Cleanup DownloadService

This commit is contained in:
topjohnwu
2021-11-06 17:45:41 -07:00
parent e660fabc57
commit 6dbd8baa7e
13 changed files with 126 additions and 210 deletions
@@ -111,16 +111,14 @@ class FlashFragment : BaseUIFragment<FlashViewModel, FragmentFlashMd2Binding>()
/* Installing is understood as flashing modules / zips */
fun installIntent(context: Context, file: Uri, id: Int = -1) = FlashFragmentArgs(
fun installIntent(context: Context, file: Uri) = FlashFragmentArgs(
action = Const.Value.FLASH_ZIP,
additionalData = file,
dismissId = id
).let { createIntent(context, it) }
fun install(file: Uri, id: Int) = MainDirections.actionFlashFragment(
fun install(file: Uri) = MainDirections.actionFlashFragment(
action = Const.Value.FLASH_ZIP,
additionalData = file,
dismissId = id
)
}
@@ -20,7 +20,6 @@ import com.topjohnwu.magisk.databinding.itemBindingOf
import com.topjohnwu.magisk.databinding.set
import com.topjohnwu.magisk.events.SnackbarEvent
import com.topjohnwu.magisk.ktx.*
import com.topjohnwu.magisk.view.Notifications
import com.topjohnwu.superuser.CallbackList
import com.topjohnwu.superuser.Shell
import kotlinx.coroutines.Dispatchers
@@ -50,9 +49,7 @@ class FlashViewModel : BaseViewModel() {
}
fun startFlashing() {
val (action, uri, id) = args
if (id != -1)
Notifications.mgr.cancel(id)
val (action, uri) = args
viewModelScope.launch {
val result = when (action) {
@@ -70,4 +70,8 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
return true
}
override fun onResume() {
super.onResume()
viewModel.stateManagerProgress = 0
}
}