From b83d2bdc71977f4e974a804fb82353da3a0ce977 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 11 Oct 2020 18:17:32 +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 --- .../main/java/io/legado/app/constant/EventBus.kt | 1 - .../java/io/legado/app/ui/config/ConfigActivity.kt | 10 ---------- .../io/legado/app/ui/config/OtherConfigFragment.kt | 13 ++++++++----- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/EventBus.kt b/app/src/main/java/io/legado/app/constant/EventBus.kt index 8e6c2a9e6..dd00d8cee 100644 --- a/app/src/main/java/io/legado/app/constant/EventBus.kt +++ b/app/src/main/java/io/legado/app/constant/EventBus.kt @@ -3,7 +3,6 @@ package io.legado.app.constant object EventBus { const val MEDIA_BUTTON = "mediaButton" const val RECREATE = "RECREATE" - const val REOPEN = "REOPEN" const val UP_BOOK = "upBookToc" const val ALOUD_STATE = "aloud_state" const val TTS_PROGRESS = "ttsStart" diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt index 0c2525d9c..6d7bfcfe7 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt @@ -1,13 +1,9 @@ package io.legado.app.ui.config -import android.content.Intent import android.os.Bundle -import android.os.Process -import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.EventBus -import io.legado.app.ui.main.MainActivity import io.legado.app.utils.getViewModel import io.legado.app.utils.observeEvent import kotlinx.android.synthetic.main.activity_config.* @@ -58,11 +54,5 @@ class ConfigActivity : VMBaseActivity(R.layout.activity_config) observeEvent(EventBus.RECREATE) { recreate() } - observeEvent(EventBus.REOPEN) { - val intent = Intent(App.INSTANCE, MainActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) - App.INSTANCE.startActivity(intent) - Process.killProcess(Process.myPid()) - } } } \ No newline at end of file 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 36fe3dc92..542ae8780 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 @@ -7,7 +7,7 @@ import android.content.SharedPreferences import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle -import android.util.Log +import android.os.Process import android.view.View import androidx.documentfile.provider.DocumentFile import androidx.preference.ListPreference @@ -28,11 +28,11 @@ import io.legado.app.lib.dialogs.selector import io.legado.app.lib.theme.ATH import io.legado.app.receiver.SharedReceiverActivity import io.legado.app.service.WebService +import io.legado.app.ui.main.MainActivity import io.legado.app.ui.widget.image.CoverImageView import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.utils.* import java.io.File -import java.util.* class OtherConfigFragment : BasePreferenceFragment(), @@ -124,10 +124,13 @@ class OtherConfigFragment : BasePreferenceFragment(), ) PreferKey.replaceEnableDefault -> AppConfig.replaceEnableDefault = App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true) - PreferKey.language -> { + PreferKey.language -> listView.postDelayed({ LanguageUtils.setConfiguration(App.INSTANCE) - postEvent(EventBus.REOPEN, "") - } + val intent = Intent(App.INSTANCE, MainActivity::class.java) + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) + App.INSTANCE.startActivity(intent) + Process.killProcess(Process.myPid()) + }, 1000) } }