2018-10-02 15:09:16 +00:00
|
|
|
package org.schabi.newpipe.util;
|
|
|
|
|
|
|
|
import org.schabi.newpipe.extractor.InfoItem;
|
|
|
|
import org.schabi.newpipe.extractor.ListInfo;
|
|
|
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
2018-10-16 18:53:02 +00:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
2018-10-02 15:09:16 +00:00
|
|
|
|
2018-10-16 18:53:02 +00:00
|
|
|
import java.util.ArrayList;
|
2018-10-02 15:09:16 +00:00
|
|
|
import java.util.Collections;
|
2018-10-16 18:53:02 +00:00
|
|
|
import java.util.List;
|
2018-10-02 15:09:16 +00:00
|
|
|
|
|
|
|
public class RelatedStreamInfo extends ListInfo<InfoItem> {
|
|
|
|
|
2018-10-16 18:53:02 +00:00
|
|
|
private StreamInfoItem nextStream;
|
2018-10-02 15:09:16 +00:00
|
|
|
|
|
|
|
public RelatedStreamInfo(int serviceId, ListLinkHandler listUrlIdHandler, String name) {
|
|
|
|
super(serviceId, listUrlIdHandler, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RelatedStreamInfo getInfo(StreamInfo info) {
|
|
|
|
ListLinkHandler handler = new ListLinkHandler(info.getOriginalUrl(), info.getUrl(), info.getId(), Collections.emptyList(), null);
|
|
|
|
RelatedStreamInfo relatedStreamInfo = new RelatedStreamInfo(info.getServiceId(), handler, info.getName());
|
2018-10-16 18:53:02 +00:00
|
|
|
List<InfoItem> streams = new ArrayList<>();
|
|
|
|
if(info.getNextVideo() != null){
|
|
|
|
streams.add(info.getNextVideo());
|
|
|
|
}
|
|
|
|
streams.addAll(info.getRelatedStreams());
|
|
|
|
relatedStreamInfo.setRelatedItems(streams);
|
|
|
|
relatedStreamInfo.setNextStream(info.getNextVideo());
|
|
|
|
return relatedStreamInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public StreamInfoItem getNextStream() {
|
|
|
|
return nextStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setNextStream(StreamInfoItem nextStream) {
|
|
|
|
this.nextStream = nextStream;
|
2018-10-02 15:09:16 +00:00
|
|
|
}
|
|
|
|
}
|