Bug 1270197 - Crash when long-pressing History section header. r=sebastian a=lizzard
authorChenxia Liu <liuche@mozilla.com>
Wed, 04 May 2016 10:23:37 -0700
changeset 332855 ef3f13b55fcce0f5d2a8c1c16d3f3c5c76499058
parent 332854 8e724faf0734aabdb05020be65798a68f46ac354
child 332856 967d8df94b1b3977f2baeb830a9b645fd68d4c2f
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, lizzard
bugs1270197
milestone48.0a2
Bug 1270197 - Crash when long-pressing History section header. r=sebastian a=lizzard MozReview-Commit-ID: Fkna2jgTevD
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java
@@ -219,23 +219,24 @@ public class CombinedHistoryAdapter exte
                 return i;
             }
         }
         return sectionHeaders.size();
     }
 
     @Override
     public HomeContextMenuInfo makeContextMenuInfoFromPosition(View view, int position) {
-        if (position == 0) {
-            // No context menu for smartfolders.
-            return null;
+        final CombinedHistoryItem.ItemType itemType = getItemTypeForPosition(position);
+        if (itemType == CombinedHistoryItem.ItemType.HISTORY) {
+            final HomeContextMenuInfo info = new HomeContextMenuInfo(view, position, -1);
+
+            historyCursor.moveToPosition(transformAdapterPositionForDataStructure(CombinedHistoryItem.ItemType.HISTORY, position));
+            return populateHistoryInfoFromCursor(info, historyCursor);
         }
-        HomeContextMenuInfo info = new HomeContextMenuInfo(view, position, -1);
-        historyCursor.moveToPosition(transformAdapterPositionForDataStructure(CombinedHistoryItem.ItemType.HISTORY, position));
-        return populateHistoryInfoFromCursor(info, historyCursor);
+        return null;
     }
 
     protected static HomeContextMenuInfo populateHistoryInfoFromCursor(HomeContextMenuInfo info, Cursor cursor) {
         info.url = cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.Combined.URL));
         info.title = cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.Combined.TITLE));
         info.historyId = cursor.getInt(cursor.getColumnIndexOrThrow(BrowserContract.Combined.HISTORY_ID));
         info.itemType = HomeContextMenuInfo.RemoveItemType.HISTORY;
         final int bookmarkIdCol = cursor.getColumnIndexOrThrow(BrowserContract.Combined.BOOKMARK_ID);