Commit d462873e authored by topjohnwu's avatar topjohnwu

Prevent UI loop on low memory device

Fix #3215, close #3216
parent fc19b502
package com.topjohnwu.magisk.ui.install 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 androidx.lifecycle.viewModelScope
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.arch.BaseUIFragment import com.topjohnwu.magisk.arch.BaseUIFragment
...@@ -22,4 +26,20 @@ class InstallFragment : BaseUIFragment<InstallViewModel, FragmentInstallMd2Bindi ...@@ -22,4 +26,20 @@ class InstallFragment : BaseUIFragment<InstallViewModel, FragmentInstallMd2Bindi
BaseDownloader.observeProgress(this, viewModel::onProgressUpdate) 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"
}
} }
...@@ -31,13 +31,16 @@ class InstallViewModel( ...@@ -31,13 +31,16 @@ class InstallViewModel(
var step = if (skipOptions) 1 else 0 var step = if (skipOptions) 1 else 0
set(value) = set(value, field, { field = it }, BR.step) set(value) = set(value, field, { field = it }, BR.step)
var _method = -1
@get:Bindable @get:Bindable
var method = -1 var method
set(value) = set(value, field, { field = it }, BR.method) { get() = _method
set(value) = set(value, _method, { _method = it }, BR.method) {
when (it) { when (it) {
R.id.method_patch -> { R.id.method_patch -> {
MagiskInstallFileEvent { code, intent -> MagiskInstallFileEvent { code, intent ->
if (code == Activity.RESULT_OK) if (code == Activity.RESULT_OK)
data = intent?.data data = intent?.data
}.publish() }.publish()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment