Last active
February 6, 2023 11:21
-
-
Save ademirqueiroga/3e4e0dbffb9183a35d1d50392333faa8 to your computer and use it in GitHub Desktop.
AwesomeTransportControlGlue handling secondary actions
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
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