From 8de367e03f1d9b1640e730e35988a292f022cbf5 Mon Sep 17 00:00:00 2001 From: decarvalhobo Date: Mon, 2 Dec 2019 22:20:43 +0100 Subject: [PATCH 1/5] fix issue: thumbnail update when element deleted + thumbnail update when element added and no thumbnail --- .../local/dialog/PlaylistAppendDialog.java | 16 +++++++++++++--- .../local/playlist/LocalPlaylistFragment.java | 14 ++++++++++++++ .../local/playlist/LocalPlaylistManager.java | 4 ++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java index ac02b0b37..72df33576 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java @@ -152,9 +152,19 @@ public final class PlaylistAppendDialog extends PlaylistDialog { final Toast successToast = Toast.makeText(getContext(), R.string.playlist_add_stream_success, Toast.LENGTH_SHORT); - playlistDisposables.add(manager.appendToPlaylist(playlist.uid, streams) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(ignored -> successToast.show())); + if(playlist.thumbnailUrl.equals("https://i.ytimg.com/")){ //empty playlist + playlistDisposables.add(manager.createPlaylist(playlist.name, streams) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(ignored -> successToast.show())); + playlistDisposables.add(manager.deletePlaylist(playlist.uid) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(ignored -> successToast.show())); + } + else { + playlistDisposables.add(manager.appendToPlaylist(playlist.uid, streams) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(ignored -> successToast.show())); + } getDialog().dismiss(); } diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index c60cdac3f..35451d344 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -413,10 +413,24 @@ public class LocalPlaylistFragment extends BaseLocalListFragment modifyPlaylist(final long playlistId, @Nullable final String name, @Nullable final String thumbnailUrl) { From e9a4caaf0b35ec6ad3e4269dd1a6b924860c2101 Mon Sep 17 00:00:00 2001 From: De Carvalho Marcio Antonio Date: Tue, 3 Dec 2019 01:18:41 +0100 Subject: [PATCH 2/5] remove comments --- .../schabi/newpipe/local/playlist/LocalPlaylistFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index 35451d344..34278382a 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -428,7 +428,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment Date: Tue, 3 Dec 2019 01:19:48 +0100 Subject: [PATCH 3/5] remove comments --- .../org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java index 72df33576..f34e016b7 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java @@ -152,7 +152,7 @@ public final class PlaylistAppendDialog extends PlaylistDialog { final Toast successToast = Toast.makeText(getContext(), R.string.playlist_add_stream_success, Toast.LENGTH_SHORT); - if(playlist.thumbnailUrl.equals("https://i.ytimg.com/")){ //empty playlist + if(playlist.thumbnailUrl.equals("https://i.ytimg.com/")){ playlistDisposables.add(manager.createPlaylist(playlist.name, streams) .observeOn(AndroidSchedulers.mainThread()) .subscribe(ignored -> successToast.show())); From 752a76eb443c1b78a804b2c391cd5f903f8eca75 Mon Sep 17 00:00:00 2001 From: decarvalhobo Date: Wed, 4 Dec 2019 19:24:34 +0100 Subject: [PATCH 4/5] Usage of drawable instead of remote image + refactor the append to an empty playlist by just updating the thumbnail before adding the item in it. --- .../local/dialog/PlaylistAppendDialog.java | 16 ++++++---------- .../local/playlist/LocalPlaylistFragment.java | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java index f34e016b7..884fec599 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java @@ -152,20 +152,16 @@ public final class PlaylistAppendDialog extends PlaylistDialog { final Toast successToast = Toast.makeText(getContext(), R.string.playlist_add_stream_success, Toast.LENGTH_SHORT); - if(playlist.thumbnailUrl.equals("https://i.ytimg.com/")){ - playlistDisposables.add(manager.createPlaylist(playlist.name, streams) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(ignored -> successToast.show())); - playlistDisposables.add(manager.deletePlaylist(playlist.uid) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(ignored -> successToast.show())); - } - else { - playlistDisposables.add(manager.appendToPlaylist(playlist.uid, streams) + if(playlist.thumbnailUrl.equals("drawable://" + R.drawable.dummy_thumbnail_playlist)){ + playlistDisposables.add(manager.changePlaylistThumbnail(playlist.uid,streams.get(0).getThumbnailUrl()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(ignored -> successToast.show())); } + playlistDisposables.add(manager.appendToPlaylist(playlist.uid, streams) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(ignored -> successToast.show())); + getDialog().dismiss(); } } diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index 34278382a..af9ef0037 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -419,7 +419,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment Date: Tue, 7 Jan 2020 22:48:35 +0100 Subject: [PATCH 5/5] Fix code style and improve imports --- .../local/dialog/PlaylistAppendDialog.java | 13 ++++++------ .../local/playlist/LocalPlaylistFragment.java | 20 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java index 884fec599..81058eee6 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java @@ -1,15 +1,16 @@ package org.schabi.newpipe.local.dialog; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + import org.schabi.newpipe.NewPipeDatabase; import org.schabi.newpipe.R; import org.schabi.newpipe.database.LocalItem; @@ -152,8 +153,8 @@ public final class PlaylistAppendDialog extends PlaylistDialog { final Toast successToast = Toast.makeText(getContext(), R.string.playlist_add_stream_success, Toast.LENGTH_SHORT); - if(playlist.thumbnailUrl.equals("drawable://" + R.drawable.dummy_thumbnail_playlist)){ - playlistDisposables.add(manager.changePlaylistThumbnail(playlist.uid,streams.get(0).getThumbnailUrl()) + if (playlist.thumbnailUrl.equals("drawable://" + R.drawable.dummy_thumbnail_playlist)) { + playlistDisposables.add(manager.changePlaylistThumbnail(playlist.uid, streams.get(0).getThumbnailUrl()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(ignored -> successToast.show())); } diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index af9ef0037..9f21e05ff 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -4,11 +4,6 @@ import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.os.Parcelable; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; -import androidx.recyclerview.widget.RecyclerView; -import androidx.recyclerview.widget.ItemTouchHelper; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -18,6 +13,12 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; +import androidx.recyclerview.widget.ItemTouchHelper; +import androidx.recyclerview.widget.RecyclerView; + import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import org.schabi.newpipe.NewPipeDatabase; @@ -416,10 +417,11 @@ public class LocalPlaylistFragment extends BaseLocalListFragment