pull/416/head
gedoor 4 years ago
parent 32cd813fa6
commit b83d2bdc71
  1. 1
      app/src/main/java/io/legado/app/constant/EventBus.kt
  2. 10
      app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt
  3. 13
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.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"

@ -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<ConfigViewModel>(R.layout.activity_config)
observeEvent<String>(EventBus.RECREATE) {
recreate()
}
observeEvent<String>(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())
}
}
}

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

Loading…
Cancel
Save