Skip to content

Commit

Permalink
Adjust code for new library versions
Browse files Browse the repository at this point in the history
  • Loading branch information
grote committed Mar 6, 2024
1 parent b14f074 commit 847c77f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -100,7 +100,7 @@ internal class RestoreViewModel(
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) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down
8 changes: 3 additions & 5 deletions app/src/main/java/com/stevesoltys/seedvault/ui/LiveEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ open class LiveEvent<T> : LiveData<ConsumableEvent<T>>() {

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)
}
}

Expand Down

0 comments on commit 847c77f

Please sign in to comment.