diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/tv/dvr/ui/browse/RecordingCardView.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/com/android/tv/dvr/ui/browse/RecordingCardView.java b/src/com/android/tv/dvr/ui/browse/RecordingCardView.java index c83ceaf0..2ffad327 100644 --- a/src/com/android/tv/dvr/ui/browse/RecordingCardView.java +++ b/src/com/android/tv/dvr/ui/browse/RecordingCardView.java @@ -24,9 +24,11 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.support.annotation.Nullable; import android.support.v17.leanback.widget.BaseCardView; +import android.text.Layout; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewTreeObserver; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ProgressBar; @@ -62,6 +64,7 @@ public class RecordingCardView extends BaseCardView { private final boolean mExpandTitleWhenFocused; private boolean mExpanded; private String mDetailBackgroundImageUri; + private Layout mTitleViewLayout; public RecordingCardView(Context context) { this(context, false); @@ -120,6 +123,14 @@ public class RecordingCardView extends BaseCardView { * value)); } }); + getViewTreeObserver().addOnGlobalLayoutListener( + new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + getViewTreeObserver().removeOnGlobalLayoutListener(this); + mTitleViewLayout = mFoldedTitleView.getLayout(); + } + }); mExpandTitleWhenFocused = expandTitleWhenFocused; } @@ -154,7 +165,8 @@ public class RecordingCardView extends BaseCardView { * @param withAnimation {@code true} to expand/fold with animation. */ public void expandTitle(boolean expand, boolean withAnimation) { - if (expand != mExpanded && mFoldedTitleView.getLayout().getEllipsisCount(0) > 0) { + if (expand != mExpanded && mTitleViewLayout != null + && mTitleViewLayout.getEllipsisCount(0) > 0) { if (withAnimation) { if (expand) { mExpandTitleAnimator.start(); |