Added the duplicate indicator explanation & removed some unnecessary functions

This commit is contained in:
Jared Fantaye 2023-01-27 15:37:33 +01:00
parent ef4a6238c8
commit c70ce791db
2 changed files with 12 additions and 12 deletions

View File

@ -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

View File

@ -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,