From 637f31a3b7cf194fe0c53ca15ee3059741b8119f Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 24 Oct 2021 14:29:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 5 +++++ app/src/main/java/io/legado/app/help/LifecycleHelp.kt | 4 ---- .../main/java/io/legado/app/ui/config/OtherConfigFragment.kt | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 466e2407b..87de7cc33 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -7,6 +7,7 @@ import android.content.res.Configuration import android.os.Build import androidx.multidex.MultiDexApplication import com.jeremyliao.liveeventbus.LiveEventBus +import io.legado.app.base.AppContextWrapper import io.legado.app.constant.AppConst.channelIdDownload import io.legado.app.constant.AppConst.channelIdReadAloud import io.legado.app.constant.AppConst.channelIdWeb @@ -37,6 +38,10 @@ class App : MultiDexApplication() { defaultSharedPreferences.registerOnSharedPreferenceChangeListener(AppConfig) } + override fun attachBaseContext(base: Context) { + super.attachBaseContext(AppContextWrapper.wrap(base)) + } + override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) when (newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK) { diff --git a/app/src/main/java/io/legado/app/help/LifecycleHelp.kt b/app/src/main/java/io/legado/app/help/LifecycleHelp.kt index 387e37d89..dad8ca883 100644 --- a/app/src/main/java/io/legado/app/help/LifecycleHelp.kt +++ b/app/src/main/java/io/legado/app/help/LifecycleHelp.kt @@ -3,7 +3,6 @@ package io.legado.app.help import android.app.Activity import android.app.Application import android.os.Bundle -import io.legado.app.base.AppContextWrapper import io.legado.app.base.BaseService import java.lang.ref.WeakReference import java.util.* @@ -86,9 +85,6 @@ object LifecycleHelp : Application.ActivityLifecycleCallbacks { override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { activities.add(WeakReference(activity)) - if (!AppContextWrapper.isSameWithSetting(activity)) { - AppContextWrapper.wrap(activity) - } } @Synchronized diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 5c6bed4d9..38eda3429 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -11,7 +11,6 @@ import android.view.View import androidx.preference.ListPreference import androidx.preference.Preference import io.legado.app.R -import io.legado.app.base.AppContextWrapper import io.legado.app.base.BasePreferenceFragment import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey @@ -114,7 +113,6 @@ class OtherConfigFragment : BasePreferenceFragment(), } PreferKey.showDiscovery, PreferKey.showRss -> postEvent(EventBus.NOTIFY_MAIN, true) PreferKey.language -> listView.postDelayed({ - AppContextWrapper.wrap(appCtx) val intent = Intent(appCtx, MainActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) appCtx.startActivity(intent)