mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-10 17:30:31 +00:00
stability improvements
This commit is contained in:
parent
ca0d594547
commit
76ba2824a2
@ -143,146 +143,150 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
View topView = activity.findViewById(R.id.detailTopView);
|
View topView = activity.findViewById(R.id.detailTopView);
|
||||||
Button channelButton = (Button) activity.findViewById(R.id.channel_button);
|
Button channelButton = (Button) activity.findViewById(R.id.channel_button);
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
// prevents a crash if the activity/fragment was already left when the response came
|
||||||
if(info.next_video != null) {
|
if(channelButton != null) {
|
||||||
// todo: activate this function or remove it
|
|
||||||
nextStreamView.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
nextStreamView.setVisibility(View.GONE);
|
|
||||||
activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
textContentLayout.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.GONE);
|
||||||
if (android.os.Build.VERSION.SDK_INT < 18) {
|
if (info.next_video != null) {
|
||||||
playVideoButton.setVisibility(View.VISIBLE);
|
// todo: activate this function or remove it
|
||||||
} else {
|
nextStreamView.setVisibility(View.GONE);
|
||||||
ImageView playArrowView = (ImageView) activity.findViewById(R.id.play_arrow_view);
|
} else {
|
||||||
playArrowView.setVisibility(View.VISIBLE);
|
nextStreamView.setVisibility(View.GONE);
|
||||||
}
|
activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if (!showNextStreamItem) {
|
textContentLayout.setVisibility(View.VISIBLE);
|
||||||
nextVideoRootFrame.setVisibility(View.GONE);
|
if (android.os.Build.VERSION.SDK_INT < 18) {
|
||||||
similarTitle.setVisibility(View.GONE);
|
playVideoButton.setVisibility(View.VISIBLE);
|
||||||
}
|
} else {
|
||||||
|
ImageView playArrowView = (ImageView) activity.findViewById(R.id.play_arrow_view);
|
||||||
|
playArrowView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
videoTitleView.setText(info.title);
|
if (!showNextStreamItem) {
|
||||||
|
nextVideoRootFrame.setVisibility(View.GONE);
|
||||||
|
similarTitle.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
topView.setOnTouchListener(new View.OnTouchListener() {
|
videoTitleView.setText(info.title);
|
||||||
@Override
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
topView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
|
@Override
|
||||||
ImageView arrow = (ImageView) activity.findViewById(R.id.toggle_description_view);
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
View extra = activity.findViewById(R.id.detailExtraView);
|
if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
|
||||||
if (extra.getVisibility() == View.VISIBLE) {
|
ImageView arrow = (ImageView) activity.findViewById(R.id.toggle_description_view);
|
||||||
extra.setVisibility(View.GONE);
|
View extra = activity.findViewById(R.id.detailExtraView);
|
||||||
arrow.setImageResource(R.drawable.arrow_down);
|
if (extra.getVisibility() == View.VISIBLE) {
|
||||||
} else {
|
extra.setVisibility(View.GONE);
|
||||||
extra.setVisibility(View.VISIBLE);
|
arrow.setImageResource(R.drawable.arrow_down);
|
||||||
arrow.setImageResource(R.drawable.arrow_up);
|
} else {
|
||||||
|
extra.setVisibility(View.VISIBLE);
|
||||||
|
arrow.setImageResource(R.drawable.arrow_up);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
});
|
||||||
|
|
||||||
|
// Since newpipe is designed to work even if certain information is not available,
|
||||||
|
// the UI has to react on missing information.
|
||||||
|
videoTitleView.setText(info.title);
|
||||||
|
if (!info.uploader.isEmpty()) {
|
||||||
|
uploaderView.setText(info.uploader);
|
||||||
|
} else {
|
||||||
|
activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
if (info.view_count >= 0) {
|
||||||
|
viewCountView.setText(Localization.localizeViewCount(info.view_count, a));
|
||||||
// Since newpipe is designed to work even if certain information is not available,
|
} else {
|
||||||
// the UI has to react on missing information.
|
viewCountView.setVisibility(View.GONE);
|
||||||
videoTitleView.setText(info.title);
|
}
|
||||||
if(!info.uploader.isEmpty()) {
|
if (info.dislike_count >= 0) {
|
||||||
uploaderView.setText(info.uploader);
|
thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a));
|
||||||
} else {
|
} else {
|
||||||
activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE);
|
thumbsDownView.setVisibility(View.INVISIBLE);
|
||||||
}
|
activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE);
|
||||||
if(info.view_count >= 0) {
|
}
|
||||||
viewCountView.setText(Localization.localizeViewCount(info.view_count, a));
|
if (info.like_count >= 0) {
|
||||||
} else {
|
thumbsUpView.setText(Localization.localizeNumber(info.like_count, a));
|
||||||
viewCountView.setVisibility(View.GONE);
|
} else {
|
||||||
}
|
thumbsUpView.setVisibility(View.GONE);
|
||||||
if(info.dislike_count >= 0) {
|
activity.findViewById(R.id.detail_thumbs_up_img_view).setVisibility(View.GONE);
|
||||||
thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a));
|
thumbsDownView.setVisibility(View.GONE);
|
||||||
} else {
|
activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE);
|
||||||
thumbsDownView.setVisibility(View.INVISIBLE);
|
}
|
||||||
activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE);
|
if (!info.upload_date.isEmpty()) {
|
||||||
}
|
uploadDateView.setText(Localization.localizeDate(info.upload_date, a));
|
||||||
if(info.like_count >= 0) {
|
} else {
|
||||||
thumbsUpView.setText(Localization.localizeNumber(info.like_count, a));
|
uploadDateView.setVisibility(View.GONE);
|
||||||
} else {
|
}
|
||||||
thumbsUpView.setVisibility(View.GONE);
|
if (!info.description.isEmpty()) {
|
||||||
activity.findViewById(R.id.detail_thumbs_up_img_view).setVisibility(View.GONE);
|
descriptionView.setText(Html.fromHtml(info.description));
|
||||||
thumbsDownView.setVisibility(View.GONE);
|
} else {
|
||||||
activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE);
|
descriptionView.setVisibility(View.GONE);
|
||||||
}
|
|
||||||
if(!info.upload_date.isEmpty()) {
|
|
||||||
uploadDateView.setText(Localization.localizeDate(info.upload_date, a));
|
|
||||||
} else {
|
|
||||||
uploadDateView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
if(!info.description.isEmpty()) {
|
|
||||||
descriptionView.setText(Html.fromHtml(info.description));
|
|
||||||
} else {
|
|
||||||
descriptionView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
|
|
||||||
|
|
||||||
// parse streams
|
|
||||||
Vector<VideoStream> streamsToUse = new Vector<>();
|
|
||||||
for (VideoStream i : info.video_streams) {
|
|
||||||
if (useStream(i, streamsToUse)) {
|
|
||||||
streamsToUse.add(i);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
textContentLayout.setVisibility(View.VISIBLE);
|
descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
if(info.next_video == null) {
|
// parse streams
|
||||||
activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE);
|
Vector<VideoStream> streamsToUse = new Vector<>();
|
||||||
}
|
for (VideoStream i : info.video_streams) {
|
||||||
|
if (useStream(i, streamsToUse)) {
|
||||||
|
streamsToUse.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(info.related_streams != null && !info.related_streams.isEmpty()) {
|
textContentLayout.setVisibility(View.VISIBLE);
|
||||||
initSimilarVideos(info);
|
|
||||||
} else {
|
|
||||||
activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
|
|
||||||
activity.findViewById(R.id.similar_streams_view).setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
setupActionBarHandler(info);
|
if (info.next_video == null) {
|
||||||
|
activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if(autoPlayEnabled) {
|
if (info.related_streams != null && !info.related_streams.isEmpty()) {
|
||||||
playVideo(info);
|
initSimilarVideos(info);
|
||||||
}
|
} else {
|
||||||
|
activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
|
||||||
|
activity.findViewById(R.id.similar_streams_view).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT < 18) {
|
setupActionBarHandler(info);
|
||||||
playVideoButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
|
if (autoPlayEnabled) {
|
||||||
|
playVideo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (android.os.Build.VERSION.SDK_INT < 18) {
|
||||||
|
playVideoButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
playVideo(info);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
backgroundButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
playVideo(info);
|
playVideo(info);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
backgroundButton.setOnClickListener(new View.OnClickListener() {
|
if (info.channel_url != null && info.channel_url != "") {
|
||||||
@Override
|
channelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
@Override
|
||||||
playVideo(info);
|
public void onClick(View view) {
|
||||||
|
Intent i = new Intent(activity, ChannelActivity.class);
|
||||||
|
i.putExtra(ChannelActivity.CHANNEL_URL, info.channel_url);
|
||||||
|
i.putExtra(ChannelActivity.SERVICE_ID, info.service_id);
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
channelButton.setVisibility(Button.GONE);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if(info.channel_url != null && info.channel_url != "") {
|
initThumbnailViews(info);
|
||||||
channelButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Intent i = new Intent(activity, ChannelActivity.class);
|
|
||||||
i.putExtra(ChannelActivity.CHANNEL_URL, info.channel_url);
|
|
||||||
i.putExtra(ChannelActivity.SERVICE_ID, info.service_id);
|
|
||||||
startActivity(i);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
channelButton.setVisibility(Button.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initThumbnailViews(info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initThumbnailViews(final StreamInfo info) {
|
private void initThumbnailViews(final StreamInfo info) {
|
||||||
@ -290,7 +294,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
ImageView uploaderThumb
|
ImageView uploaderThumb
|
||||||
= (ImageView) activity.findViewById(R.id.detail_uploader_thumbnail_view);
|
= (ImageView) activity.findViewById(R.id.detail_uploader_thumbnail_view);
|
||||||
|
|
||||||
if(info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
|
if (info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
|
||||||
imageLoader.displayImage(info.thumbnail_url, videoThumbnailView,
|
imageLoader.displayImage(info.thumbnail_url, videoThumbnailView,
|
||||||
displayImageOptions, new ImageLoadingListener() {
|
displayImageOptions, new ImageLoadingListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -318,7 +322,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
} else {
|
} else {
|
||||||
videoThumbnailView.setImageResource(R.drawable.dummy_thumbnail_dark);
|
videoThumbnailView.setImageResource(R.drawable.dummy_thumbnail_dark);
|
||||||
}
|
}
|
||||||
if(info.uploader_thumbnail_url != null && !info.uploader_thumbnail_url.isEmpty()) {
|
if (info.uploader_thumbnail_url != null && !info.uploader_thumbnail_url.isEmpty()) {
|
||||||
imageLoader.displayImage(info.uploader_thumbnail_url,
|
imageLoader.displayImage(info.uploader_thumbnail_url,
|
||||||
uploaderThumb, displayImageOptions,
|
uploaderThumb, displayImageOptions,
|
||||||
new ImageErrorLoadingListener(activity, rootView, info.service_id));
|
new ImageErrorLoadingListener(activity, rootView, info.service_id));
|
||||||
@ -418,7 +422,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(info.audio_streams == null) {
|
if (info.audio_streams == null) {
|
||||||
actionBarHandler.showAudioAction(false);
|
actionBarHandler.showAudioAction(false);
|
||||||
} else {
|
} else {
|
||||||
actionBarHandler.setOnPlayAudioListener(new ActionBarHandler.OnActionListener() {
|
actionBarHandler.setOnPlayAudioListener(new ActionBarHandler.OnActionListener() {
|
||||||
|
Loading…
Reference in New Issue
Block a user