diff options
author | Ridhim Rastogi <ridhim.rastogi@ittiam.com> | 2019-06-03 11:17:19 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2019-06-03 14:45:09 -0700 |
commit | 64814d0026e1a5e065817fe65ce34a1440e690fa (patch) | |
tree | 290539f9f4f50660e8e62b03c97f8afac717c7ae /src | |
parent | 6878c2db9565b59c7297d4705c752638c6f7905a (diff) | |
download | TV-64814d0026e1a5e065817fe65ce34a1440e690fa.tar.gz |
Fix EPG scroll behavior for overlapping layouts
GridLayout scrollToPosition stays on same layout if layout of requested item overlaps with the first item of current layout.
smoothScrollToPosition will invalidate the layouts and scroll to the requested position.
Live Channels: Import of http://pa/1358263
Bug: 129466363
Change-Id: I6b964e547217b7589e3bd15980a308b0aacdde6b
PiperOrigin-RevId: 251271392
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/tv/guide/ProgramGrid.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/tv/guide/ProgramGrid.java b/src/com/android/tv/guide/ProgramGrid.java index d0e050b2..96e161cd 100644 --- a/src/com/android/tv/guide/ProgramGrid.java +++ b/src/com/android/tv/guide/ProgramGrid.java @@ -256,8 +256,19 @@ public class ProgramGrid extends VerticalGridView { scrollToPosition(getAdapter().getItemCount() - 1); return null; } else if (getSelectedPosition() == getAdapter().getItemCount() - 1) { - scrollToPosition(0); - return null; + int itemCount = getLayoutManager().getItemCount(); + int childCount = getChildCount(); + // b/129466363 For an item which overalps with previous layout GridLayoutManager + // will scroll to first child of current layout, instead of going to previous one. + // smoothscrollToPosition will invalidate all layouts and scroll to position 0. + // This condition checks for an item which overlaps with the first layout + if (itemCount > 2 * (childCount + 1) || itemCount <= childCount) { + scrollToPosition(0); + return null; + } else { + smoothScrollToPosition(0); + return getChildAt(0); + } } return focused; } |