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

RowHeaderPresenter

public class RowHeaderPresenter extends Presenter
RowHeaderPresenter provides a default implementation for header using TextView. If subclass override and creates its own view, subclass must also override {@link #onSelectLevelChanged(ViewHolder)}.

Fields Summary
private final int
mLayoutResourceId
private final android.graphics.Paint
mFontMeasurePaint
Constructors Summary
public RowHeaderPresenter()


      
        this(R.layout.lb_row_header);
    
public RowHeaderPresenter(int layoutResourceId)

hide

        mLayoutResourceId = layoutResourceId;
    
Methods Summary
protected static floatgetFontDescent(android.widget.TextView textView, android.graphics.Paint fontMeasurePaint)

        if (fontMeasurePaint.getTextSize() != textView.getTextSize()) {
            fontMeasurePaint.setTextSize(textView.getTextSize());
        }
        if (fontMeasurePaint.getTypeface() != textView.getTypeface()) {
            fontMeasurePaint.setTypeface(textView.getTypeface());
        }
        return fontMeasurePaint.descent();
    
public intgetSpaceUnderBaseline(android.support.v17.leanback.widget.RowHeaderPresenter$ViewHolder holder)
Returns the space (distance in pixels) below the baseline of the text view, if one exists; otherwise, returns 0.

        int space = holder.view.getPaddingBottom();
        if (holder.view instanceof TextView) {
            space += (int) getFontDescent((TextView) holder.view, mFontMeasurePaint);
        }
        return space;
    
public voidonBindViewHolder(Presenter.ViewHolder viewHolder, java.lang.Object item)

        setSelectLevel((ViewHolder) viewHolder, 0);
        Row rowItem = (Row) item;
        if (rowItem != null) {
            HeaderItem headerItem = rowItem.getHeaderItem();
            if (headerItem != null) {
                String text = headerItem.getName();
                ((RowHeaderView) viewHolder.view).setText(text);
            }
        }
    
public Presenter.ViewHolderonCreateViewHolder(android.view.ViewGroup parent)

        RowHeaderView headerView = (RowHeaderView) LayoutInflater.from(parent.getContext())
                .inflate(mLayoutResourceId, parent, false);

        ViewHolder viewHolder = new ViewHolder(headerView);
        viewHolder.mOriginalTextColor = headerView.getCurrentTextColor();
        viewHolder.mUnselectAlpha = parent.getResources().getFraction(
                R.fraction.lb_browse_header_unselect_alpha, 1, 1);
        return viewHolder;
    
protected voidonSelectLevelChanged(android.support.v17.leanback.widget.RowHeaderPresenter$ViewHolder holder)

        holder.view.setAlpha(holder.mUnselectAlpha + holder.mSelectLevel *
                (1f - holder.mUnselectAlpha));
    
public voidonUnbindViewHolder(Presenter.ViewHolder viewHolder)

    
public final voidsetSelectLevel(android.support.v17.leanback.widget.RowHeaderPresenter$ViewHolder holder, float selectLevel)

        holder.mSelectLevel = selectLevel;
        onSelectLevelChanged(holder);