You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
@@ -4,7 +4,7 @@ import android.content.Intent
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.BaseUIFragment
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloadService
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloader
|
||||
import com.topjohnwu.magisk.databinding.FragmentInstallMd2Binding
|
||||
import com.topjohnwu.magisk.events.RequestFileEvent
|
||||
import com.topjohnwu.magisk.ktx.coroutineScope
|
||||
@@ -26,7 +26,7 @@ class InstallFragment : BaseUIFragment<InstallViewModel, FragmentInstallMd2Bindi
|
||||
|
||||
// Allow markwon to run in viewmodel scope
|
||||
binding.releaseNotes.coroutineScope = viewModel.viewModelScope
|
||||
BaseDownloadService.observeProgress(this, viewModel::onProgressUpdate)
|
||||
BaseDownloader.observeProgress(this, viewModel::onProgressUpdate)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,17 +78,16 @@ class InstallViewModel(
|
||||
step = nextStep
|
||||
}
|
||||
|
||||
fun install() = DownloadService(get()) {
|
||||
subject = Subject.Magisk(resolveConfiguration())
|
||||
}.also { state = State.LOADING }
|
||||
fun install() =
|
||||
DownloadService(get(), Subject.Magisk(resolveAction())).also { state = State.LOADING }
|
||||
|
||||
// ---
|
||||
|
||||
private fun resolveConfiguration() = when (method) {
|
||||
private fun resolveAction() = when (method) {
|
||||
R.id.method_download -> Action.Download
|
||||
R.id.method_patch -> Action.Patch(data!!)
|
||||
R.id.method_direct -> Action.Flash.Primary
|
||||
R.id.method_inactive_slot -> Action.Flash.Secondary
|
||||
else -> throw IllegalArgumentException("Unknown value")
|
||||
else -> error("Unknown value")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user