Fix small theme config issue

This commit is contained in:
topjohnwu 2018-09-17 23:29:38 -04:00
parent e6afbf2ec0
commit 017fbf267b
4 changed files with 10 additions and 16 deletions

View File

@ -110,11 +110,6 @@ public class MainActivity extends BaseActivity
return true; return true;
} }
@Override
public int[] getSubscribedTopics() {
return new int[] {Topic.RELOAD_ACTIVITY};
}
@Override @Override
public void onPublish(int topic, Object[] result) { public void onPublish(int topic, Object[] result) {
recreate(); recreate();

View File

@ -43,11 +43,11 @@ public abstract class FlavorActivity extends AppCompatActivity implements Topic.
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Topic.subscribe(this); Topic.subscribe(this);
if (Data.isDarkTheme && getDarkTheme() != -1) { if (Data.isDarkTheme && getDarkTheme() != -1) {
setTheme(getDarkTheme()); setTheme(getDarkTheme());
} }
super.onCreate(savedInstanceState);
} }
@Override @Override

View File

@ -222,7 +222,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
setSummary(); setSummary();
switch (key) { switch (key) {
case Const.Key.DARK_THEME: case Const.Key.DARK_THEME:
Topic.publish(false, Topic.RELOAD_ACTIVITY); requireActivity().recreate();
break; break;
case Const.Key.COREONLY: case Const.Key.COREONLY:
if (prefs.getBoolean(key, false)) { if (prefs.getBoolean(key, false)) {
@ -254,7 +254,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
break; break;
case Const.Key.LOCALE: case Const.Key.LOCALE:
LocaleManager.setLocale(mm); LocaleManager.setLocale(mm);
Topic.publish(false, Topic.RELOAD_ACTIVITY); requireActivity().recreate();
break; break;
case Const.Key.UPDATE_CHANNEL: case Const.Key.UPDATE_CHANNEL:
case Const.Key.CUSTOM_CHANNEL: case Const.Key.CUSTOM_CHANNEL:

View File

@ -12,20 +12,19 @@ import androidx.annotation.IntDef;
public class Topic { public class Topic {
public static final int MAGISK_HIDE_DONE = 0; public static final int MAGISK_HIDE_DONE = 0;
public static final int RELOAD_ACTIVITY = 1; public static final int MODULE_LOAD_DONE = 1;
public static final int MODULE_LOAD_DONE = 2; public static final int REPO_LOAD_DONE = 2;
public static final int REPO_LOAD_DONE = 3; public static final int UPDATE_CHECK_DONE = 3;
public static final int UPDATE_CHECK_DONE = 4; public static final int SNET_CHECK_DONE = 4;
public static final int SNET_CHECK_DONE = 5; public static final int LOCALE_FETCH_DONE = 5;
public static final int LOCALE_FETCH_DONE = 6;
@IntDef({MAGISK_HIDE_DONE, RELOAD_ACTIVITY, MODULE_LOAD_DONE, REPO_LOAD_DONE, @IntDef({MAGISK_HIDE_DONE, MODULE_LOAD_DONE, REPO_LOAD_DONE,
UPDATE_CHECK_DONE, SNET_CHECK_DONE, LOCALE_FETCH_DONE}) UPDATE_CHECK_DONE, SNET_CHECK_DONE, LOCALE_FETCH_DONE})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface TopicID {} public @interface TopicID {}
// We will not dynamically add topics, so use arrays instead of hash tables // We will not dynamically add topics, so use arrays instead of hash tables
private static Store[] topicList = new Store[7]; private static Store[] topicList = new Store[6];
public static void subscribe(Subscriber sub, @TopicID int... topics) { public static void subscribe(Subscriber sub, @TopicID int... topics) {
for (int topic : topics) { for (int topic : topics) {