From 96de0f86fe43b3b00530022afccec772fdaf1d12 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 15 Nov 2021 12:23:51 +0100 Subject: [PATCH] Fix lint issue "NullSafeMutableLiveData" LiveData value assignment nullability mismatch --- .../KeysBackupRestoreFromKeyViewModel.kt | 9 ++------- ...KeysBackupRestoreFromPassphraseViewModel.kt | 9 ++------- .../KeysBackupRestoreSharedViewModel.kt | 10 ++-------- .../setup/KeysBackupSetupSharedViewModel.kt | 18 +++++------------- 4 files changed, 11 insertions(+), 35 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreFromKeyViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreFromKeyViewModel.kt index ddbe86305c..a0a6a138dc 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreFromKeyViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreFromKeyViewModel.kt @@ -29,13 +29,8 @@ class KeysBackupRestoreFromKeyViewModel @Inject constructor( private val stringProvider: StringProvider ) : ViewModel() { - var recoveryCode: MutableLiveData = MutableLiveData() - var recoveryCodeErrorText: MutableLiveData = MutableLiveData() - - init { - recoveryCode.value = null - recoveryCodeErrorText.value = null - } + var recoveryCode: MutableLiveData = MutableLiveData(null) + var recoveryCodeErrorText: MutableLiveData = MutableLiveData(null) // ========= Actions ========= fun updateCode(newValue: String) { diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreFromPassphraseViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreFromPassphraseViewModel.kt index af5938e20a..81d3c64dec 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreFromPassphraseViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreFromPassphraseViewModel.kt @@ -28,13 +28,8 @@ class KeysBackupRestoreFromPassphraseViewModel @Inject constructor( private val stringProvider: StringProvider ) : ViewModel() { - var passphrase: MutableLiveData = MutableLiveData() - var passphraseErrorText: MutableLiveData = MutableLiveData() - - init { - passphrase.value = null - passphraseErrorText.value = null - } + var passphrase: MutableLiveData = MutableLiveData(null) + var passphraseErrorText: MutableLiveData = MutableLiveData(null) // ========= Actions ========= diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreSharedViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreSharedViewModel.kt index 34a333d588..8362a3566e 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreSharedViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreSharedViewModel.kt @@ -57,7 +57,7 @@ class KeysBackupRestoreSharedViewModel @Inject constructor( lateinit var session: Session - var keyVersionResult: MutableLiveData = MutableLiveData() + var keyVersionResult: MutableLiveData = MutableLiveData(null) var keySourceModel: MutableLiveData = MutableLiveData() @@ -69,17 +69,11 @@ class KeysBackupRestoreSharedViewModel @Inject constructor( val navigateEvent: LiveData> get() = _navigateEvent - var loadingEvent: MutableLiveData = MutableLiveData() + var loadingEvent: MutableLiveData = MutableLiveData(null) var importKeyResult: ImportRoomKeysResult? = null var importRoomKeysFinishWithResult: MutableLiveData> = MutableLiveData() - init { - keyVersionResult.value = null - _keyVersionResultError.value = null - loadingEvent.value = null - } - fun initSession(session: Session) { this.session = session } diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupSharedViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupSharedViewModel.kt index cd59a69a86..1141886689 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupSharedViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupSharedViewModel.kt @@ -68,23 +68,15 @@ class KeysBackupSetupSharedViewModel @Inject constructor() : ViewModel() { // Step 3 // Var to ignore events from previous request(s) to generate a recovery key private var currentRequestId: MutableLiveData = MutableLiveData() - var recoveryKey: MutableLiveData = MutableLiveData() - var prepareRecoverFailError: MutableLiveData = MutableLiveData() + var recoveryKey: MutableLiveData = MutableLiveData(null) + var prepareRecoverFailError: MutableLiveData = MutableLiveData(null) var megolmBackupCreationInfo: MegolmBackupCreationInfo? = null var copyHasBeenMade = false - var isCreatingBackupVersion: MutableLiveData = MutableLiveData() - var creatingBackupError: MutableLiveData = MutableLiveData() + var isCreatingBackupVersion: MutableLiveData = MutableLiveData(false) + var creatingBackupError: MutableLiveData = MutableLiveData(null) var keysVersion: MutableLiveData = MutableLiveData() - var loadingStatus: MutableLiveData = MutableLiveData() - - init { - recoveryKey.value = null - isCreatingBackupVersion.value = false - prepareRecoverFailError.value = null - creatingBackupError.value = null - loadingStatus.value = null - } + var loadingStatus: MutableLiveData = MutableLiveData(null) fun initSession(session: Session) { this.session = session