From ab7c1b689333a6c088014bde8beb39ff9347f7f4 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Sun, 6 Jun 2021 17:55:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/kongzue/dialogx/interfaces/BaseDialog.java | 3 ++- .../java/xyz/fycz/myreader/ActivityManage.java | 14 ++++++++++++-- .../xyz/fycz/myreader/model/storage/Restore.kt | 2 +- .../fycz/myreader/ui/activity/ReadActivity.java | 4 ++++ 4 files changed, 19 insertions(+), 4 deletions(-) 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); }