FileDocCategorySizeDatePackage
PlaybackControlsPresenter.javaAPI DocAndroid 5.1 API11662Thu Mar 12 22:22:56 GMT 2015android.support.v17.leanback.widget

PlaybackControlsPresenter

public class PlaybackControlsPresenter extends ControlBarPresenter
A presenter for a control bar that supports "more actions", and toggling the set of controls between primary and secondary sets of {@link Actions}.

Fields Summary
private boolean
mMoreActionsEnabled
private static int
sChildMarginBigger
private static int
sChildMarginBiggest
Constructors Summary
public PlaybackControlsPresenter(int layoutResourceId)
Constructor for a PlaybackControlsRowPresenter.

param
layoutResourceId The resource id of the layout for this presenter.


                        
       
        super(layoutResourceId);
    
Methods Summary
public booleanareMoreActionsEnabled()
Returns true if secondary actions are enabled.

        return mMoreActionsEnabled;
    
public voidenableSecondaryActions(boolean enable)
Enables the display of secondary actions. A "more actions" button will be displayed. When "more actions" is selected, the primary actions are replaced with the secondary actions.

        mMoreActionsEnabled = enable;
    
public voidenableTimeMargins(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh, boolean enable)

        MarginLayoutParams lp;
        lp = (MarginLayoutParams) vh.mCurrentTime.getLayoutParams();
        lp.setMarginStart(enable ? vh.mCurrentTimeMarginStart : 0);
        vh.mCurrentTime.setLayoutParams(lp);

        lp = (MarginLayoutParams) vh.mTotalTime.getLayoutParams();
        lp.setMarginEnd(enable ? vh.mTotalTimeMarginEnd : 0);
        vh.mTotalTime.setLayoutParams(lp);
    
private static voidformatTime(int seconds, java.lang.StringBuilder sb)

        int minutes = seconds / 60;
        int hours = minutes / 60;
        seconds -= minutes * 60;
        minutes -= hours * 60;

        sb.setLength(0);
        if (hours > 0) {
            sb.append(hours).append(':");
            if (minutes < 10) {
                sb.append('0");
            }
        }
        sb.append(minutes).append(':");
        if (seconds < 10) {
            sb.append('0");
        }
        sb.append(seconds);
    
intgetChildMarginBigger(android.content.Context context)

        if (sChildMarginBigger == 0) {
            sChildMarginBigger = context.getResources().getDimensionPixelSize(
                    R.dimen.lb_playback_controls_child_margin_bigger);
        }
        return sChildMarginBigger;
    
intgetChildMarginBiggest(android.content.Context context)

        if (sChildMarginBiggest == 0) {
            sChildMarginBiggest = context.getResources().getDimensionPixelSize(
                    R.dimen.lb_playback_controls_child_margin_biggest);
        }
        return sChildMarginBiggest;
    
public intgetCurrentTime(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh)

        return vh.getCurrentTime();
    
public intgetSecondaryProgress(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh)

        return vh.getSecondaryProgress();
    
public intgetTotalTime(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh)

        return vh.getTotalTime();
    
public voidonBindViewHolder(Presenter.ViewHolder holder, java.lang.Object item)

        ViewHolder vh = (ViewHolder) holder;
        BoundData data = (BoundData) item;

        // If binding to a new adapter, display primary actions.
        if (vh.mMoreActionsAdapter != data.secondaryActionsAdapter) {
            vh.mMoreActionsAdapter = data.secondaryActionsAdapter;
            vh.mMoreActionsAdapter.registerObserver(vh.mMoreActionsObserver);
            vh.mMoreActionsShowing = false;
        }

        super.onBindViewHolder(holder, item);
        vh.showMoreActions(mMoreActionsEnabled);
    
public Presenter.ViewHolderonCreateViewHolder(android.view.ViewGroup parent)

        View v = LayoutInflater.from(parent.getContext())
            .inflate(getLayoutResourceId(), parent, false);
        return new ViewHolder(v);
    
public voidonUnbindViewHolder(Presenter.ViewHolder holder)

        super.onUnbindViewHolder(holder);
        ViewHolder vh = (ViewHolder) holder;
        vh.mMoreActionsAdapter.unregisterObserver(vh.mMoreActionsObserver);
        vh.mMoreActionsAdapter = null;
    
public voidsetCurrentTime(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh, int ms)

        vh.setCurrentTime(ms);
    
public voidsetProgressColor(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh, int color)

        Drawable drawable = new ClipDrawable(new ColorDrawable(color),
                Gravity.LEFT, ClipDrawable.HORIZONTAL);
        ((LayerDrawable) vh.mProgressBar.getProgressDrawable())
                .setDrawableByLayerId(android.R.id.progress, drawable);
    
public voidsetSecondaryProgress(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh, int progressMs)

        vh.setSecondaryProgress(progressMs);
    
public voidsetTotalTime(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh, int ms)

        vh.setTotalTime(ms);
    
public voidshowPrimaryActions(android.support.v17.leanback.widget.PlaybackControlsPresenter$ViewHolder vh)

        if (vh.mMoreActionsShowing) {
            vh.toggleMoreActions();
        }