From 053251d56672ff8e80103d4a2cc531bc4fb92f75 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 18 Jan 2020 04:07:15 +0800 Subject: [PATCH] Merge ViewModel Koin modules --- .../java/com/topjohnwu/magisk/di/Modules.kt | 3 +- .../com/topjohnwu/magisk/di/RedesignModule.kt | 32 ------------------- .../topjohnwu/magisk/di/ViewModelsModule.kt | 25 ++++++++++++++- 3 files changed, 25 insertions(+), 35 deletions(-) delete mode 100644 app/src/main/java/com/topjohnwu/magisk/di/RedesignModule.kt diff --git a/app/src/main/java/com/topjohnwu/magisk/di/Modules.kt b/app/src/main/java/com/topjohnwu/magisk/di/Modules.kt index 45bb22ef9..8fd05268e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/Modules.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/Modules.kt @@ -5,6 +5,5 @@ val koinModules = listOf( networkingModule, databaseModule, repositoryModule, - viewModelModules, - redesignModule + viewModelModules ) diff --git a/app/src/main/java/com/topjohnwu/magisk/di/RedesignModule.kt b/app/src/main/java/com/topjohnwu/magisk/di/RedesignModule.kt deleted file mode 100644 index a79c9a980..000000000 --- a/app/src/main/java/com/topjohnwu/magisk/di/RedesignModule.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.topjohnwu.magisk.di - -import com.topjohnwu.magisk.ui.MainViewModel -import com.topjohnwu.magisk.ui.flash.FlashViewModel -import com.topjohnwu.magisk.ui.hide.HideViewModel -import com.topjohnwu.magisk.ui.home.HomeViewModel -import com.topjohnwu.magisk.ui.install.InstallViewModel -import com.topjohnwu.magisk.ui.log.LogViewModel -import com.topjohnwu.magisk.ui.module.ModuleViewModel -import com.topjohnwu.magisk.ui.request.RequestViewModel -import com.topjohnwu.magisk.ui.safetynet.SafetynetViewModel -import com.topjohnwu.magisk.ui.settings.SettingsViewModel -import com.topjohnwu.magisk.ui.superuser.SuperuserViewModel -import com.topjohnwu.magisk.ui.theme.ThemeViewModel -import org.koin.androidx.viewmodel.dsl.viewModel -import org.koin.dsl.module - -val redesignModule = module { - viewModel { FlashViewModel() } - viewModel { HideViewModel(get()) } - viewModel { HomeViewModel(get()) } - viewModel { LogViewModel(get()) } - viewModel { ModuleViewModel(get(), get(), get()) } - viewModel { RequestViewModel() } - viewModel { SafetynetViewModel(get()) } - viewModel { SettingsViewModel(get()) } - viewModel { SuperuserViewModel(get(), get(), get()) } - viewModel { ThemeViewModel() } - viewModel { InstallViewModel() } - - viewModel { MainViewModel() } -} diff --git a/app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt b/app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt index 547068331..d85f332d5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt @@ -3,11 +3,34 @@ package com.topjohnwu.magisk.di import android.net.Uri import com.topjohnwu.magisk.legacy.flash.FlashViewModel import com.topjohnwu.magisk.legacy.surequest.SuRequestViewModel +import com.topjohnwu.magisk.ui.MainViewModel +import com.topjohnwu.magisk.ui.hide.HideViewModel +import com.topjohnwu.magisk.ui.home.HomeViewModel +import com.topjohnwu.magisk.ui.install.InstallViewModel +import com.topjohnwu.magisk.ui.log.LogViewModel +import com.topjohnwu.magisk.ui.module.ModuleViewModel +import com.topjohnwu.magisk.ui.request.RequestViewModel +import com.topjohnwu.magisk.ui.safetynet.SafetynetViewModel +import com.topjohnwu.magisk.ui.settings.SettingsViewModel +import com.topjohnwu.magisk.ui.superuser.SuperuserViewModel +import com.topjohnwu.magisk.ui.theme.ThemeViewModel import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.dsl.module - val viewModelModules = module { + viewModel { HideViewModel(get()) } + viewModel { HomeViewModel(get()) } + viewModel { LogViewModel(get()) } + viewModel { ModuleViewModel(get(), get(), get()) } + viewModel { RequestViewModel() } + viewModel { SafetynetViewModel(get()) } + viewModel { SettingsViewModel(get()) } + viewModel { SuperuserViewModel(get(), get(), get()) } + viewModel { ThemeViewModel() } + viewModel { InstallViewModel() } + viewModel { MainViewModel() } + + // Legacy viewModel { (action: String, file: Uri, additional: Uri) -> FlashViewModel(action, file, additional, get()) }