1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 00:20:32 +00:00

Formatting, renaming and small fixes

This commit is contained in:
Jared Fantaye 2022-12-09 12:01:59 +01:00
parent bf1ebf8733
commit 1ac62541a8
5 changed files with 27 additions and 28 deletions

View File

@ -15,7 +15,7 @@ public class PlaylistEntity {
public static final String PLAYLIST_ID = "uid"; public static final String PLAYLIST_ID = "uid";
public static final String PLAYLIST_NAME = "name"; public static final String PLAYLIST_NAME = "name";
public static final String PLAYLIST_THUMBNAIL_URL = "thumbnail_url"; public static final String PLAYLIST_THUMBNAIL_URL = "thumbnail_url";
public static final String PLAYLIST_THUMBNAIL_SET = "isThumbnailSet"; public static final String PLAYLIST_THUMBNAIL_PERMANENT = "isThumbnailSet";
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = PLAYLIST_ID) @ColumnInfo(name = PLAYLIST_ID)
@ -27,14 +27,14 @@ public class PlaylistEntity {
@ColumnInfo(name = PLAYLIST_THUMBNAIL_URL) @ColumnInfo(name = PLAYLIST_THUMBNAIL_URL)
private String thumbnailUrl; private String thumbnailUrl;
@ColumnInfo(name = PLAYLIST_THUMBNAIL_SET) @ColumnInfo(name = PLAYLIST_THUMBNAIL_PERMANENT)
private boolean isThumbnailSet; private boolean isThumbnailPermanent;
public PlaylistEntity(final String name, final String thumbnailUrl, public PlaylistEntity(final String name, final String thumbnailUrl,
final boolean isThumbnailSet) { final boolean isThumbnailPermanent) {
this.name = name; this.name = name;
this.thumbnailUrl = thumbnailUrl; this.thumbnailUrl = thumbnailUrl;
this.isThumbnailSet = isThumbnailSet; this.isThumbnailPermanent = isThumbnailPermanent;
} }
public long getUid() { public long getUid() {
@ -61,12 +61,12 @@ public class PlaylistEntity {
this.thumbnailUrl = thumbnailUrl; this.thumbnailUrl = thumbnailUrl;
} }
public boolean getIsThumbnailSet() { public boolean getIsThumbnailPermanent() {
return isThumbnailSet; return isThumbnailPermanent;
} }
public void setIsThumbnailSet(final boolean isThumbnailSet) { public void setIsThumbnailPermanent(final boolean isThumbnailSet) {
this.isThumbnailSet = isThumbnailSet; this.isThumbnailPermanent = isThumbnailSet;
} }
} }

View File

