Search in sources :

Example 1 with PlaylistRemoteEntity

use of org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity 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 PlaylistRemoteEntity

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

the class RemotePlaylistItemHolder method updateFromItem.

@Override
public void updateFromItem(final LocalItem localItem, final DateFormat dateFormat) {
    if (!(localItem instanceof PlaylistRemoteEntity))
        return;
    final PlaylistRemoteEntity item = (PlaylistRemoteEntity) localItem;
    itemTitleView.setText(item.getName());
    itemStreamCountView.setText(String.valueOf(item.getStreamCount()));
    itemUploaderView.setText(Localization.concatenateStrings(item.getUploader(), NewPipe.getNameOfService(item.getServiceId())));
    itemBuilder.displayImage(item.getThumbnailUrl(), itemThumbnailView, ImageDisplayConstants.DISPLAY_PLAYLIST_OPTIONS);
    super.updateFromItem(localItem, dateFormat);
}
Also used : PlaylistRemoteEntity(org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity)

Aggregations

PlaylistRemoteEntity (org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity)2 FragmentManager (android.support.v4.app.FragmentManager)1 LocalItem (org.schabi.newpipe.database.LocalItem)1 PlaylistLocalItem (org.schabi.newpipe.database.playlist.PlaylistLocalItem)1 PlaylistMetadataEntry (org.schabi.newpipe.database.playlist.PlaylistMetadataEntry)1