Added the duplicate indicator explanation & removed some unnecessary functions

pull/9538/head
Jared Fantaye 2023-01-27 15:37:33 +01:00
rodzic ef4a6238c8
commit c70ce791db
2 zmienionych plików z 12 dodań i 12 usunięć

Wyświetl plik

@ -11,7 +11,6 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
import org.schabi.newpipe.database.stream.model.StreamStateEntity;
import org.schabi.newpipe.local.history.HistoryRecordManager;
import org.schabi.newpipe.local.holder.LocalItemHolder;
@ -345,16 +344,6 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
}
}
@Override
public long getItemId(final int position) {
final LocalItem item = localItems.get(position);
if (item != null && item.getLocalItemType() == LocalItem.LocalItemType.
PLAYLIST_LOCAL_ITEM) {
return ((PlaylistMetadataEntry) item).uid;
}
return super.getItemId(position);
}
public GridLayoutManager.SpanSizeLookup getSpanSizeLookup(final int spanCount) {
return new GridLayoutManager.SpanSizeLookup() {
@Override

Wyświetl plik

@ -61,7 +61,6 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
new LocalPlaylistManager(NewPipeDatabase.getInstance(requireContext()));
playlistAdapter = new LocalItemListAdapter(getActivity());
playlistAdapter.setHasStableIds(true);
playlistAdapter.setSelectedListener(selectedItem -> {
final List<StreamEntity> entities = getStreamEntities();
if (selectedItem instanceof PlaylistDuplicatesEntry && entities != null) {
@ -125,8 +124,20 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
playlistAdapter.clearStreamItemList();
playlistAdapter.addItems(playlists);
playlistRecyclerView.setVisibility(View.VISIBLE);
setDuplicateIndicatorExplanation(playlists);
}
}
private void setDuplicateIndicatorExplanation(final List<PlaylistDuplicatesEntry> playlists) {
for (final PlaylistDuplicatesEntry entry : playlists) {
if (entry.timesStreamIsContained > 0) {
final View indicatorExplanation = getView()
.findViewById(R.id.playlist_duplicate);
indicatorExplanation.setVisibility(View.VISIBLE);
return;
}
}
}
private void onPlaylistSelected(@NonNull final LocalPlaylistManager manager,
@NonNull final PlaylistDuplicatesEntry playlist,