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_NAME = "name";
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)
@ColumnInfo(name = PLAYLIST_ID)
@ -27,14 +27,14 @@ public class PlaylistEntity {
@ColumnInfo(name = PLAYLIST_THUMBNAIL_URL)
private String thumbnailUrl;
@ColumnInfo(name = PLAYLIST_THUMBNAIL_SET)
private boolean isThumbnailSet;
@ColumnInfo(name = PLAYLIST_THUMBNAIL_PERMANENT)
private boolean isThumbnailPermanent;
public PlaylistEntity(final String name, final String thumbnailUrl,
final boolean isThumbnailSet) {
final boolean isThumbnailPermanent) {
this.name = name;
this.thumbnailUrl = thumbnailUrl;
this.isThumbnailSet = isThumbnailSet;
this.isThumbnailPermanent = isThumbnailPermanent;
}
public long getUid() {
@ -61,12 +61,12 @@ public class PlaylistEntity {
this.thumbnailUrl = thumbnailUrl;
}
public boolean getIsThumbnailSet() {
return isThumbnailSet;
public boolean getIsThumbnailPermanent() {
return isThumbnailPermanent;
}
public void setIsThumbnailSet(final boolean isThumbnailSet) {
this.isThumbnailSet = isThumbnailSet;
public void setIsThumbnailPermanent(final boolean 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 delete = getString(R.string.delete);
final String unsetThumbnail = getString(R.string.unset_playlist_thumbnail);
final boolean isPlaylistThumbnailSet = localPlaylistManager
.getIsPlaylistThumbnailSet(selectedItem.uid);
final boolean isThumbnailPermanent = localPlaylistManager
.getIsPlaylistThumbnailPermanent(selectedItem.uid);
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final ArrayAdapter<String> arrayAdapter = getLocalDialogArrayAdapter(isPlaylistThumbnailSet,
final ArrayAdapter<String> arrayAdapter = getLocalDialogArrayAdapter(isThumbnailPermanent,
unsetThumbnail);
arrayAdapter.addAll(rename, delete, unsetThumbnail);
@ -277,11 +277,10 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
} else if (index == arrayAdapter.getPosition(delete)) {
showDeleteDialog(selectedItem.name, localPlaylistManager
.deletePlaylist(selectedItem.uid));
dialog.dismiss();
} else if (isPlaylistThumbnailSet) {
final String thumbnail_url = localPlaylistManager
} else if (isThumbnailPermanent) {
final String thumbnailUrl = localPlaylistManager
.getAutomaticPlaylistThumbnail(selectedItem.uid);
localPlaylistManager.changePlaylistThumbnail(selectedItem.uid, thumbnail_url, false)
localPlaylistManager.changePlaylistThumbnail(selectedItem.uid, thumbnailUrl, false)
.observeOn(AndroidSchedulers.mainThread())
.subscribe();
}
@ -294,8 +293,7 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
private ArrayAdapter<String> getLocalDialogArrayAdapter(final boolean isPlaylistThumbnailSet,
final String unsetThumbnail) {
return new ArrayAdapter<>(getContext(),
android.R.layout.simple_list_item_1) {
return new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1) {
@Override
public View getView(final int position, final View convertView,
final ViewGroup parent) {

View File

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

View File

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

View File

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