aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/guide/ProgramGuide.java
diff options
context:
space:
mode:
authorNick Chalko <nchalko@google.com>2016-02-26 13:38:57 -0800
committerNick Chalko <nchalko@google.com>2016-02-26 13:39:22 -0800
commitba5845f23b8fbc985890f892961abc8b39886611 (patch)
treeda373b9fe1955a2c7008c2e65df5ec3f5b087454 /src/com/android/tv/guide/ProgramGuide.java
parent1abddd9f6225298066094e20a6c29061b6af4590 (diff)
downloadTV-ba5845f23b8fbc985890f892961abc8b39886611.tar.gz
Sync to ub-tv-interns at cc7c29d2a24a1343498f6d95ca5a79e003e6aefe
Change-Id: I580da190231e47c65b69f425b30ec4685eb50ce4
Diffstat (limited to 'src/com/android/tv/guide/ProgramGuide.java')
-rw-r--r--src/com/android/tv/guide/ProgramGuide.java81
1 files changed, 43 insertions, 38 deletions
diff --git a/src/com/android/tv/guide/ProgramGuide.java b/src/com/android/tv/guide/ProgramGuide.java
index d4e4a99d..77a1146b 100644
--- a/src/com/android/tv/guide/ProgramGuide.java
+++ b/src/com/android/tv/guide/ProgramGuide.java
@@ -252,32 +252,7 @@ public class ProgramGuide implements ProgramGrid.ChildFocusListener {
// It is usually called when Genre is changed.
// Reset selection of ProgramGrid
resetRowSelection();
-
- // Align EPG at vertical center, if EPG table height is less than the screen size.
- Resources res = mActivity.getResources();
- int screenHeight = mContainer.getHeight();
- int startPadding = res
- .getDimensionPixelOffset(R.dimen.program_guide_table_margin_start);
- int topPadding = res
- .getDimensionPixelOffset(R.dimen.program_guide_table_margin_top);
- int bottomPadding = res
- .getDimensionPixelOffset(R.dimen.program_guide_table_margin_bottom);
- int tableHeight =
- res.getDimensionPixelOffset(R.dimen.program_guide_table_header_row_height)
- + mDetailHeight + mRowHeight * mGrid.getAdapter().getItemCount()
- + topPadding + bottomPadding;
- if (tableHeight > screenHeight) {
- // EPG height is longer that the screen height.
- mTable.setPaddingRelative(startPadding, topPadding, 0, 0);
- LayoutParams layoutParams = mTable.getLayoutParams();
- layoutParams.height = LayoutParams.WRAP_CONTENT;
- mTable.setLayoutParams(layoutParams);
- } else {
- mTable.setPaddingRelative(startPadding, topPadding, 0, bottomPadding);
- LayoutParams layoutParams = mTable.getLayoutParams();
- layoutParams.height = tableHeight;
- mTable.setLayoutParams(layoutParams);
- }
+ updateGuidePosition();
}
});
@@ -399,6 +374,34 @@ public class ProgramGuide implements ProgramGrid.ChildFocusListener {
mShowGuidePartial = mSharedPreference.getBoolean(KEY_SHOW_GUIDE_PARTIAL, true);
}
+ private void updateGuidePosition() {
+ // Align EPG at vertical center, if EPG table height is less than the screen size.
+ Resources res = mActivity.getResources();
+ int screenHeight = mContainer.getHeight();
+ if (screenHeight <= 0) {
+ // mContainer is not initialized yet.
+ return;
+ }
+ int startPadding = res.getDimensionPixelOffset(R.dimen.program_guide_table_margin_start);
+ int topPadding = res.getDimensionPixelOffset(R.dimen.program_guide_table_margin_top);
+ int bottomPadding = res.getDimensionPixelOffset(R.dimen.program_guide_table_margin_bottom);
+ int tableHeight = res.getDimensionPixelOffset(R.dimen.program_guide_table_header_row_height)
+ + mDetailHeight + mRowHeight * mGrid.getAdapter().getItemCount() + topPadding
+ + bottomPadding;
+ if (tableHeight > screenHeight) {
+ // EPG height is longer that the screen height.
+ mTable.setPaddingRelative(startPadding, topPadding, 0, 0);
+ LayoutParams layoutParams = mTable.getLayoutParams();
+ layoutParams.height = LayoutParams.WRAP_CONTENT;
+ mTable.setLayoutParams(layoutParams);
+ } else {
+ mTable.setPaddingRelative(startPadding, topPadding, 0, bottomPadding);
+ LayoutParams layoutParams = mTable.getLayoutParams();
+ layoutParams.height = tableHeight;
+ mTable.setLayoutParams(layoutParams);
+ }
+ }
+
@Override
public void onRequestChildFocus(View oldFocus, View newFocus) {
if (oldFocus != null && newFocus != null) {
@@ -510,18 +513,19 @@ public class ProgramGuide implements ProgramGrid.ChildFocusListener {
if (DEBUG) {
mContainer.getViewTreeObserver().addOnDrawListener(
new ViewTreeObserver.OnDrawListener() {
- long time = System.currentTimeMillis();
- int count = 0;
- @Override
- public void onDraw() {
- long curtime = System.currentTimeMillis();
- Log.d(TAG, "onDraw " + count++ + " " + (curtime - time) + "ms");
- time = curtime;
- if (count > 10) {
- mContainer.getViewTreeObserver().removeOnDrawListener(this);
- }
- }
- });
+ long time = System.currentTimeMillis();
+ int count = 0;
+
+ @Override
+ public void onDraw() {
+ long curtime = System.currentTimeMillis();
+ Log.d(TAG, "onDraw " + count++ + " " + (curtime - time) + "ms");
+ time = curtime;
+ if (count > 10) {
+ mContainer.getViewTreeObserver().removeOnDrawListener(this);
+ }
+ }
+ });
}
runnableAfterAnimatorReady.run();
if (mShowGuidePartial) {
@@ -529,6 +533,7 @@ public class ProgramGuide implements ProgramGrid.ChildFocusListener {
} else {
mShowAnimatorFull.start();
}
+ updateGuidePosition();
}
};
mContainer.getViewTreeObserver().addOnGlobalLayoutListener(mOnLayoutListenerForShow);