Adjust code for new library versions
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 e03e55e..87d4b01 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.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 val chosenRestorableBackup: LiveData<RestorableBackup> get() = mChosenRestorableBackup
internal val installResult: LiveData<InstallResult> =
- 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 e220462..cf1b338 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.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 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 7dac0f9..46720ac 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 @@
internal class LiveEventObserver<T>(private val handler: LiveEventHandler<in T>) :
Observer<ConsumableEvent<T>> {
- override fun onChanged(consumableEvent: ConsumableEvent<T>?) {
- if (consumableEvent != null) {
- val content = consumableEvent.contentIfNotConsumed
- if (content != null) handler.onEvent(content)
- }
+ override fun onChanged(value: ConsumableEvent<T>) {
+ val content = value.contentIfNotConsumed
+ if (content != null) handler.onEvent(content)
}
}