Skip to content

Instantly share code, notes, and snippets.

@ademirqueiroga
Last active February 6, 2023 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ademirqueiroga/3e4e0dbffb9183a35d1d50392333faa8 to your computer and use it in GitHub Desktop.
Save ademirqueiroga/3e4e0dbffb9183a35d1d50392333faa8 to your computer and use it in GitHub Desktop.
AwesomeTransportControlGlue handling secondary actions
private fun onSecondaryActionPressed(action: Action) {
val adapter = controlsRow.secondaryActionsAdapter as? ArrayObjectAdapter ?: return
if (action is PlaybackControlsRow.MultiAction) {
action.nextIndex()
notifyItemChanged(adapter, action)
}
when (action) {
shuffleAction -> {
playerAdapter.setShuffleAction(shuffleAction.index)
if (shuffleAction.index == PlaybackControlsRow.ShuffleAction.INDEX_ON) {
shuffledPositions.shuffle()
}
}
repeatAction -> playerAdapter.setRepeatAction(repeatAction.index)
thumbsUpAction -> currentMovie.let(LikedMovies::toggle)
myListAction -> currentMovie.let(MyList::toggle)
}
}
override fun onActionClicked(action: Action?) {
when (action) {
thumbsUpAction,
shuffleAction,
repeatAction,
myListAction -> onSecondaryActionPressed(action)
forwardAction -> {
playerAdapter.fastForward()
onUpdateProgress()
}
rewindAction -> {
playerAdapter.rewind()
onUpdateProgress()
}
else -> super.onActionClicked(action)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment