fixed Bundle casting bug incurred during related videosdisplay

This commit is contained in:
Adam Howard 2015-11-19 14:40:35 +00:00
parent 23e0196fcc
commit 2c11bd1889
3 changed files with 13 additions and 3 deletions

View File

@ -2,6 +2,8 @@ package org.schabi.newpipe;
import android.graphics.Bitmap;
import java.util.List;
/**
* Created by Christian Schabesberger on 26.08.15.
*
@ -41,7 +43,7 @@ public class VideoInfo extends AbstractVideoInfo {
public int dislike_count = -1;
public String average_rating = "";
public VideoPreviewInfo nextVideo = null;
public VideoPreviewInfo[] relatedVideos = null;
public List<VideoPreviewInfo> relatedVideos = null;
public int startPosition = -1;//in seconds. some metadata is not passed using a VideoInfo object!
public static final int VIDEO_AVAILABLE = 0x00;

View File

@ -32,6 +32,7 @@ import android.view.MenuItem;
import java.net.URL;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
@ -394,7 +395,12 @@ public class VideoItemDetailFragment extends Fragment {
@Override
public void onClick(View v) {
Intent intent = new Intent(activity, VideoItemListActivity.class);
intent.putExtra(VideoItemListActivity.VIDEO_INFO_ITEMS, currentVideoInfo.relatedVideos);
//todo: find more elegant way to do this - converting from List to ArrayList sucks
ArrayList<VideoPreviewInfo> toParcel = new ArrayList<>(currentVideoInfo.relatedVideos);
//why oh why does the parcelable array put method have to be so damn specific
// about the class of its argument?
//why not a List<? extends Parcelable>?
intent.putParcelableArrayListExtra(VideoItemListActivity.VIDEO_INFO_ITEMS, toParcel);
activity.startActivity(intent);
}
});

View File

@ -421,7 +421,9 @@ public class YoutubeExtractor extends Extractor {
relatedVideos.add(extractVideoPreviewInfo(li));
}
}
videoInfo.relatedVideos = relatedVideos.toArray(new VideoPreviewInfo[relatedVideos.size()]);
//todo: replace conversion
videoInfo.relatedVideos = relatedVideos;
//videoInfo.relatedVideos = relatedVideos.toArray(new VideoPreviewInfo[relatedVideos.size()]);
return videoInfo;
}