Bug 1296411 - Correctly transform the adapter position to a cursor position when accessing the history cursor for getItemId. r=sebastian a=ritu
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 18 Aug 2016 22:06:38 +0200
changeset 349981 02876d17a0b794ac7c2959a763a92960463d92b0
parent 349980 4bcd5c359498042511695c565e1d4beec1447579
child 349982 c66cc1b3d2273988fc49f14ca70464302248cb6a
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, ritu
bugs1296411
milestone50.0a2
Bug 1296411 - Correctly transform the adapter position to a cursor position when accessing the history cursor for getItemId. r=sebastian a=ritu Because of the smart folders and section headers, the adapter position needs to be appropriately adjusted when trying to access the corresponding cursor item. MozReview-Commit-ID: n3FvcsYJ5T
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
@@ -210,17 +210,19 @@ public class CombinedHistoryAdapter exte
             case RECENT_TABS:
                 return RECENT_TABS_ID;
             case SYNCED_DEVICES:
                 return SYNCED_DEVICES_ID;
             case SECTION_HEADER:
                 // We might have multiple section headers, so we try get unique IDs for them.
                 return position * PRIME_SECTION_HEADERS;
             case HISTORY:
-                if (!historyCursor.moveToPosition(position)) {
+                final int historyPosition = transformAdapterPositionForDataStructure(
+                        CombinedHistoryItem.ItemType.HISTORY, position);
+                if (!historyCursor.moveToPosition(historyPosition)) {
                     return RecyclerView.NO_ID;
                 }
 
                 final int historyIdCol = historyCursor.getColumnIndexOrThrow(BrowserContract.Combined.HISTORY_ID);
                 final long historyId = historyCursor.getLong(historyIdCol);
 
                 if (historyId != -1) {
                     return historyId;