parent
e8b71e867c
commit
40213b2d6a
|
@ -67,12 +67,12 @@ class ActionBarHandler {
|
||||||
|
|
||||||
public void setupStreamList(final List<VideoStream> videoStreams, Spinner toolbarSpinner) {
|
public void setupStreamList(final List<VideoStream> videoStreams, Spinner toolbarSpinner) {
|
||||||
if (activity == null) return;
|
if (activity == null) return;
|
||||||
selectedVideoStream = 0;
|
|
||||||
|
|
||||||
int defaultResolutionIndex = Utils.getDefaultResolution(activity, videoStreams);
|
selectedVideoStream = Utils.getDefaultResolution(activity, videoStreams);
|
||||||
|
|
||||||
boolean isExternalPlayerEnabled = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(activity.getString(R.string.use_external_video_player_key), false);
|
boolean isExternalPlayerEnabled = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(activity.getString(R.string.use_external_video_player_key), false);
|
||||||
toolbarSpinner.setAdapter(new SpinnerToolbarAdapter(activity, videoStreams, isExternalPlayerEnabled));
|
toolbarSpinner.setAdapter(new SpinnerToolbarAdapter(activity, videoStreams, isExternalPlayerEnabled));
|
||||||
toolbarSpinner.setSelection(defaultResolutionIndex);
|
toolbarSpinner.setSelection(selectedVideoStream);
|
||||||
toolbarSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
toolbarSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
|
|
@ -111,6 +111,10 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
private boolean showRelatedStreams;
|
private boolean showRelatedStreams;
|
||||||
private boolean wasRelatedStreamsExpanded = false;
|
private boolean wasRelatedStreamsExpanded = false;
|
||||||
|
|
||||||
|
private Handler uiHandler;
|
||||||
|
private Handler backgroundHandler;
|
||||||
|
private HandlerThread backgroundHandlerThread;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Views
|
// Views
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -150,9 +154,6 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
private LinearLayout relatedStreamRootLayout;
|
private LinearLayout relatedStreamRootLayout;
|
||||||
private LinearLayout relatedStreamsView;
|
private LinearLayout relatedStreamsView;
|
||||||
private ImageButton relatedStreamExpandButton;
|
private ImageButton relatedStreamExpandButton;
|
||||||
private Handler uiHandler;
|
|
||||||
private Handler backgroundHandler;
|
|
||||||
private HandlerThread backgroundHandlerThread;
|
|
||||||
|
|
||||||
/*////////////////////////////////////////////////////////////////////////*/
|
/*////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@ -203,10 +204,10 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
million = getString(R.string.short_million);
|
million = getString(R.string.short_million);
|
||||||
billion = getString(R.string.short_billion);
|
billion = getString(R.string.short_billion);
|
||||||
|
|
||||||
if(uiHandler == null) {
|
if (uiHandler == null) {
|
||||||
uiHandler = new Handler(Looper.getMainLooper(), new UICallback());
|
uiHandler = new Handler(Looper.getMainLooper(), new UICallback());
|
||||||
}
|
}
|
||||||
if(backgroundHandler == null) {
|
if (backgroundHandler == null) {
|
||||||
HandlerThread handlerThread = new HandlerThread("VideoDetailFragment-BG");
|
HandlerThread handlerThread = new HandlerThread("VideoDetailFragment-BG");
|
||||||
handlerThread.start();
|
handlerThread.start();
|
||||||
backgroundHandlerThread = handlerThread;
|
backgroundHandlerThread = handlerThread;
|
||||||
|
@ -259,7 +260,7 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if(backgroundHandlerThread != null) {
|
if (backgroundHandlerThread != null) {
|
||||||
backgroundHandlerThread.quit();
|
backgroundHandlerThread.quit();
|
||||||
}
|
}
|
||||||
backgroundHandlerThread = null;
|
backgroundHandlerThread = null;
|
||||||
|
@ -377,7 +378,7 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
openInPopup();
|
openInPopup();
|
||||||
break;
|
break;
|
||||||
case R.id.detail_uploader_root_layout:
|
case R.id.detail_uploader_root_layout:
|
||||||
if(currentStreamInfo.channel_url == null || currentStreamInfo.channel_url.isEmpty()) {
|
if (currentStreamInfo.channel_url == null || currentStreamInfo.channel_url.isEmpty()) {
|
||||||
Log.w(TAG, "Can't open channel because we got no channel URL");
|
Log.w(TAG, "Can't open channel because we got no channel URL");
|
||||||
} else {
|
} else {
|
||||||
NavigationHelper.openChannelFragment(getFragmentManager(), currentStreamInfo.service_id, currentStreamInfo.channel_url, currentStreamInfo.uploader);
|
NavigationHelper.openChannelFragment(getFragmentManager(), currentStreamInfo.service_id, currentStreamInfo.channel_url, currentStreamInfo.uploader);
|
||||||
|
@ -619,7 +620,6 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Menu
|
// Menu
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -940,10 +940,16 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
setTitleToUrl(info.webpage_url, info.title);
|
setTitleToUrl(info.webpage_url, info.title);
|
||||||
setStreamInfoToUrl(info.webpage_url, info);
|
setStreamInfoToUrl(info.webpage_url, info);
|
||||||
|
|
||||||
|
|
||||||
prepareDescription(info.description);
|
prepareDescription(info.description);
|
||||||
prepareUploadDate(info.upload_date);
|
prepareUploadDate(info.upload_date);
|
||||||
|
|
||||||
|
if (autoPlayEnabled) {
|
||||||
|
playVideo(info);
|
||||||
|
// Only auto play in the first open
|
||||||
|
autoPlayEnabled = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void prepareUploadDate(final String uploadDate) {
|
private void prepareUploadDate(final String uploadDate) {
|
||||||
// Hide until date is prepared or forever if no date is supplied
|
// Hide until date is prepared or forever if no date is supplied
|
||||||
videoUploadDateView.setVisibility(View.GONE);
|
videoUploadDateView.setVisibility(View.GONE);
|
||||||
|
@ -1076,9 +1082,6 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
.setStartDelay((long) (duration * .8f) + delay).setDuration(duration).setInterpolator(new FastOutSlowInInterpolator()).start();
|
.setStartDelay((long) (duration * .8f) + delay).setDuration(duration).setInterpolator(new FastOutSlowInInterpolator()).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
|
||||||
// OnStreamInfoReceivedListener callbacks
|
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
private void setErrorImage(final int imageResource) {
|
private void setErrorImage(final int imageResource) {
|
||||||
if (thumbnailImageView == null || activity == null) return;
|
if (thumbnailImageView == null || activity == null) return;
|
||||||
|
@ -1099,6 +1102,10 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
currentStreamInfo = null;
|
currentStreamInfo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// OnStreamInfoReceivedListener callbacks
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(StreamInfo info) {
|
public void onReceive(StreamInfo info) {
|
||||||
if (DEBUG) Log.d(TAG, "onReceive() called with: info = [" + info + "]");
|
if (DEBUG) Log.d(TAG, "onReceive() called with: info = [" + info + "]");
|
||||||
|
@ -1106,15 +1113,8 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
|
|
||||||
handleStreamInfo(info, true);
|
handleStreamInfo(info, true);
|
||||||
showContentWithAnimation(300, 0, 0);
|
showContentWithAnimation(300, 0, 0);
|
||||||
|
|
||||||
animateView(loadingProgressBar, false, 200);
|
animateView(loadingProgressBar, false, 200);
|
||||||
|
|
||||||
if (autoPlayEnabled) {
|
|
||||||
playVideo(info);
|
|
||||||
// Only auto play in the first open
|
|
||||||
autoPlayEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
StreamInfoCache.getInstance().putInfo(info);
|
StreamInfoCache.getInstance().putInfo(info);
|
||||||
isLoading.set(false);
|
isLoading.set(false);
|
||||||
|
|
||||||
|
@ -1171,6 +1171,10 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|
||||||
activity.finish();
|
activity.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Background handling
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
private static class BackgroundCallback implements Handler.Callback {
|
private static class BackgroundCallback implements Handler.Callback {
|
||||||
private static final int MESSAGE_DESCRIPTION = 1;
|
private static final int MESSAGE_DESCRIPTION = 1;
|
||||||
public static final int MESSAGE_UPLOADER_DATE = 2;
|
public static final int MESSAGE_UPLOADER_DATE = 2;
|
||||||
|
|
Loading…
Reference in New Issue