leanback: use item multiple align info when calculating scroll max

This wasn't discovered because the FullWidthDetails row was always tested
with related rows and it was never used to calculate scroll max.
If there is no row after FullWidthDetails row,  we need use the
last focusable view (the details descritpion)  to calcualte the scroll
max.

Bug 24801632

Change-Id: Ia3345fbee2c81464a1b016c74b9c6561be551e9e
diff --git a/v17/leanback/src/android/support/v17/leanback/widget/GridLayoutManager.java b/v17/leanback/src/android/support/v17/leanback/widget/GridLayoutManager.java
index 99334e6..b865a70 100644
--- a/v17/leanback/src/android/support/v17/leanback/widget/GridLayoutManager.java
+++ b/v17/leanback/src/android/support/v17/leanback/widget/GridLayoutManager.java
@@ -2022,7 +2022,7 @@
         int pos = sTwoInts[1];
         int savedMaxEdge = mWindowAlignment.mainAxis().getMaxEdge();
         mWindowAlignment.mainAxis().setMaxEdge(maxEdge);
-        int maxScroll = getPrimarySystemScrollPosition(findViewByPosition(pos));
+        int maxScroll = getPrimarySystemScrollPositionOfChildMax(findViewByPosition(pos));
         mWindowAlignment.mainAxis().setMaxEdge(savedMaxEdge);
 
         if (highAvailable) {
@@ -2373,6 +2373,16 @@
         return mWindowAlignment.mainAxis().getSystemScrollPos(viewCenterPrimary, isMin, isMax);
     }
 
+    private int getPrimarySystemScrollPositionOfChildMax(View view) {
+        int scrollPosition = getPrimarySystemScrollPosition(view);
+        final LayoutParams lp = (LayoutParams) view.getLayoutParams();
+        int[] multipleAligns = lp.getAlignMultiple();
+        if (multipleAligns != null && multipleAligns.length > 0) {
+            scrollPosition += multipleAligns[multipleAligns.length - 1] - multipleAligns[0];
+        }
+        return scrollPosition;
+    }
+
     /**
      * Get adjusted primary position for a given childView (if there is multiple ItemAlignment defined
      * on the view).