pull/5/head
fengyuecanzhu 4 years ago
parent df9054d817
commit ab7c1b6893
  1. 3
      DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java
  2. 14
      app/src/main/java/xyz/fycz/myreader/ActivityManage.java
  3. 2
      app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt
  4. 4
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java

@ -62,7 +62,7 @@ public abstract class BaseDialog {
}); });
} }
private static void initActivityContext(Activity activity) { public static void initActivityContext(Activity activity) {
try { try {
contextWeakReference = new WeakReference<>(activity); contextWeakReference = new WeakReference<>(activity);
rootFrameLayout = new WeakReference<>((FrameLayout) activity.getWindow().getDecorView()); rootFrameLayout = new WeakReference<>((FrameLayout) activity.getWindow().getDecorView());
@ -91,6 +91,7 @@ public abstract class BaseDialog {
addDialogToRunningList(baseDialog); addDialogToRunningList(baseDialog);
if (DialogX.implIMPLMode == DialogX.IMPL_MODE.VIEW) { if (DialogX.implIMPLMode == DialogX.IMPL_MODE.VIEW) {
if (rootFrameLayout == null || rootFrameLayout.get() == null) return; if (rootFrameLayout == null || rootFrameLayout.get() == null) return;
log(rootFrameLayout.get());
runOnMain(new Runnable() { runOnMain(new Runnable() {
@Override @Override
public void run() { public void run() {

@ -3,6 +3,8 @@ package xyz.fycz.myreader;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList; import java.util.ArrayList;
import xyz.fycz.myreader.base.BaseActivity;
public class ActivityManage { public class ActivityManage {
private static ArrayList<AppCompatActivity> activities = new ArrayList<>(); private static ArrayList<AppCompatActivity> activities = new ArrayList<>();
@ -15,7 +17,7 @@ public class ActivityManage {
activities.remove(activity); activities.remove(activity);
} }
public static void finishAllActivites() { public static void finishAllActivities() {
for (AppCompatActivity activity : activities) { for (AppCompatActivity activity : activities) {
if (!activity.isFinishing()) { if (!activity.isFinishing()) {
activity.finish(); activity.finish();
@ -23,7 +25,7 @@ public class ActivityManage {
} }
} }
public static AppCompatActivity getActivityByCurrenlyRun(){ public static AppCompatActivity getActivityByCurrentlyRun(){
if(activities.size() <= 0){ if(activities.size() <= 0){
return null; return null;
} }
@ -44,4 +46,12 @@ public class ActivityManage {
return result; return result;
} }
public static AppCompatActivity getByClass(Class<?> activity){
for (AppCompatActivity item : activities) {
if (null != item && item.getClass() == activity) {
return item;
}
}
return null;
}
} }

@ -150,7 +150,7 @@ object Restore {
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(object : MySingleObserver<Boolean>() { .subscribe(object : MySingleObserver<Boolean>() {
override fun onSuccess(t: Boolean) { override fun onSuccess(t: Boolean) {
App.getApplication().initNightTheme() //App.getApplication().initNightTheme()
callBack?.restoreSuccess() callBack?.restoreSuccess()
} }

@ -40,6 +40,7 @@ import androidx.core.content.ContextCompat;
import com.gyf.immersionbar.ImmersionBar; import com.gyf.immersionbar.ImmersionBar;
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener; import com.jaredrummler.android.colorpicker.ColorPickerDialogListener;
import com.kongzue.dialogx.dialogs.BottomMenu; import com.kongzue.dialogx.dialogs.BottomMenu;
import com.kongzue.dialogx.interfaces.BaseDialog;
import com.kongzue.dialogx.interfaces.OnMenuItemSelectListener; import com.kongzue.dialogx.interfaces.OnMenuItemSelectListener;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -1473,6 +1474,9 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
mSetting.setDayStyle(!isNight); mSetting.setDayStyle(!isNight);
SysManager.saveSetting(mSetting); SysManager.saveSetting(mSetting);
App.getApplication().setNightTheme(isNight); App.getApplication().setNightTheme(isNight);
mHandler.postDelayed(() -> {
BaseDialog.initActivityContext(ActivityManage.getByClass(this.getClass()));
}, 1000);
//mPageLoader.setPageStyle(!isCurDayStyle); //mPageLoader.setPageStyle(!isCurDayStyle);
} }

Loading…
Cancel
Save