Example usage for android.support.v4.media.session PlaybackStateCompat getExtras

List of usage examples for android.support.v4.media.session PlaybackStateCompat getExtras

Introduction

In this page you can find the example usage for android.support.v4.media.session PlaybackStateCompat getExtras.

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Get any custom extras that were set on this playback state.

Usage

From source file:org.runbuddy.tomahawk.ui.fragments.PlaybackFragment.java

/**
 * Refresh the information in this fragment to reflect that of the current shuffleButton state.
 *///  www .  j  av a2 s  . c  om
protected void refreshShuffleButtonState(PlaybackStateCompat playbackState) {
    if (getView() != null) {
        ImageButton imageButton = (ImageButton) getView().findViewById(R.id.imageButton_shuffle);
        if (imageButton != null) {
            if (playbackState.getExtras() != null
                    && !(getPlaybackManager().getPlaylist() instanceof StationPlaylist)
                    && getPlaybackManager().getCurrentEntry() != null) {
                imageButton.setAlpha(1f);
                imageButton.setClickable(true);
                int repeatMode = playbackState.getExtras().getInt(PlaybackService.EXTRAS_KEY_SHUFFLE_MODE);
                if (repeatMode == PlaybackManager.SHUFFLED) {
                    ImageUtils.setTint(imageButton.getDrawable(), R.color.tomahawk_red);
                } else if (repeatMode == PlaybackManager.NOT_SHUFFLED) {
                    ImageUtils.clearTint(imageButton.getDrawable());
                }
            } else {
                imageButton.setAlpha(0.2f);
                imageButton.setClickable(false);
            }
        }
    }
}

From source file:org.runbuddy.tomahawk.ui.fragments.PlaybackFragment.java

/**
 * Refresh the information in this fragment to reflect that of the current repeatButton state.
 *//*from  w ww. jav  a  2  s.c om*/
protected void refreshRepeatButtonState(PlaybackStateCompat playbackState) {
    if (getView() != null) {
        ImageButton imageButton = (ImageButton) getView().findViewById(R.id.imageButton_repeat);
        if (imageButton != null) {
            if (playbackState.getExtras() != null
                    && !(getPlaybackManager().getPlaylist() instanceof StationPlaylist)
                    && getPlaybackManager().getCurrentEntry() != null) {
                imageButton.setAlpha(1f);
                imageButton.setClickable(true);
                int repeatMode = playbackState.getExtras().getInt(PlaybackService.EXTRAS_KEY_REPEAT_MODE);
                if (repeatMode == PlaybackManager.REPEAT_ALL) {
                    ImageUtils.loadDrawableIntoImageView(TomahawkApp.getContext(), imageButton,
                            R.drawable.repeat_all, R.color.tomahawk_red);
                } else if (repeatMode == PlaybackManager.REPEAT_ONE) {
                    ImageUtils.loadDrawableIntoImageView(TomahawkApp.getContext(), imageButton,
                            R.drawable.repeat_one, R.color.tomahawk_red);
                } else if (repeatMode == PlaybackManager.NOT_REPEATING) {
                    ImageUtils.loadDrawableIntoImageView(TomahawkApp.getContext(), imageButton,
                            R.drawable.repeat_all);
                }
            } else {
                imageButton.setAlpha(0.2f);
                imageButton.setClickable(false);
            }
        }
    }
}