mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-07-07 12:32:59 +00:00
stability improvements
This commit is contained in:
parent
ca0d594547
commit
76ba2824a2
@ -143,8 +143,11 @@ 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);
|
||||||
|
|
||||||
|
// prevents a crash if the activity/fragment was already left when the response came
|
||||||
|
if(channelButton != null) {
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
if(info.next_video != null) {
|
if (info.next_video != null) {
|
||||||
// todo: activate this function or remove it
|
// todo: activate this function or remove it
|
||||||
nextStreamView.setVisibility(View.GONE);
|
nextStreamView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
@ -188,23 +191,23 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
// Since newpipe is designed to work even if certain information is not available,
|
// Since newpipe is designed to work even if certain information is not available,
|
||||||
// the UI has to react on missing information.
|
// the UI has to react on missing information.
|
||||||
videoTitleView.setText(info.title);
|
videoTitleView.setText(info.title);
|
||||||
if(!info.uploader.isEmpty()) {
|
if (!info.uploader.isEmpty()) {
|
||||||
uploaderView.setText(info.uploader);
|
uploaderView.setText(info.uploader);
|
||||||
} else {
|
} else {
|
||||||
activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE);
|
activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if(info.view_count >= 0) {
|
if (info.view_count >= 0) {
|
||||||
viewCountView.setText(Localization.localizeViewCount(info.view_count, a));
|
viewCountView.setText(Localization.localizeViewCount(info.view_count, a));
|
||||||
} else {
|
} else {
|
||||||
viewCountView.setVisibility(View.GONE);
|
viewCountView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if(info.dislike_count >= 0) {
|
if (info.dislike_count >= 0) {
|
||||||
thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a));
|
thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a));
|
||||||
} else {
|
} else {
|
||||||
thumbsDownView.setVisibility(View.INVISIBLE);
|
thumbsDownView.setVisibility(View.INVISIBLE);
|
||||||
activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE);
|
activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if(info.like_count >= 0) {
|
if (info.like_count >= 0) {
|
||||||
thumbsUpView.setText(Localization.localizeNumber(info.like_count, a));
|
thumbsUpView.setText(Localization.localizeNumber(info.like_count, a));
|
||||||
} else {
|
} else {
|
||||||
thumbsUpView.setVisibility(View.GONE);
|
thumbsUpView.setVisibility(View.GONE);
|
||||||
@ -212,12 +215,12 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
thumbsDownView.setVisibility(View.GONE);
|
thumbsDownView.setVisibility(View.GONE);
|
||||||
activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE);
|
activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if(!info.upload_date.isEmpty()) {
|
if (!info.upload_date.isEmpty()) {
|
||||||
uploadDateView.setText(Localization.localizeDate(info.upload_date, a));
|
uploadDateView.setText(Localization.localizeDate(info.upload_date, a));
|
||||||
} else {
|
} else {
|
||||||
uploadDateView.setVisibility(View.GONE);
|
uploadDateView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if(!info.description.isEmpty()) {
|
if (!info.description.isEmpty()) {
|
||||||
descriptionView.setText(Html.fromHtml(info.description));
|
descriptionView.setText(Html.fromHtml(info.description));
|
||||||
} else {
|
} else {
|
||||||
descriptionView.setVisibility(View.GONE);
|
descriptionView.setVisibility(View.GONE);
|
||||||
@ -235,11 +238,11 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
|
|
||||||
textContentLayout.setVisibility(View.VISIBLE);
|
textContentLayout.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if(info.next_video == null) {
|
if (info.next_video == null) {
|
||||||
activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE);
|
activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(info.related_streams != null && !info.related_streams.isEmpty()) {
|
if (info.related_streams != null && !info.related_streams.isEmpty()) {
|
||||||
initSimilarVideos(info);
|
initSimilarVideos(info);
|
||||||
} else {
|
} else {
|
||||||
activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
|
activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
|
||||||
@ -248,7 +251,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
|
|
||||||
setupActionBarHandler(info);
|
setupActionBarHandler(info);
|
||||||
|
|
||||||
if(autoPlayEnabled) {
|
if (autoPlayEnabled) {
|
||||||
playVideo(info);
|
playVideo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +271,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(info.channel_url != null && info.channel_url != "") {
|
if (info.channel_url != null && info.channel_url != "") {
|
||||||
channelButton.setOnClickListener(new View.OnClickListener() {
|
channelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -284,13 +287,14 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
|
|
||||||
initThumbnailViews(info);
|
initThumbnailViews(info);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initThumbnailViews(final StreamInfo info) {
|
private void initThumbnailViews(final StreamInfo info) {
|
||||||
ImageView videoThumbnailView = (ImageView) activity.findViewById(R.id.detail_thumbnail_view);
|
ImageView videoThumbnailView = (ImageView) activity.findViewById(R.id.detail_thumbnail_view);
|
||||||
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…
x
Reference in New Issue
Block a user