Skip to content

Instantly share code, notes, and snippets.

@mattttvaughn
Created March 23, 2022 00:03
Show Gist options
  • Save mattttvaughn/6879649ba9ee4b179070ab1d3f721dd8 to your computer and use it in GitHub Desktop.
Save mattttvaughn/6879649ba9ee4b179070ab1d3f721dd8 to your computer and use it in GitHub Desktop.
Updating skip forwards/backwards icons in currently playing
private var _jumpForwardsIcon = MutableLiveData(makeJumpForwardsIcon())
val jumpForwardsIcon: LiveData<Int>
get() = _jumpForwardsIcon
private var _jumpBackwardsIcon = MutableLiveData(makeJumpBackwardsIcon())
val jumpBackwardsIcon: LiveData<Int>
get() = _jumpBackwardsIcon
// this listener already exists, just add the KEY_JUMP lines
private val prefsChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
when (key) {
PrefsRepo.KEY_PLAYBACK_SPEED -> _speed.postValue(prefsRepo.playbackSpeed)
// Add these \/ \/ \/
PrefsRepo.KEY_JUMP_FORWARD_SECONDS -> _jumpForwardsIcon.value = makeJumpForwardsIcon()
PrefsRepo.KEY_JUMP_BACKWARD_SECONDS -> _jumpBackwardsIcon.value = makeJumpBackwardsIcon()
}
}
fun makeJumpForwardsIcon(): Int {
return when (prefsRepo.jumpForwardSeconds) {
10L -> R.drawable.ic_forward_10_white
// TODO: finish this
else -> R.drawable.ic_forward_30_white
}
}
fun makeJumpForwardsIcon(): Int {
TODO("finish this too")
}
android:src="@{viewModel.jumpBackwardsIcon}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment