Bug 908423 - Account for parent folder row when creating bookmark list context menu. r=sriram
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 27 Aug 2013 08:44:58 -0700
changeset 144484 ed5ffec871a60133bea3bd4c70f4272158a8e75e
parent 144483 35112ff85c605d737e9d7bae694412a9a64ea7d0
child 144485 b8217f322b54b73828cf3ab92304f9745f050a47
push id2383
push usermleibovic@mozilla.com
push dateTue, 27 Aug 2013 15:45:21 +0000
treeherderfx-team@ed5ffec871a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs908423
milestone26.0a1
Bug 908423 - Account for parent folder row when creating bookmark list context menu. r=sriram
mobile/android/base/home/BookmarksListView.java
--- a/mobile/android/base/home/BookmarksListView.java
+++ b/mobile/android/base/home/BookmarksListView.java
@@ -142,16 +142,28 @@ public class BookmarksListView extends H
             // Otherwise, just open the URL
             final String url = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.URL));
 
             // This item is a TwoLinePageRow, so we allow switch-to-tab.
             getOnUrlOpenListener().onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.ALLOW_SWITCH_TO_TAB));
         }
     }
 
+    @Override
+    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+        // Adjust the item position to account for the parent folder row that is inserted
+        // at the top of the list when viewing the contents of a folder.
+        final BookmarksListAdapter adapter = getBookmarksListAdapter();
+        if (adapter.isShowingChildFolder()) {
+            position--;
+        }
+
+        return super.onItemLongClick(parent, view, position, id);
+    }
+
     private BookmarksListAdapter getBookmarksListAdapter() {
         BookmarksListAdapter adapter;
         ListAdapter listAdapter = getAdapter();
         if (listAdapter instanceof HeaderViewListAdapter) {
             adapter = (BookmarksListAdapter) ((HeaderViewListAdapter) listAdapter).getWrappedAdapter();
         } else {
             adapter = (BookmarksListAdapter) listAdapter;
         }