Search in sources :

Example 6 with StreamInfoItem

use of org.schabi.newpipe.extractor.stream.StreamInfoItem in project NewPipe by TeamNewPipe.

the class StatisticsPlaylistFragment method showStreamDialog.

/*//////////////////////////////////////////////////////////////////////////
    // Utils
    //////////////////////////////////////////////////////////////////////////*/
private void showStreamDialog(final StreamStatisticsEntry item) {
    final Context context = getContext();
    final Activity activity = getActivity();
    if (context == null || context.getResources() == null || getActivity() == null)
        return;
    final StreamInfoItem infoItem = item.toStreamInfoItem();
    final String[] commands = new String[] { context.getResources().getString(R.string.enqueue_on_background), context.getResources().getString(R.string.enqueue_on_popup), context.getResources().getString(R.string.start_here_on_main), context.getResources().getString(R.string.start_here_on_background), context.getResources().getString(R.string.start_here_on_popup) };
    final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
        final int index = Math.max(itemListAdapter.getItemsList().indexOf(item), 0);
        switch(i) {
            case 0:
                NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(infoItem));
                break;
            case 1:
                NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(infoItem));
                break;
            case 2:
                NavigationHelper.playOnMainPlayer(context, getPlayQueue(index));
                break;
            case 3:
                NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
                break;
            case 4:
                NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
                break;
            default:
                break;
        }
    };
    new InfoItemDialog(getActivity(), infoItem, commands, actions).show();
}
Also used : Context(android.content.Context) Context(android.content.Context) StreamStatisticsEntry(org.schabi.newpipe.database.stream.StreamStatisticsEntry) Bundle(android.os.Bundle) NavigationHelper(org.schabi.newpipe.util.NavigationHelper) NonNull(android.support.annotation.NonNull) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) SinglePlayQueue(org.schabi.newpipe.playlist.SinglePlayQueue) ArrayList(java.util.ArrayList) HistoryRecordManager(org.schabi.newpipe.history.HistoryRecordManager) View(android.view.View) OnClickGesture(org.schabi.newpipe.util.OnClickGesture) State(icepick.State) Subscriber(org.reactivestreams.Subscriber) R(org.schabi.newpipe.R) DialogInterface(android.content.DialogInterface) Parcelable(android.os.Parcelable) LayoutInflater(android.view.LayoutInflater) LocalItem(org.schabi.newpipe.database.LocalItem) UserAction(org.schabi.newpipe.report.UserAction) ViewGroup(android.view.ViewGroup) StreamInfoItem(org.schabi.newpipe.extractor.stream.StreamInfoItem) List(java.util.List) InfoItemDialog(org.schabi.newpipe.info_list.InfoItemDialog) Subscription(org.reactivestreams.Subscription) PlayQueue(org.schabi.newpipe.playlist.PlayQueue) Nullable(android.support.annotation.Nullable) Activity(android.app.Activity) Collections(java.util.Collections) StreamInfoItem(org.schabi.newpipe.extractor.stream.StreamInfoItem) InfoItemDialog(org.schabi.newpipe.info_list.InfoItemDialog) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) SinglePlayQueue(org.schabi.newpipe.playlist.SinglePlayQueue)

Example 7 with StreamInfoItem

use of org.schabi.newpipe.extractor.stream.StreamInfoItem in project NewPipe by TeamNewPipe.

the class PlaylistAppendDialog method fromStreamInfoItems.

public static PlaylistAppendDialog fromStreamInfoItems(final List<StreamInfoItem> items) {
    PlaylistAppendDialog dialog = new PlaylistAppendDialog();
    List<StreamEntity> entities = new ArrayList<>(items.size());
    for (final StreamInfoItem item : items) {
        entities.add(new StreamEntity(item));
    }
    dialog.setInfo(entities);
    return dialog;
}
Also used : StreamInfoItem(org.schabi.newpipe.extractor.stream.StreamInfoItem) ArrayList(java.util.ArrayList) StreamEntity(org.schabi.newpipe.database.stream.model.StreamEntity)

Example 8 with StreamInfoItem

use of org.schabi.newpipe.extractor.stream.StreamInfoItem in project NewPipe by TeamNewPipe.

the class StreamMiniInfoItemHolder method updateFromItem.

@Override
public void updateFromItem(final InfoItem infoItem) {
    if (!(infoItem instanceof StreamInfoItem))
        return;
    final StreamInfoItem item = (StreamInfoItem) infoItem;
    itemVideoTitleView.setText(item.getName());
    itemUploaderView.setText(item.getUploaderName());
    if (item.getDuration() > 0) {
        itemDurationView.setText(Localization.getDurationString(item.getDuration()));
        itemDurationView.setBackgroundColor(ContextCompat.getColor(itemBuilder.getContext(), R.color.duration_background_color));
        itemDurationView.setVisibility(View.VISIBLE);
    } else if (item.getStreamType() == StreamType.LIVE_STREAM) {
        itemDurationView.setText(R.string.duration_live);
        itemDurationView.setBackgroundColor(ContextCompat.getColor(itemBuilder.getContext(), R.color.live_duration_background_color));
        itemDurationView.setVisibility(View.VISIBLE);
    } else {
        itemDurationView.setVisibility(View.GONE);
    }
    // Default thumbnail is shown on error, while loading and if the url is empty
    itemBuilder.getImageLoader().displayImage(item.getThumbnailUrl(), itemThumbnailView, ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS);
    itemView.setOnClickListener(view -> {
        if (itemBuilder.getOnStreamSelectedListener() != null) {
            itemBuilder.getOnStreamSelectedListener().selected(item);
        }
    });
    switch(item.getStreamType()) {
        case AUDIO_STREAM:
        case VIDEO_STREAM:
        case LIVE_STREAM:
        case AUDIO_LIVE_STREAM:
            enableLongClick(item);
            break;
        case FILE:
        case NONE:
        default:
            disableLongClick();
            break;
    }
}
Also used : StreamInfoItem(org.schabi.newpipe.extractor.stream.StreamInfoItem)

