leanback/src/main/java/androidx/leanback/widget/DetailsOverviewLogoPresenter.java
@Override
    public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
        DetailsOverviewRow row = (DetailsOverviewRow) item;
        ImageView imageView = ((ImageView) viewHolder.view);
        imageView.setImageDrawable(row.getImageDrawable());
        if (isBoundToImage((ViewHolder) viewHolder, row)) {
            ViewHolder vh = (ViewHolder) viewHolder;
            if (vh.isSizeFromDrawableIntrinsic()) {
                ViewGroup.LayoutParams lp = imageView.getLayoutParams();
                lp.width = row.getImageDrawable().getIntrinsicWidth();
                lp.height = row.getImageDrawable().getIntrinsicHeight();
                if (imageView.getMaxWidth() > 0 || imageView.getMaxHeight() > 0) {
                    float maxScaleWidth = 1f;
                    if (imageView.getMaxWidth() > 0) {
                        if (lp.width > imageView.getMaxWidth()) {
                            maxScaleWidth = imageView.getMaxWidth() / (float) lp.width;
                        }
                    }
                    float maxScaleHeight = 1f;
                    if (imageView.getMaxHeight() > 0) {
                        if (lp.height > imageView.getMaxHeight()) {
                            maxScaleHeight = imageView.getMaxHeight() / (float) lp.height;
                        }
                    }
                    float scale = Math.min(maxScaleWidth, maxScaleHeight);
                    lp.width = (int) (lp.width * scale);
                    lp.height = (int) (lp.height * scale);
                }
                imageView.setLayoutParams(lp);
            }
            vh.mParentPresenter.notifyOnBindLogo(vh.mParentViewHolder);
        }
    }
/**
     * Bind logo View to drawable of DetailsOverviewRow and call notifyOnBindLogo().  The
     * default implementation assumes the Logo View is an ImageView and change layout size to
     * intrinsic size of ImageDrawable if {@link ViewHolder#isSizeFromDrawableIntrinsic()} is true.
     * @param viewHolder ViewHolder to bind.
     * @param item DetailsOverviewRow object to bind.
     */
Bind logo View to drawable of DetailsOverviewRow and call notifyOnBindLogo().  The
default implementation assumes the Logo View is an ImageView and change layout size to
intrinsic size of ImageDrawable if  ViewHolder#isSizeFromDrawableIntrinsic() is true.
@param viewHolder ViewHolder to bind.
@param item DetailsOverviewRow object to bind.
Bind logo View to drawable of DetailsOverviewRow and call notifyOnBindLogo () . The default implementation assumes the Logo View is an ImageView and change layout size to intrinsic size of ImageDrawable if ViewHolder#isSizeFromDrawableIntrinsic () is true . @param viewHolder ViewHolder to bind . @param item DetailsOverviewRow object to bind .
@Override
    public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
        DetailsOverviewRow row = (DetailsOverviewRow) item;
        ImageView imageView = ((ImageView) viewHolder.view);
        imageView.setImageDrawable(row.getImageDrawable());
        if (isBoundToImage((ViewHolder) viewHolder, row)) {
            ViewHolder vh = (ViewHolder) viewHolder;
            if (vh.isSizeFromDrawableIntrinsic()) {
                ViewGroup.LayoutParams lp = imageView.getLayoutParams();
                lp.width = row.getImageDrawable().getIntrinsicWidth();
                lp.height = row.getImageDrawable().getIntrinsicHeight();
                if (imageView.getMaxWidth() > 0 || imageView.getMaxHeight() > 0) {
                    float maxScaleWidth = 1f;
                    if (imageView.getMaxWidth() > 0) {
                        if (lp.width > imageView.getMaxWidth()) {
                            maxScaleWidth = imageView.getMaxWidth() / (float) lp.width;
                        }
                    }
                    float maxScaleHeight = 1f;
                    if (imageView.getMaxHeight() > 0) {
                        if (lp.height > imageView.getMaxHeight()) {
                            maxScaleHeight = imageView.getMaxHeight() / (float) lp.height;
                        }
                    }
                    float scale = Math.min(maxScaleWidth, maxScaleHeight);
                    lp.width = (int) (lp.width * scale);
                    lp.height = (int) (lp.height * scale);
                }
                imageView.setLayoutParams(lp);
            }
            vh.mParentPresenter.notifyOnBindLogo(vh.mParentViewHolder);
        }
    }
@ Override public void onBindViewHolder ( Presenter . ViewHolder viewHolder , Object item ) { DetailsOverviewRow row = ( DetailsOverviewRow ) item ; ImageView imageView = ( ( ImageView ) viewHolder . view ) ; imageView . setImageDrawable ( row . getImageDrawable ( ) ) ; if ( isBoundToImage ( ( ViewHolder ) viewHolder , row ) ) { ViewHolder vh = ( ViewHolder ) viewHolder ; if ( vh . isSizeFromDrawableIntrinsic ( ) ) { ViewGroup . LayoutParams lp = imageView . getLayoutParams ( ) ; lp . width = row . getImageDrawable ( ) . getIntrinsicWidth ( ) ; lp . height = row . getImageDrawable ( ) . getIntrinsicHeight ( ) ; if ( imageView . getMaxWidth ( ) > 0 || imageView . getMaxHeight ( ) > 0 ) { float maxScaleWidth = 1f ; if ( imageView . getMaxWidth ( ) > 0 ) { if ( lp . width > imageView . getMaxWidth ( ) ) { maxScaleWidth = imageView . getMaxWidth ( ) / ( float ) lp . width ; } } float maxScaleHeight = 1f ; if ( imageView . getMaxHeight ( ) > 0 ) { if ( lp . height > imageView . getMaxHeight ( ) ) { maxScaleHeight = imageView . getMaxHeight ( ) / ( float ) lp . height ; } } float scale = Math . min ( maxScaleWidth , maxScaleHeight ) ; lp . width = ( int ) ( lp . width * scale ) ; lp . height = ( int ) ( lp . height * scale ) ; } imageView . setLayoutParams ( lp ) ; } vh . mParentPresenter . notifyOnBindLogo ( vh . mParentViewHolder ) ; } }
Bind logo View to drawable of DetailsOverviewRow and call notifyOnBindLogo().
Bind logo View to drawable of DetailsOverviewRow and call notifyOnBindLogo () .