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

AbstractDetailsDescriptionPresenter

public abstract class AbstractDetailsDescriptionPresenter extends Presenter
An abstract {@link Presenter} for rendering a detailed description of an item. Typically this Presenter will be used in a DetailsOveriewRowPresenter.

Subclasses will override {@link #onBindDescription} to implement the data binding for this Presenter.

Fields Summary
Constructors Summary
Methods Summary
protected abstract voidonBindDescription(android.support.v17.leanback.widget.AbstractDetailsDescriptionPresenter$ViewHolder vh, java.lang.Object item)
Binds the data from the item referenced in the DetailsOverviewRow to the ViewHolder.

param
vh The ViewHolder for this details description view.
param
item The item from the DetailsOverviewRow being presented.

public final voidonBindViewHolder(Presenter.ViewHolder viewHolder, java.lang.Object item)

        ViewHolder vh = (ViewHolder) viewHolder;
        onBindDescription(vh, item);

        boolean hasTitle = true;
        if (TextUtils.isEmpty(vh.mTitle.getText())) {
            vh.mTitle.setVisibility(View.GONE);
            hasTitle = false;
        } else {
            vh.mTitle.setVisibility(View.VISIBLE);
            vh.mTitle.setLineSpacing(vh.mTitleLineSpacing - vh.mTitle.getLineHeight() +
                    vh.mTitle.getLineSpacingExtra(), vh.mTitle.getLineSpacingMultiplier());
        }
        setTopMargin(vh.mTitle, vh.mTitleMargin);

        boolean hasSubtitle = true;
        if (TextUtils.isEmpty(vh.mSubtitle.getText())) {
            vh.mSubtitle.setVisibility(View.GONE);
            hasSubtitle = false;
        } else {
            vh.mSubtitle.setVisibility(View.VISIBLE);
            if (hasTitle) {
                setTopMargin(vh.mSubtitle, vh.mUnderTitleBaselineMargin +
                        vh.mSubtitleFontMetricsInt.ascent - vh.mTitleFontMetricsInt.descent);
            } else {
                setTopMargin(vh.mSubtitle, 0);
            }
        }

        if (TextUtils.isEmpty(vh.mBody.getText())) {
            vh.mBody.setVisibility(View.GONE);
        } else {
            vh.mBody.setVisibility(View.VISIBLE);
            vh.mBody.setLineSpacing(vh.mBodyLineSpacing - vh.mBody.getLineHeight() +
                    vh.mBody.getLineSpacingExtra(), vh.mBody.getLineSpacingMultiplier());

            if (hasSubtitle) {
                setTopMargin(vh.mBody, vh.mUnderSubtitleBaselineMargin +
                        vh.mBodyFontMetricsInt.ascent - vh.mSubtitleFontMetricsInt.descent);
            } else if (hasTitle) {
                setTopMargin(vh.mBody, vh.mUnderTitleBaselineMargin +
                        vh.mBodyFontMetricsInt.ascent - vh.mTitleFontMetricsInt.descent);
            } else {
                setTopMargin(vh.mBody, 0);
            }
        }
    
public final android.support.v17.leanback.widget.AbstractDetailsDescriptionPresenter$ViewHolderonCreateViewHolder(android.view.ViewGroup parent)

        View v = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.lb_details_description, parent, false);
        return new ViewHolder(v);
    
public voidonUnbindViewHolder(Presenter.ViewHolder viewHolder)

private voidsetTopMargin(android.widget.TextView textView, int topMargin)

        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) textView.getLayoutParams();
        lp.topMargin = topMargin;
        textView.setLayoutParams(lp);