修复MIUI13阅读界面切换日夜间闪退的问题

master
fengyuecanzhu 3 years ago
parent 5eb19128c9
commit 6c723feb27
  1. 9
      app/src/main/java/xyz/fycz/myreader/base/BaseActivity.java
  2. 20
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java

@ -41,7 +41,6 @@ public abstract class BaseActivity extends SwipeBackActivity {
protected Toolbar mToolbar; protected Toolbar mToolbar;
private int curNightMode;
/****************************abstract area*************************************/ /****************************abstract area*************************************/
/** /**
* 绑定视图 * 绑定视图
@ -154,9 +153,6 @@ public abstract class BaseActivity extends SwipeBackActivity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (isThemeChange()) {
recreate();
}
} }
@Override @Override
@ -174,17 +170,12 @@ public abstract class BaseActivity extends SwipeBackActivity {
public void initTheme() { public void initTheme() {
//if (isNightTheme()) { //if (isNightTheme()) {
//setTheme(R.style.AppNightTheme); //setTheme(R.style.AppNightTheme);
curNightMode = AppCompatDelegate.getDefaultNightMode();
/*} else { /*} else {
//curNightMode = false; //curNightMode = false;
//setTheme(R.style.AppDayTheme); //setTheme(R.style.AppDayTheme);
}*/ }*/
} }
protected boolean isThemeChange() {
return curNightMode != AppCompatDelegate.getDefaultNightMode();
}
/**************************used method area*******************************************/ /**************************used method area*******************************************/
protected void startActivity(Class<? extends AppCompatActivity> activity) { protected void startActivity(Class<? extends AppCompatActivity> activity) {

@ -653,6 +653,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
} }
} }
, (dialog, which) -> { , (dialog, which) -> {
isCollected = false;
mBookService.deleteBookById(mBook.getId()); mBookService.deleteBookById(mBook.getId());
exit(); exit();
}); });
@ -1392,13 +1393,28 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
private void changeNightAndDaySetting(boolean isNight) { private void changeNightAndDaySetting(boolean isNight) {
mSetting.setDayStyle(!isNight); mSetting.setDayStyle(!isNight);
SysManager.saveSetting(mSetting); SysManager.saveSetting(mSetting);
App.getApplication().setNightTheme(isNight); toggleMenu(true);
mHandler.postDelayed(() -> { mHandler.postDelayed(() -> {
Intent intent = new Intent(this, ReadActivity.class);
if (aBooks != null) {
intent.putExtra(APPCONST.SOURCE_INDEX, mSourceDialog.getSourceIndex());
BitIntentDataManager.getInstance().putData(intent, aBooks);
} else {
BitIntentDataManager.getInstance().putData(intent, mBook);
}
if (!isCollected) {
intent.putExtra("isCollected", false);
}
exit();
App.getApplication().setNightTheme(isNight);
startActivity(intent);
}, mBottomOutAnim.getDuration());
/*mHandler.postDelayed(() -> {
AppCompatActivity activity = ActivityManage.getByClass(this.getClass()); AppCompatActivity activity = ActivityManage.getByClass(this.getClass());
if (activity != null) { if (activity != null) {
BaseDialog.initActivityContext(activity); BaseDialog.initActivityContext(activity);
} }
}, 1000); }, 1000);*/
//mPageLoader.setPageStyle(!isCurDayStyle); //mPageLoader.setPageStyle(!isCurDayStyle);
} }

Loading…
Cancel
Save