Created
March 24, 2021 13:16
-
-
Save vegeta2102/f4779caf4d49f6a8dbec0e86e0ddb99f to your computer and use it in GitHub Desktop.
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
class ProgressBarViewModel @ViewModelInject constructor( | |
private val progressBarRepository: ProgressBarRepository | |
) : ViewModel() { | |
// Display seconds | |
val countDown: LiveData<String> = progressBarRepository.data.map { | |
it.time.toString() | |
}.asLiveData().distinctUntilChanged() | |
// Progress state of circle bar | |
val progress: LiveData<Int> = progressBarRepository.data.map { | |
it.progress | |
}.asLiveData().distinctUntilChanged() | |
fun start() { | |
viewModelScope.launch { | |
// Count down 10 seconds | |
progressBarRepository.startCountDown(10) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment