restart if theme changed
This commit is contained in:
parent
afdc28c041
commit
d9ef4625b8
@ -29,6 +29,7 @@ public class CommonActivity extends SherlockFragmentActivity {
|
||||
|
||||
private boolean m_smallScreenMode = true;
|
||||
private boolean m_compatMode = false;
|
||||
private String m_theme;
|
||||
|
||||
protected SharedPreferences m_prefs;
|
||||
|
||||
@ -84,6 +85,18 @@ public class CommonActivity extends SherlockFragmentActivity {
|
||||
return m_writableDb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (!m_theme.equals(m_prefs.getString("theme", "THEME_DARK"))) {
|
||||
Log.d(TAG, "theme changed, restarting");
|
||||
|
||||
finish();
|
||||
startActivity(getIntent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
@ -96,7 +109,13 @@ public class CommonActivity extends SherlockFragmentActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
m_prefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(getApplicationContext());
|
||||
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
m_theme = savedInstanceState.getString("theme");
|
||||
} else {
|
||||
m_theme = m_prefs.getString("theme", "THEME_DARK");
|
||||
}
|
||||
|
||||
initDatabase();
|
||||
|
||||
m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
|
||||
@ -106,6 +125,13 @@ public class CommonActivity extends SherlockFragmentActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle out) {
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
out.putString("theme", m_theme);
|
||||
}
|
||||
|
||||
public boolean isSmallScreen() {
|
||||
return m_smallScreenMode;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user