Browse Source

improve restart

master
DF1E 10 years ago
parent
commit
2551b3dc27
  1. 2
      src/acr/browser/lightning/DisplaySettingsActivity.java
  2. 12
      src/acr/browser/lightning/ThemableActivity.java

2
src/acr/browser/lightning/DisplaySettingsActivity.java

@ -121,7 +121,7 @@ public class DisplaySettingsActivity extends ThemableActivity { @@ -121,7 +121,7 @@ public class DisplaySettingsActivity extends ThemableActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPreferences.edit().putBoolean(PreferenceConstants.DARK_THEME, isChecked).apply();
mActivity.recreate();
restart();
}
});

12
src/acr/browser/lightning/ThemableActivity.java

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
package acr.browser.lightning;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
@ -36,7 +37,16 @@ public abstract class ThemableActivity extends ActionBarActivity { @@ -36,7 +37,16 @@ public abstract class ThemableActivity extends ActionBarActivity {
if (mPreferences != null
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME,
false) != mDark) {
this.recreate();
restart();
}
}
protected void restart() {
final Bundle outState = new Bundle();
onSaveInstanceState(outState);
final Intent intent = new Intent(this, getClass());
finish();
overridePendingTransition(0, 0);
startActivity(intent);
}
}

Loading…
Cancel
Save