Prevent UI loop on low memory device

Fix , close 
This commit is contained in:
topjohnwu 2020-10-06 02:21:57 -07:00
parent fc19b50290
commit d462873e74
2 changed files with 26 additions and 3 deletions
app/src/main/java/com/topjohnwu/magisk/ui/install

View File

@ -1,5 +1,9 @@
package com.topjohnwu.magisk.ui.install
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.viewModelScope
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.arch.BaseUIFragment
@ -22,4 +26,20 @@ class InstallFragment : BaseUIFragment<InstallViewModel, FragmentInstallMd2Bindi
BaseDownloader.observeProgress(this, viewModel::onProgressUpdate)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
viewModel._method = savedInstanceState?.getInt(KEY_CURRENT_METHOD, -1) ?: -1
return super.onCreateView(inflater, container, savedInstanceState)
}
override fun onSaveInstanceState(outState: Bundle) {
outState.putInt(KEY_CURRENT_METHOD, viewModel.method)
}
companion object {
private const val KEY_CURRENT_METHOD = "current_method"
}
}

View File

@ -31,9 +31,12 @@ class InstallViewModel(
var step = if (skipOptions) 1 else 0
set(value) = set(value, field, { field = it }, BR.step)
var _method = -1
@get:Bindable
var method = -1
set(value) = set(value, field, { field = it }, BR.method) {
var method
get() = _method
set(value) = set(value, _method, { _method = it }, BR.method) {
when (it) {
R.id.method_patch -> {
MagiskInstallFileEvent { code, intent ->