Fixed theme switching

This commit is contained in:
M66B 2015-11-14 11:02:35 +01:00
parent 68fb60cd48
commit 74bbfab052
1 changed files with 6 additions and 7 deletions

View File

@ -237,6 +237,9 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
.create(); .create();
dialogFirst.show(); dialogFirst.show();
} }
// Listen for preference changes
prefs.registerOnSharedPreferenceChangeListener(this);
} }
@Override @Override
@ -244,10 +247,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
super.onResume(); super.onResume();
Log.i(TAG, "Resume"); Log.i(TAG, "Resume");
// Listen for preference changes
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
// Listen for interactive state changes // Listen for interactive state changes
IntentFilter ifInteractive = new IntentFilter(); IntentFilter ifInteractive = new IntentFilter();
ifInteractive.addAction(Intent.ACTION_SCREEN_ON); ifInteractive.addAction(Intent.ACTION_SCREEN_ON);
@ -279,9 +278,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
super.onPause(); super.onPause();
Log.i(TAG, "Pause"); Log.i(TAG, "Pause");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.unregisterOnSharedPreferenceChangeListener(this);
unregisterReceiver(interactiveStateReceiver); unregisterReceiver(interactiveStateReceiver);
unregisterReceiver(connectivityChangedReceiver); unregisterReceiver(connectivityChangedReceiver);
unregisterReceiver(packageChangedReceiver); unregisterReceiver(packageChangedReceiver);
@ -298,6 +294,9 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
running = false; running = false;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.unregisterOnSharedPreferenceChangeListener(this);
if (dialogFirst != null) { if (dialogFirst != null) {
dialogFirst.dismiss(); dialogFirst.dismiss();
dialogFirst = null; dialogFirst = null;