From 10c42de2f16a5e2162d718ce431a36020506d71e Mon Sep 17 00:00:00 2001 From: Stypox Date: Wed, 3 May 2023 10:28:24 +0200 Subject: [PATCH] Fix uploader and subchannel avatars swapped --- .../fragments/detail/VideoDetailFragment.java | 54 +++++++------------ .../fragment_video_detail.xml | 12 ++--- .../main/res/layout/fragment_video_detail.xml | 12 ++--- 3 files changed, 30 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 8227f1c69..3c07b1a93 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -61,7 +61,6 @@ import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.tabs.TabLayout; -import com.squareup.picasso.Callback; import org.schabi.newpipe.App; import org.schabi.newpipe.R; @@ -649,27 +648,6 @@ public final class VideoDetailFragment } } - private void initThumbnailViews(@NonNull final StreamInfo info) { - PicassoHelper.loadDetailsThumbnail(info.getThumbnailUrl()).tag(PICASSO_VIDEO_DETAILS_TAG) - .into(binding.detailThumbnailImageView, new Callback() { - @Override - public void onSuccess() { - // nothing to do, the image was loaded correctly into the thumbnail - } - - @Override - public void onError(final Exception e) { - showSnackBarError(new ErrorInfo(e, UserAction.LOAD_IMAGE, - info.getThumbnailUrl(), info)); - } - }); - - PicassoHelper.loadAvatar(info.getSubChannelAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG) - .into(binding.detailSubChannelThumbnailView); - PicassoHelper.loadAvatar(info.getUploaderAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG) - .into(binding.detailUploaderThumbnailView); - } - /*////////////////////////////////////////////////////////////////////////// // OwnStack //////////////////////////////////////////////////////////////////////////*/ @@ -1480,12 +1458,9 @@ public final class VideoDetailFragment binding.detailSubChannelThumbnailView.setVisibility(View.GONE); if (!isEmpty(info.getSubChannelName())) { - displayBothUploaderAndSubChannel(info, activity); - } else if (!isEmpty(info.getUploaderName())) { - displayUploaderAsSubChannel(info, activity); + displayBothUploaderAndSubChannel(info); } else { - binding.detailUploaderTextView.setVisibility(View.GONE); - binding.detailUploaderThumbnailView.setVisibility(View.GONE); + displayUploaderAsSubChannel(info); } final Drawable buddyDrawable = @@ -1559,7 +1534,8 @@ public final class VideoDetailFragment binding.detailSecondaryControlPanel.setVisibility(View.GONE); checkUpdateProgressInfo(info); - initThumbnailViews(info); + PicassoHelper.loadDetailsThumbnail(info.getThumbnailUrl()).tag(PICASSO_VIDEO_DETAILS_TAG) + .into(binding.detailThumbnailImageView); showMetaInfoInTextView(info.getMetaInfo(), binding.detailMetaInfoTextView, binding.detailMetaInfoSeparator, disposables); @@ -1596,27 +1572,30 @@ public final class VideoDetailFragment noVideoStreams ? R.drawable.ic_headset_shadow : R.drawable.ic_play_arrow_shadow); } - private void displayUploaderAsSubChannel(final StreamInfo info, final Context context) { + private void displayUploaderAsSubChannel(final StreamInfo info) { binding.detailSubChannelTextView.setText(info.getUploaderName()); binding.detailSubChannelTextView.setVisibility(View.VISIBLE); binding.detailSubChannelTextView.setSelected(true); if (info.getUploaderSubscriberCount() > -1) { binding.detailUploaderTextView.setText( - Localization.shortSubscriberCount(context, info.getUploaderSubscriberCount())); + Localization.shortSubscriberCount(activity, info.getUploaderSubscriberCount())); binding.detailUploaderTextView.setVisibility(View.VISIBLE); } else { binding.detailUploaderTextView.setVisibility(View.GONE); } + + PicassoHelper.loadAvatar(info.getUploaderAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG) + .into(binding.detailSubChannelThumbnailView); + binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE); + binding.detailUploaderThumbnailView.setVisibility(View.GONE); } - private void displayBothUploaderAndSubChannel(final StreamInfo info, final Context context) { + private void displayBothUploaderAndSubChannel(final StreamInfo info) { binding.detailSubChannelTextView.setText(info.getSubChannelName()); binding.detailSubChannelTextView.setVisibility(View.VISIBLE); binding.detailSubChannelTextView.setSelected(true); - binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE); - final StringBuilder subText = new StringBuilder(); if (!isEmpty(info.getUploaderName())) { subText.append( @@ -1627,7 +1606,7 @@ public final class VideoDetailFragment subText.append(Localization.DOT_SEPARATOR); } subText.append( - Localization.shortSubscriberCount(context, info.getUploaderSubscriberCount())); + Localization.shortSubscriberCount(activity, info.getUploaderSubscriberCount())); } if (subText.length() > 0) { @@ -1637,6 +1616,13 @@ public final class VideoDetailFragment } else { binding.detailUploaderTextView.setVisibility(View.GONE); } + + PicassoHelper.loadAvatar(info.getSubChannelAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG) + .into(binding.detailSubChannelThumbnailView); + binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE); + PicassoHelper.loadAvatar(info.getUploaderAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG) + .into(binding.detailUploaderThumbnailView); + binding.detailUploaderThumbnailView.setVisibility(View.VISIBLE); } public void openDownloadDialog() { diff --git a/app/src/main/res/layout-large-land/fragment_video_detail.xml b/app/src/main/res/layout-large-land/fragment_video_detail.xml index 9fdede902..d18681056 100644 --- a/app/src/main/res/layout-large-land/fragment_video_detail.xml +++ b/app/src/main/res/layout-large-land/fragment_video_detail.xml @@ -267,23 +267,21 @@ android:layout_height="wrap_content"> + app:shapeAppearance="@style/CircularImageView" /> diff --git a/app/src/main/res/layout/fragment_video_detail.xml b/app/src/main/res/layout/fragment_video_detail.xml index 438c618ef..9aaf6d8d6 100644 --- a/app/src/main/res/layout/fragment_video_detail.xml +++ b/app/src/main/res/layout/fragment_video_detail.xml @@ -254,24 +254,22 @@ android:layout_height="wrap_content"> + tools:ignore="RtlHardcoded" />