Example 9 with StreamInfoItem

use of org.schabi.newpipe.extractor.stream.StreamInfoItem in project NewPipe by TeamNewPipe.

the class StreamInfoItemHolder method updateFromItem.

@Override
public void updateFromItem(final InfoItem infoItem) {
    super.updateFromItem(infoItem);
    if (!(infoItem instanceof StreamInfoItem))
        return;
    final StreamInfoItem item = (StreamInfoItem) infoItem;
    itemAdditionalDetails.setText(getStreamInfoDetailLine(item));
}
Also used : StreamInfoItem(org.schabi.newpipe.extractor.stream.StreamInfoItem)

Example 10 with StreamInfoItem

use of org.schabi.newpipe.extractor.stream.StreamInfoItem in project NewPipe by TeamNewPipe.

the class BaseListFragment method showStreamDialog.

protected void showStreamDialog(final StreamInfoItem item) {
    final Context context = getContext();
    final Activity activity = getActivity();
    if (context == null || context.getResources() == null || getActivity() == null)
        return;
    final String[] commands = new String[] { context.getResources().getString(R.string.enqueue_on_background), context.getResources().getString(R.string.enqueue_on_popup), context.getResources().getString(R.string.append_playlist) };
    final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
        switch(i) {
            case 0:
                NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
                break;
            case 1:
                NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
                break;
            case 2:
                if (getFragmentManager() != null) {
                    PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item)).show(getFragmentManager(), TAG);
                }
                break;
            default:
                break;
        }
    };
    new InfoItemDialog(getActivity(), item, commands, actions).show();
}
Also used : Context(android.content.Context) InfoListAdapter(org.schabi.newpipe.info_list.InfoListAdapter) Context(android.content.Context) ChannelInfoItem(org.schabi.newpipe.extractor.channel.ChannelInfoItem) Bundle(android.os.Bundle) NavigationHelper(org.schabi.newpipe.util.NavigationHelper) NonNull(android.support.annotation.NonNull) SinglePlayQueue(org.schabi.newpipe.playlist.SinglePlayQueue) InfoItem(org.schabi.newpipe.extractor.InfoItem) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) View(android.view.View) OnClickGesture(org.schabi.newpipe.util.OnClickGesture) AnimationUtils.animateView(org.schabi.newpipe.util.AnimationUtils.animateView) ActionBar(android.support.v7.app.ActionBar) R(org.schabi.newpipe.R) Log(android.util.Log) DialogInterface(android.content.DialogInterface) BaseStateFragment(org.schabi.newpipe.fragments.BaseStateFragment) StateSaver(org.schabi.newpipe.util.StateSaver) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) StreamInfoItem(org.schabi.newpipe.extractor.stream.StreamInfoItem) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) PlaylistInfoItem(org.schabi.newpipe.extractor.playlist.PlaylistInfoItem) InfoItemDialog(org.schabi.newpipe.info_list.InfoItemDialog) Queue(java.util.Queue) Activity(android.app.Activity) PlaylistAppendDialog(org.schabi.newpipe.fragments.local.dialog.PlaylistAppendDialog) Collections(java.util.Collections) OnScrollBelowItemsListener(org.schabi.newpipe.fragments.OnScrollBelowItemsListener) InfoItemDialog(org.schabi.newpipe.info_list.InfoItemDialog) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) SinglePlayQueue(org.schabi.newpipe.playlist.SinglePlayQueue)

Aggregations

StreamInfoItem (org.schabi.newpipe.extractor.stream.StreamInfoItem)13 ArrayList (java.util.ArrayList)7 SinglePlayQueue (org.schabi.newpipe.playlist.SinglePlayQueue)7 Activity (android.app.Activity)4 Context (android.content.Context)4 DialogInterface (android.content.DialogInterface)4 Bundle (android.os.Bundle)4 NonNull (android.support.annotation.NonNull)4 Nullable (android.support.annotation.Nullable)4 View (android.view.View)4 List (java.util.List)4 R (org.schabi.newpipe.R)4 LocalItem (org.schabi.newpipe.database.LocalItem)4 InfoItemDialog (org.schabi.newpipe.info_list.InfoItemDialog)4 NavigationHelper (org.schabi.newpipe.util.NavigationHelper)4 RecyclerView (android.support.v7.widget.RecyclerView)3 Log (android.util.Log)3 LayoutInflater (android.view.LayoutInflater)3 ViewGroup (android.view.ViewGroup)3 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)3