Crash fixes

This commit is contained in:
arkon 2020-04-14 17:13:45 -04:00
parent e67bb64311
commit 0bb6e1cdc2
2 changed files with 13 additions and 1 deletions

View File

@ -3,6 +3,8 @@ package eu.kanade.tachiyomi
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import android.content.res.Configuration import android.content.res.Configuration
import android.os.Build
import android.webkit.WebView
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent import androidx.lifecycle.OnLifecycleEvent
@ -43,6 +45,14 @@ open class App : Application(), LifecycleObserver {
LocaleHelper.updateConfiguration(this, resources.configuration) LocaleHelper.updateConfiguration(this, resources.configuration)
ProcessLifecycleOwner.get().lifecycle.addObserver(this) ProcessLifecycleOwner.get().lifecycle.addObserver(this)
// Avoid sharing WebView instance across multiple processes
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val processName = getProcessName()
if (packageName != processName) {
WebView.setDataDirectorySuffix(processName)
}
}
} }
override fun attachBaseContext(base: Context) { override fun attachBaseContext(base: Context) {
@ -56,6 +66,7 @@ open class App : Application(), LifecycleObserver {
} }
@OnLifecycleEvent(Lifecycle.Event.ON_STOP) @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
@Suppress("unused")
fun onAppBackgrounded() { fun onAppBackgrounded() {
val preferences: PreferencesHelper by injectLazy() val preferences: PreferencesHelper by injectLazy()
if (preferences.lockAppAfter().getOrDefault() >= 0) { if (preferences.lockAppAfter().getOrDefault() >= 0) {

View File

@ -59,13 +59,14 @@ class MainActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = MainActivityBinding.inflate(layoutInflater)
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079 // Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079
if (!isTaskRoot) { if (!isTaskRoot) {
finish() finish()
return return
} }
binding = MainActivityBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
setSupportActionBar(binding.toolbar) setSupportActionBar(binding.toolbar)