diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt index e03e55e80..87d4b0194 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt @@ -15,8 +15,8 @@ import androidx.annotation.UiThread import androidx.annotation.WorkerThread import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations.switchMap import androidx.lifecycle.asLiveData +import androidx.lifecycle.switchMap import androidx.lifecycle.viewModelScope import com.stevesoltys.seedvault.BackupMonitor import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER @@ -100,7 +100,7 @@ internal class RestoreViewModel( internal val chosenRestorableBackup: LiveData get() = mChosenRestorableBackup internal val installResult: LiveData = - switchMap(mChosenRestorableBackup) { backup -> + mChosenRestorableBackup.switchMap { backup -> getInstallResult(backup) } internal val installIntentCreator by lazy { InstallIntentCreator(app.packageManager) } diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt index e220462c3..cf1b3388f 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt @@ -21,8 +21,8 @@ import androidx.annotation.UiThread import androidx.core.content.ContextCompat.startForegroundService import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations.switchMap import androidx.lifecycle.liveData +import androidx.lifecycle.switchMap import androidx.lifecycle.viewModelScope import androidx.recyclerview.widget.DiffUtil.calculateDiff import com.stevesoltys.seedvault.BackupWorker @@ -69,7 +69,7 @@ internal class SettingsViewModel( internal val lastBackupTime = metadataManager.lastBackupTime - private val mAppStatusList = switchMap(lastBackupTime) { + private val mAppStatusList = lastBackupTime.switchMap { // updates app list when lastBackupTime changes getAppStatusResult() } diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/LiveEvent.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/LiveEvent.kt index 7dac0f91e..46720ac2b 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/LiveEvent.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/LiveEvent.kt @@ -25,11 +25,9 @@ open class LiveEvent : LiveData>() { internal class LiveEventObserver(private val handler: LiveEventHandler) : Observer> { - override fun onChanged(consumableEvent: ConsumableEvent?) { - if (consumableEvent != null) { - val content = consumableEvent.contentIfNotConsumed - if (content != null) handler.onEvent(content) - } + override fun onChanged(value: ConsumableEvent) { + val content = value.contentIfNotConsumed + if (content != null) handler.onEvent(content) } }