Bug 1402145 - Use adapter child position rather than view position. r=mcomella
authorChenxia Liu <liuche@mozilla.com>
Fri, 22 Sep 2017 09:09:23 -0700
changeset 382541 722e1226aa7a1676dfa936d01ba00920ef2736c1
parent 382540 a54290a32fd6978e9f89ab4efd823e936258ba84
child 382542 2b59b2d150ce2214ce26ba0ede07674c70e17c67
push id32561
push userarchaeopteryx@coole-files.de
push dateSat, 23 Sep 2017 09:36:26 +0000
treeherdermozilla-central@8c3a15583223 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1402145
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1402145 - Use adapter child position rather than view position. r=mcomella MozReview-Commit-ID: ESi8MMYC1lp
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java
@@ -37,26 +37,28 @@ import android.view.View;
     public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
         final int left = parent.getPaddingLeft();
         final int right = parent.getWidth() - parent.getPaddingRight();
 
         final int childCount = parent.getChildCount();
         for (int i = 0; i < childCount; i++) {
             final View child = parent.getChildAt(i);
 
-            if (parent.getChildAdapterPosition(child) < START_DRAWING_AT_POSITION) {
+            final int childPosition = parent.getChildAdapterPosition(child);
+            if (childPosition == RecyclerView.NO_POSITION
+                    || childPosition < START_DRAWING_AT_POSITION) {
                 continue;
             }
 
             if (child.getVisibility() == View.GONE) {
                 continue;
             }
 
             // Do not draw dividers above section title items.
-            final int childViewType = parent.getAdapter().getItemViewType(i);
+            final int childViewType = parent.getAdapter().getItemViewType(childPosition);
             if (childViewType == StreamRecyclerAdapter.RowItemType.HIGHLIGHTS_TITLE.getViewType()
                     || childViewType == StreamRecyclerAdapter.RowItemType.TOP_STORIES_TITLE.getViewType()) {
                 continue;
             }
 
             final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                     .getLayoutParams();
             final int topOfDivider = child.getTop() + params.topMargin;