@ -262,12 +262,12 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
final String rename = getString(R.string.rename); final String rename = getString(R.string.rename);
final String delete = getString(R.string.delete); final String delete = getString(R.string.delete);
final String unsetThumbnail = getString(R.string.unset_playlist_thumbnail); final String unsetThumbnail = getString(R.string.unset_playlist_thumbnail);
final boolean isPlaylistThumbnailSet = localPlaylistManager final boolean isThumbnailPermanent = localPlaylistManager
.getIsPlaylistThumbnailSet(selectedItem.uid); .getIsPlaylistThumbnailPermanent(selectedItem.uid);
final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final ArrayAdapter<String> arrayAdapter = getLocalDialogArrayAdapter(isPlaylistThumbnailSet, final ArrayAdapter<String> arrayAdapter = getLocalDialogArrayAdapter(isThumbnailPermanent,
unsetThumbnail); unsetThumbnail);
arrayAdapter.addAll(rename, delete, unsetThumbnail); arrayAdapter.addAll(rename, delete, unsetThumbnail);
@ -277,11 +277,10 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
} else if (index == arrayAdapter.getPosition(delete)) { } else if (index == arrayAdapter.getPosition(delete)) {
showDeleteDialog(selectedItem.name, localPlaylistManager showDeleteDialog(selectedItem.name, localPlaylistManager
.deletePlaylist(selectedItem.uid)); .deletePlaylist(selectedItem.uid));
dialog.dismiss(); } else if (isThumbnailPermanent) {
} else if (isPlaylistThumbnailSet) { final String thumbnailUrl = localPlaylistManager
final String thumbnail_url = localPlaylistManager
.getAutomaticPlaylistThumbnail(selectedItem.uid); .getAutomaticPlaylistThumbnail(selectedItem.uid);
localPlaylistManager.changePlaylistThumbnail(selectedItem.uid, thumbnail_url, false) localPlaylistManager.changePlaylistThumbnail(selectedItem.uid, thumbnailUrl, false)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(); .subscribe();
} }
@ -294,8 +293,7 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
private ArrayAdapter<String> getLocalDialogArrayAdapter(final boolean isPlaylistThumbnailSet, private ArrayAdapter<String> getLocalDialogArrayAdapter(final boolean isPlaylistThumbnailSet,
final String unsetThumbnail) { final String unsetThumbnail) {
return new ArrayAdapter<>(getContext(), return new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1) {
android.R.layout.simple_list_item_1) {
@Override @Override
public View getView(final int position, final View convertView, public View getView(final int position, final View convertView,
final ViewGroup parent) { final ViewGroup parent) {

View File

@ -405,8 +405,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
.zipWith(historyIdsMaybe, (playlist, historyStreamIds) -> { .zipWith(historyIdsMaybe, (playlist, historyStreamIds) -> {
// Remove Watched, Functionality data // Remove Watched, Functionality data
final List<PlaylistStreamEntry> notWatchedItems = new ArrayList<>(); final List<PlaylistStreamEntry> notWatchedItems = new ArrayList<>();
final boolean isThumbnailSet = playlistManager final boolean isThumbnailPermanent = playlistManager
.getIsPlaylistThumbnailSet(playlistId); .getIsPlaylistThumbnailPermanent(playlistId);
boolean thumbnailVideoRemoved = false; boolean thumbnailVideoRemoved = false;
if (removePartiallyWatched) { if (removePartiallyWatched) {
@ -416,7 +416,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
if (indexInHistory < 0) { if (indexInHistory < 0) {
notWatchedItems.add(playlistItem); notWatchedItems.add(playlistItem);
} else if (!isThumbnailSet && !thumbnailVideoRemoved } else if (!isThumbnailPermanent && !thumbnailVideoRemoved
&& playlistManager.getPlaylistThumbnail(playlistId) && playlistManager.getPlaylistThumbnail(playlistId)
.equals(playlistItem.getStreamEntity().getThumbnailUrl())) { .equals(playlistItem.getStreamEntity().getThumbnailUrl())) {
thumbnailVideoRemoved = true; thumbnailVideoRemoved = true;
@ -437,7 +437,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
if (indexInHistory < 0 || (streamStateEntity != null if (indexInHistory < 0 || (streamStateEntity != null
&& !streamStateEntity.isFinished(duration))) { && !streamStateEntity.isFinished(duration))) {
notWatchedItems.add(playlistItem); notWatchedItems.add(playlistItem);
} else if (!isThumbnailSet && !thumbnailVideoRemoved } else if (!isThumbnailPermanent && !thumbnailVideoRemoved
&& playlistManager.getPlaylistThumbnail(playlistId) && playlistManager.getPlaylistThumbnail(playlistId)
.equals(playlistItem.getStreamEntity().getThumbnailUrl())) { .equals(playlistItem.getStreamEntity().getThumbnailUrl())) {
thumbnailVideoRemoved = true; thumbnailVideoRemoved = true;
@ -589,7 +589,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
private void changeThumbnailUrl(final String thumbnailUrl, final boolean isPermanent) { private void changeThumbnailUrl(final String thumbnailUrl, final boolean isPermanent) {
if (playlistManager == null || (!isPermanent && playlistManager if (playlistManager == null || (!isPermanent && playlistManager
.getIsPlaylistThumbnailSet(playlistId))) { .getIsPlaylistThumbnailPermanent(playlistId))) {
return; return;
} }
@ -612,11 +612,12 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
} }
private void updateThumbnailUrl() { private void updateThumbnailUrl() {
if (playlistManager.getIsPlaylistThumbnailSet(playlistId)) { if (playlistManager.getIsPlaylistThumbnailPermanent(playlistId)) {
return; return;
} }
final String newThumbnailUrl; final String newThumbnailUrl;
if (!itemListAdapter.getItemsList().isEmpty()) { if (!itemListAdapter.getItemsList().isEmpty()) {
newThumbnailUrl = ((PlaylistStreamEntry) itemListAdapter.getItemsList().get(0)) newThumbnailUrl = ((PlaylistStreamEntry) itemListAdapter.getItemsList().get(0))
.getStreamEntity().getThumbnailUrl(); .getStreamEntity().getThumbnailUrl();

View File

@ -110,8 +110,9 @@ public class LocalPlaylistManager {
return playlistTable.getPlaylist(playlistId).blockingFirst().get(0).getThumbnailUrl(); return playlistTable.getPlaylist(playlistId).blockingFirst().get(0).getThumbnailUrl();
} }
public boolean getIsPlaylistThumbnailSet(final long playlistId) { public boolean getIsPlaylistThumbnailPermanent(final long playlistId) {
return playlistTable.getPlaylist(playlistId).blockingFirst().get(0).getIsThumbnailSet(); return playlistTable.getPlaylist(playlistId).blockingFirst().get(0)
.getIsThumbnailPermanent();
} }
public String getAutomaticPlaylistThumbnail(final long playlistId) { public String getAutomaticPlaylistThumbnail(final long playlistId) {
@ -133,7 +134,7 @@ public class LocalPlaylistManager {
} }
if (thumbnailUrl != null) { if (thumbnailUrl != null) {
playlist.setThumbnailUrl(thumbnailUrl); playlist.setThumbnailUrl(thumbnailUrl);
playlist.setIsThumbnailSet(isPermanent); playlist.setIsThumbnailPermanent(isPermanent);
} }
return playlistTable.update(playlist); return playlistTable.update(playlist);
}).subscribeOn(Schedulers.io()); }).subscribeOn(Schedulers.io());

View File

@ -7,7 +7,6 @@
<string name="install">Install</string> <string name="install">Install</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="yes">Yes</string>
<string name="open_in_browser">Open in browser</string> <string name="open_in_browser">Open in browser</string>
<string name="mark_as_watched">Mark as watched</string> <string name="mark_as_watched">Mark as watched</string>
<string name="open_in_popup_mode">Open in popup mode</string> <string name="open_in_popup_mode">Open in popup mode</string>