Bug 1399042: Move NO_POSITION check for IndexOutOfBoundsException in onItemClick. r=mcomella
authorChenxia Liu <liuche@mozilla.com>
Wed, 13 Sep 2017 14:31:51 -0700
changeset 430261 c9b73b821bd5393ffc64a1cc81085095a696ecb0
parent 430260 72a9bca22654ea28ba17a50d9dd9d078e14fa309
child 430262 cfd5924a10e353e60b2dc93837954b446e3d422e
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1399042
milestone57.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 1399042: Move NO_POSITION check for IndexOutOfBoundsException in onItemClick. r=mcomella MozReview-Commit-ID: GAs6HOwp8ru
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
@@ -235,38 +235,38 @@ public class StreamRecyclerAdapter exten
         }
 
         final WebpageItemRow highlightItem = (WebpageItemRow) recyclerView.getChildViewHolder(v);
         openContextMenu(highlightItem, position, ActivityStreamTelemetry.Contract.INTERACTION_LONG_CLICK);
         return true;
     }
 
     private boolean onItemClickIsValidRowItem(final int position) {
-        final int viewType = getItemViewType(position);
-        if (viewType != RowItemType.HIGHLIGHT_ITEM.getViewType()
-                && viewType != RowItemType.TOP_STORIES_ITEM.getViewType()) {
-            // Headers (containing topsites and/or the highlights title) do their own click handling as needed
-            return false;
-        }
-
         // The position this method receives is from RecyclerView.ViewHolder.getAdapterPosition, whose docs state:
         // "Note that if you've called notifyDataSetChanged(), until the next layout pass, the return value of this
         // method will be NO_POSITION."
         //
         // At the time of writing, we call notifyDataSetChanged for:
         // - swapHighlights (can't do anything about this)
         // - setTileSize (in theory, we might be able to do something hacky to get the existing highlights list)
         //
         // Given the low crash rate (34 crashes in 23 days), I don't think it's worth investigating further
         // or adding a hack.
         if (position == RecyclerView.NO_POSITION) {
             Log.w(LOGTAG, "onItemClicked: received NO_POSITION. Returning");
             return false;
         }
 
+        final int viewType = getItemViewType(position);
+        if (viewType != RowItemType.HIGHLIGHT_ITEM.getViewType()
+                && viewType != RowItemType.TOP_STORIES_ITEM.getViewType()) {
+            // Headers (containing topsites and/or the highlights title) do their own click handling as needed
+            return false;
+        }
+
         return true;
     }
 
     @Override
     public void openContextMenu(final WebpageItemRow webpageItemRow, final int position, @NonNull final String interactionExtra) {
         final WebpageRowModel model = (WebpageRowModel) recyclerViewModel.get(position);
 
         final String sourceType;