]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/helpers/BookmarksDatabaseHelper.java
Include the number of bookmarks in sub folders in the snackbar when deleting bookmark...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / helpers / BookmarksDatabaseHelper.java
index 984402e826a077877b8117e0323d5a8e19a4b243..8fe4be9cab056f55f0c229371db53ce123f3b140 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -334,12 +334,14 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper {
 
         // Extract the array of IDs not to get to the string builder.
         for (long databaseIdLong : exceptIdLongArray) {
-            if (idsNotToGetStringBuilder.length() == 0) {  // This is the first number, so only add the number.
-                idsNotToGetStringBuilder.append(databaseIdLong);
-            } else {  // This is not the first number, so place a `,` before the new number.
+            // Check to see if there is already a number in the builder.
+            if (idsNotToGetStringBuilder.length() > 0) {
+                // This is not the first number, so place a `,` before the new number.
                 idsNotToGetStringBuilder.append(",");
-                idsNotToGetStringBuilder.append(databaseIdLong);
             }
+
+            // Add the new number to the builder.
+            idsNotToGetStringBuilder.append(databaseIdLong);
         }
 
         // Prepare the SQL statement to select all items except those with the specified IDs.
@@ -360,12 +362,14 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper {
 
         // Extract the array of IDs not to get to the string builder.
         for (long databaseIdLong : exceptIdLongArray) {
-            if (idsNotToGetStringBuilder.length() == 0) {  // This is the first number, so only add the number.
-                idsNotToGetStringBuilder.append(databaseIdLong);
-            } else {  // This is not the first number, so place a `,` before the new number.
+            // Check to see if there is already a number in the builder.
+            if (idsNotToGetStringBuilder.length() > 0) {
+                // This is not the first number, so place a `,` before the new number.
                 idsNotToGetStringBuilder.append(",");
-                idsNotToGetStringBuilder.append(databaseIdLong);
             }
+
+            // Add the new number to the builder.
+            idsNotToGetStringBuilder.append(databaseIdLong);
         }
 
         // Prepare the SQL statement to select all items except those with the specified IDs.
@@ -411,7 +415,7 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper {
     }
 
     // Get a cursor with just database ID of bookmarks and folders in the specified folder.  This is useful for deleting folders with bookmarks that have favorite icons too large to fit in a cursor.
-    public Cursor getBookmarkIDs(String folderName) {
+    public Cursor getBookmarkIds(String folderName) {
         // Get a readable database handle.
         SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
 
@@ -436,12 +440,14 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper {
 
         // Extract the array of IDs not to get to the string builder.
         for (long databaseIdLong : exceptIdLongArray) {
-            if (idsNotToGetStringBuilder.length() == 0) {  // This is the first number, so only add the number.
-                idsNotToGetStringBuilder.append(databaseIdLong);
-            } else {  // This is not the first number, so place a `,` before the new number.
+            // Check to see if there is already a number in the builder.
+            if (idsNotToGetStringBuilder.length() > 0) {
+                // This is not the first number, so place a `,` before the new number.
                 idsNotToGetStringBuilder.append(",");
-                idsNotToGetStringBuilder.append(databaseIdLong);
             }
+
+            // Add the new number to the builder.
+            idsNotToGetStringBuilder.append(databaseIdLong);
         }
 
         // SQL escape the folder name.
@@ -466,12 +472,14 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper {
 
         // Extract the array of IDs not to get to the string builder.
         for (long databaseIdLong : exceptIdLongArray) {
-            if (idsNotToGetStringBuilder.length() == 0) {  // This is the first number, so only add the number.
-                idsNotToGetStringBuilder.append(databaseIdLong);
-            } else {  // This is not the first number, so place a `,` before the new number.
+            // Check to see if there is already a number in the builder.
+            if (idsNotToGetStringBuilder.length() > 0) {
+                // This is not the first number, so place a `,` before the new number.
                 idsNotToGetStringBuilder.append(",");
-                idsNotToGetStringBuilder.append(databaseIdLong);
             }
+
+            // Add the new number to the builder.
+            idsNotToGetStringBuilder.append(databaseIdLong);
         }
 
         // SQL escape `folderName`.