Bug 1367024: Move NO_POSITION check for IndexOutOfBoundsException in onItemClick. r?mcomella
MozReview-Commit-ID: GAs6HOwp8ru
--- 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;