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 {
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() {

@ -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<AppCompatActivity> 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;
}
}

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

@ -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);
}

Loading…
Cancel
Save