From 8d59812827a3993fcdd3d322100e7f053bcca96b Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 16 Nov 2023 22:46:43 +0100 Subject: [PATCH] Fix channel avatar not loading correctly sometimes The fix just involves removing some really outdated code (6 years ago) added in https://github.com/TeamNewPipe/NewPipe/commit/33e29be7db2e4a6fcd23e411081c871bf3c4b5c3#diff-38bd2cf1b92659b499c08e1cf6ac9ef384c7e13381b906f2f98c57cbb758756dR778 (blame: https://github.com/TeamNewPipe/NewPipe/blame/9318bb530619898c1e1f3f8a8c866f3d2e35ab0c/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailActivity.java#L778). What that code did was setting the 'buddy' image to the uploader avatar as a placeholder, and then setting the actual image if it existed and after it had loaded. That code remained there up until now, but now it doesn't make sense anymore, since Picasso already takes care of setting placeholders. The problem is, starting from #10066 the actual uploader image is set before (not after) those lines of code, making them do the wrong thing, i.e. always overwrite the currently set image. But then why did the channel avatar image work normally sometimes? My guess is that since Picasso loads images in the background, when opening a video from scratch setting the placeholder still happened before Picasso finished loading the image. However when the image is already cached it's loaded much faster and therefore setting the placeholder happens after, effectively hiding the loaded image. --- .../newpipe/fragments/detail/VideoDetailFragment.java | 6 ------ 1 file changed, 6 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 a25d0fae4..7db5e0251 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 @@ -24,7 +24,6 @@ import android.content.pm.ActivityInfo; import android.database.ContentObserver; import android.graphics.Color; import android.graphics.Rect; -import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -1482,11 +1481,6 @@ public final class VideoDetailFragment displayUploaderAsSubChannel(info); } - final Drawable buddyDrawable = - AppCompatResources.getDrawable(activity, R.drawable.placeholder_person); - binding.detailSubChannelThumbnailView.setImageDrawable(buddyDrawable); - binding.detailUploaderThumbnailView.setImageDrawable(buddyDrawable); - if (info.getViewCount() >= 0) { if (info.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) { binding.detailViewCountView.setText(Localization.listeningCount(activity,