Continued working on a way to show that items are already in a playlist
This commit is contained in:
parent
ac15339911
commit
f5a1f915be
2 changed files with 37 additions and 27 deletions
|
@ -347,7 +347,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(final int position) {
|
public long getItemId(final int position) {
|
||||||
final LocalItem item = localItems.get(0);
|
final LocalItem item = localItems.get(position);
|
||||||
if (item != null && item.getLocalItemType() == LocalItem.LocalItemType.
|
if (item != null && item.getLocalItemType() == LocalItem.LocalItemType.
|
||||||
PLAYLIST_LOCAL_ITEM) {
|
PLAYLIST_LOCAL_ITEM) {
|
||||||
return ((PlaylistMetadataEntry) item).uid;
|
return ((PlaylistMetadataEntry) item).uid;
|
||||||
|
|
|
@ -16,10 +16,10 @@ import org.schabi.newpipe.NewPipeDatabase;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
|
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity;
|
import org.schabi.newpipe.database.stream.model.StreamEntity;
|
||||||
|
import org.schabi.newpipe.fragments.OnScrollBelowItemsListener;
|
||||||
import org.schabi.newpipe.local.LocalItemListAdapter;
|
import org.schabi.newpipe.local.LocalItemListAdapter;
|
||||||
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
|
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
@ -126,34 +126,44 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
|
||||||
playlistAdapter.addItems(playlists);
|
playlistAdapter.addItems(playlists);
|
||||||
playlistRecyclerView.setVisibility(View.VISIBLE);
|
playlistRecyclerView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
final LocalPlaylistManager playlistManager =
|
playlistRecyclerView.addOnScrollListener(new DefaultItemListOnScrolledDownListener());
|
||||||
new LocalPlaylistManager(NewPipeDatabase.getInstance(requireContext()));
|
initDuplicateIndicators(playlistRecyclerView);
|
||||||
final List<Long> duplicateIds = playlistManager.getDuplicatePlaylist(getStreamEntities()
|
}
|
||||||
.get(0).getUrl()).blockingFirst();
|
}
|
||||||
|
|
||||||
final HashMap<Integer, Long> map = new HashMap<>();
|
public class DefaultItemListOnScrolledDownListener extends OnScrollBelowItemsListener {
|
||||||
for (int i = 0; i < playlists.size(); i++) {
|
@Override
|
||||||
map.put(i, playlists.get(i).uid);
|
public void onScrolledDown(final RecyclerView recyclerView) {
|
||||||
|
showDuplicateIndicators(recyclerView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initDuplicateIndicators(@NonNull final RecyclerView view) {
|
||||||
|
view.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
showDuplicateIndicators(view);
|
||||||
}
|
}
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
|
||||||
playlistRecyclerView.postDelayed(new Runnable() {
|
public void showDuplicateIndicators(final RecyclerView view) {
|
||||||
@Override
|
final LocalPlaylistManager playlistManager =
|
||||||
public void run() {
|
new LocalPlaylistManager(NewPipeDatabase.getInstance(requireContext()));
|
||||||
if (playlistRecyclerView.getAdapter() == null) {
|
final List<Long> duplicateIds = playlistManager.getDuplicatePlaylist(getStreamEntities()
|
||||||
return;
|
.get(0).getUrl()).blockingFirst();
|
||||||
}
|
|
||||||
final int count = playlistRecyclerView.getAdapter().getItemCount();
|
if (view.getAdapter() == null) {
|
||||||
System.out.println(" kasjdflkalk" + playlistRecyclerView.getAdapter()
|
return;
|
||||||
.getItemId(0));
|
}
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
if (playlistRecyclerView.findViewHolderForAdapterPosition(i) != null
|
final int count = view.getAdapter().getItemCount();
|
||||||
&& duplicateIds.contains(playlistAdapter.getItemId(i))) {
|
for (int i = 0; i < count; i++) {
|
||||||
playlistRecyclerView.findViewHolderForAdapterPosition(i).itemView
|
if (view.findViewHolderForAdapterPosition(i) != null
|
||||||
.findViewById(R.id.checkmark2).setVisibility(View.VISIBLE);
|
&& duplicateIds.contains(playlistAdapter.getItemId(i))) {
|
||||||
}
|
view.findViewHolderForAdapterPosition(i).itemView
|
||||||
}
|
.findViewById(R.id.checkmark2).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue