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

ControlBarPresenter

public class ControlBarPresenter extends Presenter
A presenter that assumes a LinearLayout container for a series of control buttons backed by objects of type {@link Action}. Different layouts may be passed to the presenter constructor. The layout must contain a view with id control_bar.

Fields Summary
private static final int
MAX_CONTROLS
private OnControlClickedListener
mOnControlClickedListener
private OnControlSelectedListener
mOnControlSelectedListener
private int
mLayoutResourceId
private static int
sChildMarginDefault
private static int
sControlIconWidth
Constructors Summary
public ControlBarPresenter(int layoutResourceId)
Constructor for a ControlBarPresenter.

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

        mLayoutResourceId = layoutResourceId;
    
Methods Summary
intgetChildMarginDefault(android.content.Context context)

        if (sChildMarginDefault == 0) {
            sChildMarginDefault = context.getResources().getDimensionPixelSize(
                    R.dimen.lb_playback_controls_child_margin_default);
        }
        return sChildMarginDefault;
    
intgetControlIconWidth(android.content.Context context)

        if (sControlIconWidth == 0) {
            sControlIconWidth = context.getResources().getDimensionPixelSize(
                    R.dimen.lb_control_icon_width);
        }
        return sControlIconWidth;
    
public intgetLayoutResourceId()
Returns the layout resource id.

        return mLayoutResourceId;
    
public android.support.v17.leanback.widget.ControlBarPresenter$OnControlSelectedListenergetOnItemControlListener()
Returns the listener for control selection.

        return mOnControlSelectedListener;
    
public android.support.v17.leanback.widget.ControlBarPresenter$OnControlClickedListenergetOnItemViewClickedListener()
Returns the listener for control clicked events.

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

        ViewHolder vh = (ViewHolder) holder;
        BoundData data = (BoundData) item;
        if (vh.mAdapter != data.adapter) {
            vh.mAdapter = data.adapter;
            if (vh.mAdapter != null) {
                vh.mAdapter.registerObserver(vh.mDataObserver);
            }
        }
        vh.mPresenter = data.presenter;
        vh.mData = data;
        vh.showControls(vh.mPresenter);
    
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)

        ViewHolder vh = (ViewHolder) holder;
        if (vh.mAdapter != null) {
            vh.mAdapter.unregisterObserver(vh.mDataObserver);
            vh.mAdapter = null;
        }
        vh.mData = null;
    
public voidsetOnControlClickedListener(android.support.v17.leanback.widget.ControlBarPresenter$OnControlClickedListener listener)
Sets the listener for control clicked events.

        mOnControlClickedListener = listener;
    
public voidsetOnControlSelectedListener(android.support.v17.leanback.widget.ControlBarPresenter$OnControlSelectedListener listener)
Sets the listener for control selection.

        mOnControlSelectedListener = listener;