]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Update the display order after deleting a bookmark. Fixes https://redmine.stoutner...
authorSoren Stoutner <soren@stoutner.com>
Fri, 22 Sep 2017 16:48:26 +0000 (09:48 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 22 Sep 2017 16:48:26 +0000 (09:48 -0700)
app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java

index 5e9d9fafe657201d25b3a9f663b82a541d389e02..efdb06a72e03e4f2c2e69dc8639f7d0e3e2aa7f1 100644 (file)
@@ -476,6 +476,20 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                                                     // Delete `databaseIdInt`.
                                                     bookmarksDatabaseHelper.deleteBookmark(databaseIdInt);
                                                 }
+
+                                                // Update the display order.
+                                                for (int i = 0; i < bookmarksListView.getCount(); i++) {
+                                                    // Get the database ID for the current bookmark.
+                                                    int currentBookmarkDatabaseId = (int) bookmarksListView.getItemIdAtPosition(i);
+
+                                                    // Move `bookmarksCursor` to the current bookmark position.
+                                                    bookmarksCursor.moveToPosition(i);
+
+                                                    // Update the display order only if it is not correct in the database.
+                                                    if (bookmarksCursor.getInt(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER)) != i) {
+                                                        bookmarksDatabaseHelper.updateBookmarkDisplayOrder(currentBookmarkDatabaseId, i);
+                                                    }
+                                                }
                                                 break;
                                         }
                                     }