diff --git a/DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java b/DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java index 5e3d02b..08f23cf 100644 --- a/DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java +++ b/DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java @@ -62,7 +62,7 @@ public abstract class BaseDialog { }); } - private static void initActivityContext(Activity activity) { + public static void initActivityContext(Activity activity) { try { contextWeakReference = new WeakReference<>(activity); rootFrameLayout = new WeakReference<>((FrameLayout) activity.getWindow().getDecorView()); @@ -91,6 +91,7 @@ public abstract class BaseDialog { addDialogToRunningList(baseDialog); if (DialogX.implIMPLMode == DialogX.IMPL_MODE.VIEW) { if (rootFrameLayout == null || rootFrameLayout.get() == null) return; + log(rootFrameLayout.get()); runOnMain(new Runnable() { @Override public void run() { diff --git a/app/src/main/java/xyz/fycz/myreader/ActivityManage.java b/app/src/main/java/xyz/fycz/myreader/ActivityManage.java index 7a8b7fd..cbfd3f9 100644 --- a/app/src/main/java/xyz/fycz/myreader/ActivityManage.java +++ b/app/src/main/java/xyz/fycz/myreader/ActivityManage.java @@ -3,6 +3,8 @@ package xyz.fycz.myreader; import androidx.appcompat.app.AppCompatActivity; import java.util.ArrayList; +import xyz.fycz.myreader.base.BaseActivity; + public class ActivityManage { private static ArrayList activities = new ArrayList<>(); @@ -15,7 +17,7 @@ public class ActivityManage { activities.remove(activity); } - public static void finishAllActivites() { + public static void finishAllActivities() { for (AppCompatActivity activity : activities) { if (!activity.isFinishing()) { activity.finish(); @@ -23,7 +25,7 @@ public class ActivityManage { } } - public static AppCompatActivity getActivityByCurrenlyRun(){ + public static AppCompatActivity getActivityByCurrentlyRun(){ if(activities.size() <= 0){ return null; } @@ -44,4 +46,12 @@ public class ActivityManage { return result; } + public static AppCompatActivity getByClass(Class activity){ + for (AppCompatActivity item : activities) { + if (null != item && item.getClass() == activity) { + return item; + } + } + return null; + } } diff --git a/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt b/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt index 0c05456..48a0ea4 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt @@ -150,7 +150,7 @@ object Restore { .observeOn(AndroidSchedulers.mainThread()) .subscribe(object : MySingleObserver() { override fun onSuccess(t: Boolean) { - App.getApplication().initNightTheme() + //App.getApplication().initNightTheme() callBack?.restoreSuccess() } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java index c78b6c8..fddd6e6 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java @@ -40,6 +40,7 @@ import androidx.core.content.ContextCompat; import com.gyf.immersionbar.ImmersionBar; import com.jaredrummler.android.colorpicker.ColorPickerDialogListener; import com.kongzue.dialogx.dialogs.BottomMenu; +import com.kongzue.dialogx.interfaces.BaseDialog; import com.kongzue.dialogx.interfaces.OnMenuItemSelectListener; import org.jetbrains.annotations.NotNull; @@ -1473,6 +1474,9 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe mSetting.setDayStyle(!isNight); SysManager.saveSetting(mSetting); App.getApplication().setNightTheme(isNight); + mHandler.postDelayed(() -> { + BaseDialog.initActivityContext(ActivityManage.getByClass(this.getClass())); + }, 1000); //mPageLoader.setPageStyle(!isCurDayStyle); }