Created
March 23, 2022 00:03
-
-
Save mattttvaughn/6879649ba9ee4b179070ab1d3f721dd8 to your computer and use it in GitHub Desktop.
Updating skip forwards/backwards icons in currently playing
This file contains hidden or 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
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") | |
} | |
This file contains hidden or 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
android:src="@{viewModel.jumpBackwardsIcon}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment