Search in sources :

Example 1 with PlaylistMetadataEntry

use of org.schabi.newpipe.database.playlist.PlaylistMetadataEntry in project NewPipe by TeamNewPipe.

the class BookmarkFragment method initListeners.

@Override
protected void initListeners() {
    super.initListeners();
    itemListAdapter.setSelectedListener(new OnClickGesture<LocalItem>() {

        @Override
        public void selected(LocalItem selectedItem) {
            // Requires the parent fragment to find holder for fragment replacement
            if (getParentFragment() == null)
                return;
            final FragmentManager fragmentManager = getParentFragment().getFragmentManager();
            if (selectedItem instanceof PlaylistMetadataEntry) {
                final PlaylistMetadataEntry entry = ((PlaylistMetadataEntry) selectedItem);
                NavigationHelper.openLocalPlaylistFragment(fragmentManager, entry.uid, entry.name);
            } else if (selectedItem instanceof PlaylistRemoteEntity) {
                final PlaylistRemoteEntity entry = ((PlaylistRemoteEntity) selectedItem);
                NavigationHelper.openPlaylistFragment(fragmentManager, entry.getServiceId(), entry.getUrl(), entry.getName());
            }
        }

        @Override
        public void held(LocalItem selectedItem) {
            if (selectedItem instanceof PlaylistMetadataEntry) {
                showLocalDeleteDialog((PlaylistMetadataEntry) selectedItem);
            } else if (selectedItem instanceof PlaylistRemoteEntity) {
                showRemoteDeleteDialog((PlaylistRemoteEntity) selectedItem);
            }
        }
    });
    lastPlayedButton.setOnClickListener(view -> {
        if (getParentFragment() != null) {
            NavigationHelper.openLastPlayedFragment(getParentFragment().getFragmentManager());
        }
    });
    mostPlayedButton.setOnClickListener(view -> {
        if (getParentFragment() != null) {
            NavigationHelper.openMostPlayedFragment(getParentFragment().getFragmentManager());
        }
    });
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) PlaylistLocalItem(org.schabi.newpipe.database.playlist.PlaylistLocalItem) LocalItem(org.schabi.newpipe.database.LocalItem) PlaylistRemoteEntity(org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity) PlaylistMetadataEntry(org.schabi.newpipe.database.playlist.PlaylistMetadataEntry)

Example 2 with PlaylistMetadataEntry

use of org.schabi.newpipe.database.playlist.PlaylistMetadataEntry in project NewPipe by TeamNewPipe.

the class PlaylistAppendDialog method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final LocalPlaylistManager playlistManager = new LocalPlaylistManager(NewPipeDatabase.getInstance(getContext()));
    playlistAdapter = new LocalItemListAdapter(getActivity());
    playlistAdapter.setSelectedListener(new OnClickGesture<LocalItem>() {

        @Override
        public void selected(LocalItem selectedItem) {
            if (!(selectedItem instanceof PlaylistMetadataEntry) || getStreams() == null)
                return;
            onPlaylistSelected(playlistManager, (PlaylistMetadataEntry) selectedItem, getStreams());
        }
    });
    playlistRecyclerView = view.findViewById(R.id.playlist_list);
    playlistRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    playlistRecyclerView.setAdapter(playlistAdapter);
    final View newPlaylistButton = view.findViewById(R.id.newPlaylist);
    newPlaylistButton.setOnClickListener(ignored -> openCreatePlaylistDialog());
    playlistReactor = playlistManager.getPlaylists().observeOn(AndroidSchedulers.mainThread()).subscribe(this::onPlaylistsReceived);
}
Also used : LocalItemListAdapter(org.schabi.newpipe.fragments.local.LocalItemListAdapter) LocalItem(org.schabi.newpipe.database.LocalItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) LocalPlaylistManager(org.schabi.newpipe.fragments.local.LocalPlaylistManager) PlaylistMetadataEntry(org.schabi.newpipe.database.playlist.PlaylistMetadataEntry)

Example 3 with PlaylistMetadataEntry

use of org.schabi.newpipe.database.playlist.PlaylistMetadataEntry in project NewPipe by TeamNewPipe.

the class LocalPlaylistItemHolder method updateFromItem.

@Override
public void updateFromItem(final LocalItem localItem, final DateFormat dateFormat) {
    if (!(localItem instanceof PlaylistMetadataEntry))
        return;
    final PlaylistMetadataEntry item = (PlaylistMetadataEntry) localItem;
    itemTitleView.setText(item.name);
    itemStreamCountView.setText(String.valueOf(item.streamCount));
    itemUploaderView.setVisibility(View.INVISIBLE);
    itemBuilder.displayImage(item.thumbnailUrl, itemThumbnailView, ImageDisplayConstants.DISPLAY_PLAYLIST_OPTIONS);
    super.updateFromItem(localItem, dateFormat);
}
Also used : PlaylistMetadataEntry(org.schabi.newpipe.database.playlist.PlaylistMetadataEntry)

Aggregations

PlaylistMetadataEntry (org.schabi.newpipe.database.playlist.PlaylistMetadataEntry)3 LocalItem (org.schabi.newpipe.database.LocalItem)2 FragmentManager (android.support.v4.app.FragmentManager)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 PlaylistLocalItem (org.schabi.newpipe.database.playlist.PlaylistLocalItem)1 PlaylistRemoteEntity (org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity)1 LocalItemListAdapter (org.schabi.newpipe.fragments.local.LocalItemListAdapter)1 LocalPlaylistManager (org.schabi.newpipe.fragments.local.LocalPlaylistManager)1