-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement turning on/off UI event logs
- Loading branch information
1 parent
3b00854
commit 9a3be26
Showing
8 changed files
with
166 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...rc/main/java/io/horizontalsystems/bankwallet/modules/settings/privacy/PrivacyViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.horizontalsystems.bankwallet.modules.settings.privacy | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.lifecycle.viewModelScope | ||
import io.horizontalsystems.bankwallet.core.App | ||
import io.horizontalsystems.bankwallet.core.ViewModelUiState | ||
import io.horizontalsystems.bankwallet.core.stats.StatsManager | ||
import kotlinx.coroutines.launch | ||
|
||
class PrivacyViewModel(private val statsManager: StatsManager) : ViewModelUiState<PrivacyUiState>() { | ||
private var uiStatsEnabled = statsManager.uiStatsEnabled | ||
|
||
init { | ||
viewModelScope.launch { | ||
statsManager.uiStatsEnabledFlow.collect { | ||
uiStatsEnabled = it | ||
emitState() | ||
} | ||
} | ||
} | ||
|
||
override fun createState() = PrivacyUiState( | ||
uiStatsEnabled = uiStatsEnabled | ||
) | ||
|
||
fun toggleUiStats(enabled: Boolean) { | ||
statsManager.toggleUiStats(enabled) | ||
} | ||
|
||
class Factory : ViewModelProvider.Factory { | ||
@Suppress("UNCHECKED_CAST") | ||
override fun <T : ViewModel> create(modelClass: Class<T>): T { | ||
return PrivacyViewModel(App.statsManager) as T | ||
} | ||
} | ||
|
||
} | ||
|
||
data class PrivacyUiState(val uiStatsEnabled: Boolean) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters