-Rename playlist in players to play queue.
This commit is contained in:
parent
cbcd281784
commit
7c9c3de644
|
@ -250,12 +250,7 @@ public abstract class BasePlayer implements Player.EventListener, AudioManager.O
|
||||||
changeState(STATE_LOADING);
|
changeState(STATE_LOADING);
|
||||||
|
|
||||||
isPrepared = false;
|
isPrepared = false;
|
||||||
|
mediaSource = buildMediaSource(url, format);
|
||||||
final MediaSource ms = buildMediaSource(url, format);
|
|
||||||
final DynamicConcatenatingMediaSource dcms = new DynamicConcatenatingMediaSource();
|
|
||||||
dcms.addMediaSource(ms);
|
|
||||||
mediaSource = dcms;
|
|
||||||
dcms.addMediaSource(new LoopingMediaSource(ms, 2));
|
|
||||||
|
|
||||||
if (simpleExoPlayer.getPlaybackState() != Player.STATE_IDLE) simpleExoPlayer.stop();
|
if (simpleExoPlayer.getPlaybackState() != Player.STATE_IDLE) simpleExoPlayer.stop();
|
||||||
if (videoStartPos > 0) simpleExoPlayer.seekTo(videoStartPos);
|
if (videoStartPos > 0) simpleExoPlayer.seekTo(videoStartPos);
|
||||||
|
|
|
@ -3,19 +3,31 @@ package org.schabi.newpipe.player;
|
||||||
import com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource;
|
import com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
|
|
||||||
import org.schabi.newpipe.playlist.Playlist;
|
import org.schabi.newpipe.playlist.PlayQueue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MediaSourceManager {
|
public class PlaybackManager {
|
||||||
|
|
||||||
private DynamicConcatenatingMediaSource source;
|
private DynamicConcatenatingMediaSource source;
|
||||||
|
|
||||||
private Playlist playlist;
|
private PlayQueue playQueue;
|
||||||
|
private int index;
|
||||||
|
|
||||||
private List<MediaSource> sources;
|
private List<MediaSource> sources;
|
||||||
|
|
||||||
public MediaSourceManager(Playlist playlist) {
|
public PlaybackManager(PlayQueue playQueue, int index) {
|
||||||
this.source = new DynamicConcatenatingMediaSource();
|
this.source = new DynamicConcatenatingMediaSource();
|
||||||
this.playlist = playlist;
|
|
||||||
|
this.playQueue = playQueue;
|
||||||
|
this.index = index;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnChangeListener {
|
||||||
|
void isLoading();
|
||||||
|
void isLoaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,26 +16,61 @@ import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import io.reactivex.Maybe;
|
import io.reactivex.Maybe;
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.functions.Consumer;
|
import io.reactivex.functions.Consumer;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
public class ExternalPlaylist extends Playlist {
|
public class ExternalPlayQueue extends PlayQueue {
|
||||||
|
|
||||||
|
private final static int LOAD_PROXIMITY = 10;
|
||||||
|
|
||||||
|
private boolean isComplete;
|
||||||
|
|
||||||
private AtomicInteger pageNumber;
|
private AtomicInteger pageNumber;
|
||||||
|
|
||||||
private StreamingService service;
|
private StreamingService service;
|
||||||
|
|
||||||
public ExternalPlaylist(final PlayListInfoItem playlist) {
|
private PlayListInfoItem playlist;
|
||||||
super();
|
|
||||||
service = getService(playlist.serviceId);
|
|
||||||
pageNumber = new AtomicInteger(0);
|
|
||||||
|
|
||||||
load(playlist);
|
public ExternalPlayQueue(final PlayListInfoItem playlist) {
|
||||||
|
super();
|
||||||
|
this.service = getService(playlist.serviceId);
|
||||||
|
this.pageNumber = new AtomicInteger(0);
|
||||||
|
this.playlist = playlist;
|
||||||
|
|
||||||
|
fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(final PlayListInfoItem playlist) {
|
@Override
|
||||||
|
public boolean isComplete() {
|
||||||
|
return isComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(int index, boolean loadNeighbors) {
|
||||||
|
if (index > streams.size() || streams.get(index) == null) return;
|
||||||
|
|
||||||
|
streams.get(index).load();
|
||||||
|
|
||||||
|
if (loadNeighbors) {
|
||||||
|
int leftBound = index - LOAD_BOUND >= 0 ? index - LOAD_BOUND : 0;
|
||||||
|
int rightBound = index + LOAD_BOUND < streams.size() ? index + LOAD_BOUND : streams.size() - 1;
|
||||||
|
|
||||||
|
for (int i = leftBound; i < rightBound; i++) {
|
||||||
|
final PlayQueueItem item = streams.get(i);
|
||||||
|
if (item != null) item.load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Maybe<StreamInfo> get(int index) {
|
||||||
|
if (index > streams.size() || streams.get(index) == null) return Maybe.empty();
|
||||||
|
return streams.get(index).getStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public synchronized void fetch() {
|
||||||
final int page = pageNumber.getAndIncrement();
|
final int page = pageNumber.getAndIncrement();
|
||||||
|
|
||||||
final Callable<PlayListInfo> task = new Callable<PlayListInfo>() {
|
final Callable<PlayListInfo> task = new Callable<PlayListInfo>() {
|
||||||
|
@ -49,8 +84,10 @@ public class ExternalPlaylist extends Playlist {
|
||||||
final Consumer<PlayListInfo> onSuccess = new Consumer<PlayListInfo>() {
|
final Consumer<PlayListInfo> onSuccess = new Consumer<PlayListInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public void accept(PlayListInfo playListInfo) throws Exception {
|
public void accept(PlayListInfo playListInfo) throws Exception {
|
||||||
|
if (!playListInfo.hasNextPage) isComplete = true;
|
||||||
|
|
||||||
streams.addAll(extractPlaylistItems(playListInfo));
|
streams.addAll(extractPlaylistItems(playListInfo));
|
||||||
changeBroadcast.onNext(streams);
|
notifyChange();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,33 +98,16 @@ public class ExternalPlaylist extends Playlist {
|
||||||
.subscribe(onSuccess);
|
.subscribe(onSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PlaylistItem> extractPlaylistItems(final PlayListInfo info) {
|
private List<PlayQueueItem> extractPlaylistItems(final PlayListInfo info) {
|
||||||
List<PlaylistItem> result = new ArrayList<>();
|
List<PlayQueueItem> result = new ArrayList<>();
|
||||||
for (final InfoItem stream : info.related_streams) {
|
for (final InfoItem stream : info.related_streams) {
|
||||||
if (stream instanceof StreamInfoItem) {
|
if (stream instanceof StreamInfoItem) {
|
||||||
result.add(new PlaylistItem((StreamInfoItem) stream));
|
result.add(new PlayQueueItem((StreamInfoItem) stream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean isComplete() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void load(int index) {
|
|
||||||
while (streams.size() < index) {
|
|
||||||
pageNumber.incrementAndGet();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Observable<StreamInfo> get(int index) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StreamingService getService(final int serviceId) {
|
private StreamingService getService(final int serviceId) {
|
||||||
try {
|
try {
|
||||||
return NewPipe.getService(serviceId);
|
return NewPipe.getService(serviceId);
|
||||||
|
@ -95,5 +115,4 @@ public class ExternalPlaylist extends Playlist {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.schabi.newpipe.playlist;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.reactivex.Maybe;
|
||||||
|
import io.reactivex.subjects.BehaviorSubject;
|
||||||
|
|
||||||
|
public abstract class PlayQueue {
|
||||||
|
private final String TAG = "PlayQueue@" + Integer.toHexString(hashCode());
|
||||||
|
|
||||||
|
final int LOAD_BOUND = 2;
|
||||||
|
|
||||||
|
protected List<PlayQueueItem> streams;
|
||||||
|
private BehaviorSubject<List<PlayQueueItem>> changeBroadcast;
|
||||||
|
|
||||||
|
PlayQueue() {
|
||||||
|
streams = Collections.synchronizedList(new ArrayList<PlayQueueItem>());
|
||||||
|
changeBroadcast = BehaviorSubject.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public List<PlayQueueItem> getStreams() {
|
||||||
|
return streams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyChange() {
|
||||||
|
changeBroadcast.onNext(streams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean isComplete();
|
||||||
|
|
||||||
|
public abstract void load(int index, boolean loadNeighbors);
|
||||||
|
|
||||||
|
public abstract Maybe<StreamInfo> get(int index);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.schabi.newpipe.playlist;
|
package org.schabi.newpipe.playlist;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -10,7 +9,6 @@ import android.view.ViewGroup;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.info_list.StreamInfoItemHolder;
|
import org.schabi.newpipe.info_list.StreamInfoItemHolder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,11 +31,11 @@ import java.util.List;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PlaylistAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PlayQueueAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
private static final String TAG = PlaylistAdapter.class.toString();
|
private static final String TAG = PlayQueueAdapter.class.toString();
|
||||||
|
|
||||||
private final PlaylistItemBuilder playlistItemBuilder;
|
private final PlaylistItemBuilder playlistItemBuilder;
|
||||||
private final List<PlaylistItem> playlistItems;
|
private final PlayQueue playQueue;
|
||||||
private boolean showFooter = false;
|
private boolean showFooter = false;
|
||||||
private View header = null;
|
private View header = null;
|
||||||
private View footer = null;
|
private View footer = null;
|
||||||
|
@ -55,34 +53,60 @@ public class PlaylistAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaylistAdapter(List<PlaylistItem> data) {
|
public PlayQueueAdapter(PlayQueue playQueue) {
|
||||||
playlistItemBuilder = new PlaylistItemBuilder();
|
this.playlistItemBuilder = new PlaylistItemBuilder();
|
||||||
playlistItems = data;
|
this.playQueue = playQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedListener(PlaylistItemBuilder.OnSelectedListener listener) {
|
public void setSelectedListener(PlaylistItemBuilder.OnSelectedListener listener) {
|
||||||
playlistItemBuilder.setOnSelectedListener(listener);
|
playlistItemBuilder.setOnSelectedListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInfoItemList(List<PlaylistItem> data) {
|
public void addItems(List<PlayQueueItem> data) {
|
||||||
if(data != null) {
|
if(data != null) {
|
||||||
playlistItems.addAll(data);
|
playQueue.getStreams().addAll(data);
|
||||||
notifyDataSetChanged();
|
notifyPlaylistChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInfoItem(PlaylistItem data) {
|
public void addItem(PlayQueueItem data) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
playlistItems.add(data);
|
playQueue.getStreams().add(data);
|
||||||
notifyDataSetChanged();
|
notifyPlaylistChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearStreamItemList() {
|
public void removeItem(int index) {
|
||||||
if(playlistItems.isEmpty()) {
|
if (index < playQueue.getStreams().size()) {
|
||||||
|
playQueue.getStreams().remove(index);
|
||||||
|
notifyPlaylistChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapItems(int source, int target) {
|
||||||
|
final List<PlayQueueItem> items = playQueue.getStreams();
|
||||||
|
if (source < items.size() && target < items.size()) {
|
||||||
|
final PlayQueueItem sourceItem = items.get(source);
|
||||||
|
final PlayQueueItem targetItem = items.get(target);
|
||||||
|
|
||||||
|
items.set(target, sourceItem);
|
||||||
|
items.set(source, targetItem);
|
||||||
|
|
||||||
|
notifyPlaylistChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
if(playQueue.getStreams().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
playlistItems.clear();
|
playQueue.getStreams().clear();
|
||||||
|
|
||||||
|
notifyPlaylistChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyPlaylistChange() {
|
||||||
|
playQueue.notifyChange();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,13 +120,13 @@ public class PlaylistAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlaylistItem> getItemsList() {
|
public List<PlayQueueItem> getItems() {
|
||||||
return playlistItems;
|
return playQueue.getStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
int count = playlistItems.size();
|
int count = playQueue.getStreams().size();
|
||||||
if(header != null) count++;
|
if(header != null) count++;
|
||||||
if(footer != null && showFooter) count++;
|
if(footer != null && showFooter) count++;
|
||||||
return count;
|
return count;
|
||||||
|
@ -116,7 +140,7 @@ public class PlaylistAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||||
} else if(header != null) {
|
} else if(header != null) {
|
||||||
position--;
|
position--;
|
||||||
}
|
}
|
||||||
if(footer != null && position == playlistItems.size() && showFooter) {
|
if(footer != null && position == playQueue.getStreams().size() && showFooter) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -140,14 +164,14 @@ public class PlaylistAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int i) {
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int i) {
|
||||||
if(holder instanceof PlaylistItemHolder) {
|
if(holder instanceof PlayQueueItemHolder) {
|
||||||
if(header != null) {
|
if(header != null) {
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
playlistItemBuilder.buildStreamInfoItem((PlaylistItemHolder) holder, playlistItems.get(i));
|
playlistItemBuilder.buildStreamInfoItem((PlayQueueItemHolder) holder, playQueue.getStreams().get(i));
|
||||||
} else if(holder instanceof HFHolder && i == 0 && header != null) {
|
} else if(holder instanceof HFHolder && i == 0 && header != null) {
|
||||||
((HFHolder) holder).view = header;
|
((HFHolder) holder).view = header;
|
||||||
} else if(holder instanceof HFHolder && i == playlistItems.size() && footer != null && showFooter) {
|
} else if(holder instanceof HFHolder && i == playQueue.getStreams().size() && footer != null && showFooter) {
|
||||||
((HFHolder) holder).view = footer;
|
((HFHolder) holder).view = footer;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@ import io.reactivex.functions.Action;
|
||||||
import io.reactivex.functions.Consumer;
|
import io.reactivex.functions.Consumer;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
public class PlaylistItem implements Serializable {
|
public class PlayQueueItem implements Serializable {
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private String url;
|
private String url;
|
||||||
|
@ -28,7 +28,7 @@ public class PlaylistItem implements Serializable {
|
||||||
private Throwable error;
|
private Throwable error;
|
||||||
private Maybe<StreamInfo> stream;
|
private Maybe<StreamInfo> stream;
|
||||||
|
|
||||||
public PlaylistItem(final StreamInfoItem streamInfoItem) {
|
public PlayQueueItem(final StreamInfoItem streamInfoItem) {
|
||||||
this.title = streamInfoItem.getTitle();
|
this.title = streamInfoItem.getTitle();
|
||||||
this.url = streamInfoItem.getLink();
|
this.url = streamInfoItem.getLink();
|
||||||
this.serviceId = streamInfoItem.service_id;
|
this.serviceId = streamInfoItem.service_id;
|
|
@ -29,12 +29,12 @@ import org.schabi.newpipe.info_list.InfoItemHolder;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PlaylistItemHolder extends RecyclerView.ViewHolder {
|
public class PlayQueueItemHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
public final TextView itemVideoTitleView, itemDurationView;
|
public final TextView itemVideoTitleView, itemDurationView;
|
||||||
public final View itemRoot;
|
public final View itemRoot;
|
||||||
|
|
||||||
public PlaylistItemHolder(View v) {
|
public PlayQueueItemHolder(View v) {
|
||||||
super(v);
|
super(v);
|
||||||
itemRoot = v.findViewById(R.id.itemRoot);
|
itemRoot = v.findViewById(R.id.itemRoot);
|
||||||
itemVideoTitleView = (TextView) v.findViewById(R.id.itemVideoTitleView);
|
itemVideoTitleView = (TextView) v.findViewById(R.id.itemVideoTitleView);
|
|
@ -1,38 +0,0 @@
|
||||||
package org.schabi.newpipe.playlist;
|
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.subjects.PublishSubject;
|
|
||||||
|
|
||||||
public abstract class Playlist {
|
|
||||||
private final String TAG = "Playlist@" + Integer.toHexString(hashCode());
|
|
||||||
|
|
||||||
private final int LOAD_BOUND = 2;
|
|
||||||
|
|
||||||
List<PlaylistItem> streams;
|
|
||||||
PublishSubject<List<PlaylistItem>> changeBroadcast;
|
|
||||||
|
|
||||||
Playlist() {
|
|
||||||
streams = Collections.synchronizedList(new ArrayList<PlaylistItem>());
|
|
||||||
changeBroadcast = PublishSubject.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public PublishSubject<List<PlaylistItem>> getChangeBroadcast() {
|
|
||||||
return changeBroadcast;
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract boolean isComplete();
|
|
||||||
|
|
||||||
abstract void load(int index);
|
|
||||||
|
|
||||||
abstract Observable<StreamInfo> get(int index);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,48 +1,14 @@
|
||||||
package org.schabi.newpipe.playlist;
|
package org.schabi.newpipe.playlist;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
||||||
|
|
||||||
import org.schabi.newpipe.ImageErrorLoadingListener;
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.AbstractStreamInfo;
|
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
|
||||||
import org.schabi.newpipe.extractor.playlist.PlayListInfoItem;
|
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamInfoItem;
|
|
||||||
import org.schabi.newpipe.info_list.ChannelInfoItemHolder;
|
|
||||||
import org.schabi.newpipe.info_list.InfoItemHolder;
|
|
||||||
import org.schabi.newpipe.info_list.PlaylistInfoItemHolder;
|
|
||||||
import org.schabi.newpipe.info_list.StreamInfoItemHolder;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Christian Schabesberger on 26.09.16.
|
|
||||||
* <p>
|
|
||||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
|
||||||
* InfoItemBuilder.java is part of NewPipe.
|
|
||||||
* <p>
|
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* <p>
|
|
||||||
* NewPipe is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
* <p>
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PlaylistItemBuilder {
|
public class PlaylistItemBuilder {
|
||||||
|
|
||||||
|
@ -60,10 +26,10 @@ public class PlaylistItemBuilder {
|
||||||
this.onStreamInfoItemSelectedListener = listener;
|
this.onStreamInfoItemSelectedListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public View buildView(ViewGroup parent, final PlaylistItem item) {
|
public View buildView(ViewGroup parent, final PlayQueueItem item) {
|
||||||
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||||
final View itemView = inflater.inflate(R.layout.stream_item, parent, false);
|
final View itemView = inflater.inflate(R.layout.stream_item, parent, false);
|
||||||
final PlaylistItemHolder holder = new PlaylistItemHolder(itemView);
|
final PlayQueueItemHolder holder = new PlayQueueItemHolder(itemView);
|
||||||
|
|
||||||
buildStreamInfoItem(holder, item);
|
buildStreamInfoItem(holder, item);
|
||||||
|
|
||||||
|
@ -71,7 +37,7 @@ public class PlaylistItemBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void buildStreamInfoItem(PlaylistItemHolder holder, final PlaylistItem item) {
|
public void buildStreamInfoItem(PlayQueueItemHolder holder, final PlayQueueItem item) {
|
||||||
if (!TextUtils.isEmpty(item.getTitle())) holder.itemVideoTitleView.setText(item.getTitle());
|
if (!TextUtils.isEmpty(item.getTitle())) holder.itemVideoTitleView.setText(item.getTitle());
|
||||||
|
|
||||||
if (item.getDuration() > 0) {
|
if (item.getDuration() > 0) {
|
||||||
|
|
Loading…
Reference in New Issue