Bug 941825 - Make BookmarksListAdapter's swapCursor() idempotent. r=mfinkle, a=lsblakk
authorLucas Rocha <lucasr@mozilla.com>
Mon, 25 Nov 2013 14:02:16 -0500
changeset 166600 1e7e095cfcf4e21ac5bfdf2788d4fa48c97185d9
parent 166599 b241eaa5d3b83f6c0f30f699ba1f5be0d6acf902
child 166601 4494b9b0a0e94e346f8455838ca6f25091ca4100
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, lsblakk
bugs941825
milestone27.0a2
Bug 941825 - Make BookmarksListAdapter's swapCursor() idempotent. r=mfinkle, a=lsblakk CLOSED TREE
mobile/android/base/home/BookmarksListAdapter.java
--- a/mobile/android/base/home/BookmarksListAdapter.java
+++ b/mobile/android/base/home/BookmarksListAdapter.java
@@ -162,24 +162,33 @@ class BookmarksListAdapter extends Multi
      * Set a listener that can refresh this adapter.
      *
      * @param listener The listener that can refresh the adapter.
      */
     public void setOnRefreshFolderListener(OnRefreshFolderListener listener) {
         mListener = listener;
     }
 
+    private boolean isCurrentFolder(FolderInfo folderInfo) {
+        return (mParentStack.size() > 0 &&
+                mParentStack.peek().id == folderInfo.id);
+    }
+
     public void swapCursor(Cursor c, FolderInfo folderInfo, RefreshType refreshType) {
         switch(refreshType) {
             case PARENT:
-                mParentStack.removeFirst();
+                if (!isCurrentFolder(folderInfo)) {
+                    mParentStack.removeFirst();
+                }
                 break;
 
             case CHILD:
-                mParentStack.addFirst(folderInfo);
+                if (!isCurrentFolder(folderInfo)) {
+                    mParentStack.addFirst(folderInfo);
+                }
                 break;
 
             default:
                 // Do nothing;
         }
 
         swapCursor(c);
     }