From c24aed054f9da7dcde634faf570f0314d44f6a87 Mon Sep 17 00:00:00 2001 From: GGAutomaton <32899400+GGAutomaton@users.noreply.github.com> Date: Sat, 16 Apr 2022 12:00:02 +0800 Subject: [PATCH] Fix sonar warning and typo --- .../schabi/newpipe/database/Migrations.java | 16 ++--- .../newpipe/local/LocalItemListAdapter.java | 15 +++-- .../local/bookmark/BookmarkFragment.java | 64 +++++++++---------- .../LocalBookmarkPlaylistItemHolder.java | 11 +--- .../local/holder/LocalPlaylistItemHolder.java | 3 +- .../RemoteBookmarkPlaylistItemHolder.java | 19 +----- .../holder/RemotePlaylistItemHolder.java | 3 +- 7 files changed, 53 insertions(+), 78 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/Migrations.java b/app/src/main/java/org/schabi/newpipe/database/Migrations.java index ffca6cca5..1013899ca 100644 --- a/app/src/main/java/org/schabi/newpipe/database/Migrations.java +++ b/app/src/main/java/org/schabi/newpipe/database/Migrations.java @@ -195,8 +195,8 @@ public final class Migrations { try { database.beginTransaction(); - // update playlists - // create a temp table to initialize display_index + // Update playlists. + // Create a temp table to initialize display_index. database.execSQL("CREATE TABLE `playlists_tmp` " + "(`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + "`name` TEXT, `thumbnail_url` TEXT," @@ -204,16 +204,16 @@ public final class Migrations { database.execSQL("INSERT INTO `playlists_tmp` (`uid`, `name`, `thumbnail_url`)" + "SELECT `uid`, `name`, `thumbnail_url` FROM `playlists`"); - // replace the old table + // Replace the old table. database.execSQL("DROP TABLE `playlists`"); database.execSQL("ALTER TABLE `playlists_tmp` RENAME TO `playlists`"); - // create index on the new table + // Create index on the new table. database.execSQL("CREATE INDEX `index_playlists_name` ON `playlists` (`name`)"); - // update remote_playlists - // create a temp table to initialize display_index + // Update remote_playlists. + // Create a temp table to initialize display_index. database.execSQL("CREATE TABLE `remote_playlists_tmp` " + "(`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + "`service_id` INTEGER NOT NULL, `name` TEXT, `url` TEXT, " @@ -225,11 +225,11 @@ public final class Migrations { + "SELECT `uid`, `service_id`, `name`, `url`, `thumbnail_url`, `uploader`, " + "`stream_count` FROM `remote_playlists`"); - // replace the old table + // Replace the old table. database.execSQL("DROP TABLE `remote_playlists`"); database.execSQL("ALTER TABLE `remote_playlists_tmp` RENAME TO `remote_playlists`"); - // create index on the new table + // Create index on the new table. database.execSQL("CREATE INDEX `index_remote_playlists_name` " + "ON `remote_playlists` (`name`)"); database.execSQL("CREATE UNIQUE INDEX `index_remote_playlists_service_id_url` " diff --git a/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java b/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java index 161d35ee5..5c22cee24 100644 --- a/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java @@ -256,12 +256,17 @@ public class LocalItemListAdapter extends RecyclerView.Adapter, Void> { - // Save the list 10s after the last change occurred + // Save the list 10 seconds after the last change occurred private static final long SAVE_DEBOUNCE_MILLIS = 10000; private static final int MINIMUM_INITIAL_DRAG_VELOCITY = 12; @State @@ -281,6 +281,7 @@ public final class BookmarkFragment extends BaseLocalListFragment disposables.add(remotePlaylistManager.updatePlaylists( remoteItemsUpdate, remoteItemsDeleteUid) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(() -> { - if (isModified != null) { - isModified.set(false); - } - }, - throwable -> showError(new ErrorInfo(throwable, - UserAction.REQUESTED_BOOKMARK, - "Saving playlist")) - )), + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(() -> { + if (isModified != null) { + isModified.set(false); + } + }, + throwable -> showError(new ErrorInfo(throwable, + UserAction.REQUESTED_BOOKMARK, + "Saving playlist")) + )), throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_BOOKMARK, "Saving playlist")) )); @@ -529,22 +527,21 @@ public final class BookmarkFragment extends BaseLocalListFragment