fix: only apply white image background to channel avatars

This commit is contained in:
Bnyro 2024-01-06 14:23:03 +01:00
parent 02bd3f4cd1
commit 4c1604a646
10 changed files with 15 additions and 14 deletions

View File

@ -63,7 +63,7 @@ object ImageHelper {
/** /**
* load an image from a url into an imageView * load an image from a url into an imageView
*/ */
fun loadImage(url: String?, target: ImageView) { fun loadImage(url: String?, target: ImageView, whiteBackground: Boolean = false) {
// only load the image if the data saver mode is disabled // only load the image if the data saver mode is disabled
if (DataSaverMode.isEnabled(target.context) || url.isNullOrEmpty()) return if (DataSaverMode.isEnabled(target.context) || url.isNullOrEmpty()) return
val urlToLoad = ProxyHelper.unwrapImageUrl(url) val urlToLoad = ProxyHelper.unwrapImageUrl(url)
@ -72,7 +72,7 @@ object ImageHelper {
.data(urlToLoad) .data(urlToLoad)
.listener { _, result -> .listener { _, result ->
// set the background to white for transparent images // set the background to white for transparent images
target.setBackgroundColor(Color.WHITE) if (whiteBackground) target.setBackgroundColor(Color.WHITE)
target.setImageDrawable(result.drawable) target.setImageDrawable(result.drawable)
} }

View File

@ -83,11 +83,11 @@ class CommentsAdapter(
commentText.text = comment.commentText?.replace("</a>", "</a> ") commentText.text = comment.commentText?.replace("</a>", "</a> ")
?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {}))) ?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {})))
ImageHelper.loadImage(comment.thumbnail, commentorImage) ImageHelper.loadImage(comment.thumbnail, commentorImage, true)
likesTextView.text = comment.likeCount.formatShort() likesTextView.text = comment.likeCount.formatShort()
if (comment.creatorReplied && !channelAvatar.isNullOrBlank()) { if (comment.creatorReplied && !channelAvatar.isNullOrBlank()) {
ImageHelper.loadImage(channelAvatar, creatorReplyImageView) ImageHelper.loadImage(channelAvatar, creatorReplyImageView, true)
creatorReplyImageView.isVisible = true creatorReplyImageView.isVisible = true
} }

View File

@ -32,7 +32,8 @@ class LegacySubscriptionAdapter(
channelName.text = subscription.name channelName.text = subscription.name
ImageHelper.loadImage( ImageHelper.loadImage(
subscription.avatar, subscription.avatar,
channelAvatar channelAvatar,
true
) )
root.setOnClickListener { root.setOnClickListener {
NavigationHelper.navigateChannel(root.context, subscription.url) NavigationHelper.navigateChannel(root.context, subscription.url)

View File

@ -98,7 +98,7 @@ class SearchAdapter(
// only display channel related info if not in a channel tab // only display channel related info if not in a channel tab
if (!isChannelAdapter) { if (!isChannelAdapter) {
channelName.text = item.uploaderName channelName.text = item.uploaderName
ImageHelper.loadImage(item.uploaderAvatar, channelImage) ImageHelper.loadImage(item.uploaderAvatar, channelImage, true)
} else { } else {
channelContainer.isGone = true channelContainer.isGone = true
} }
@ -133,7 +133,7 @@ class SearchAdapter(
private fun bindChannel(item: ContentItem, binding: ChannelRowBinding) { private fun bindChannel(item: ContentItem, binding: ChannelRowBinding) {
binding.apply { binding.apply {
ImageHelper.loadImage(item.thumbnail, searchChannelImage) ImageHelper.loadImage(item.thumbnail, searchChannelImage, true)
searchChannelName.text = item.name searchChannelName.text = item.name
val subscribers = item.subscribers.formatShort() val subscribers = item.subscribers.formatShort()

View File

@ -43,7 +43,7 @@ class SubscriptionChannelAdapter(
holder.binding.apply { holder.binding.apply {
subscriptionChannelName.text = subscription.name subscriptionChannelName.text = subscription.name
ImageHelper.loadImage(subscription.avatar, subscriptionChannelImage) ImageHelper.loadImage(subscription.avatar, subscriptionChannelImage, true)
root.setOnClickListener { root.setOnClickListener {
NavigationHelper.navigateChannel(root.context, subscription.url) NavigationHelper.navigateChannel(root.context, subscription.url)

View File

@ -34,7 +34,7 @@ class SubscriptionGroupChannelsAdapter(
NavigationHelper.navigateChannel(root.context, channel.url) NavigationHelper.navigateChannel(root.context, channel.url)
} }
subscriptionChannelName.text = channel.name subscriptionChannelName.text = channel.name
ImageHelper.loadImage(channel.avatar, subscriptionChannelImage) ImageHelper.loadImage(channel.avatar, subscriptionChannelImage, true)
val channelId = channel.url.toID() val channelId = channel.url.toID()
channelIncluded.setOnCheckedChangeListener(null) channelIncluded.setOnCheckedChangeListener(null)

View File

@ -147,7 +147,7 @@ class VideosAdapter(
NavigationHelper.navigateChannel(root.context, video.uploaderUrl) NavigationHelper.navigateChannel(root.context, video.uploaderUrl)
} }
ImageHelper.loadImage(video.thumbnail, thumbnail) ImageHelper.loadImage(video.thumbnail, thumbnail)
ImageHelper.loadImage(video.uploaderAvatar, channelImage) ImageHelper.loadImage(video.uploaderAvatar, channelImage, true)
root.setOnClickListener { root.setOnClickListener {
NavigationHelper.navigateVideo(root.context, video.url) NavigationHelper.navigateVideo(root.context, video.url)
} }
@ -181,7 +181,7 @@ class VideosAdapter(
ImageHelper.loadImage(video.thumbnail, thumbnail) ImageHelper.loadImage(video.thumbnail, thumbnail)
if (forceMode != LayoutMode.CHANNEL_ROW) { if (forceMode != LayoutMode.CHANNEL_ROW) {
ImageHelper.loadImage(video.uploaderAvatar, channelImage) ImageHelper.loadImage(video.uploaderAvatar, channelImage, true)
channelName.text = video.uploaderName channelName.text = video.uploaderName
channelContainer.setOnClickListener { channelContainer.setOnClickListener {

View File

@ -60,7 +60,7 @@ class WatchHistoryAdapter(
videoInfo.text = video.uploadDate?.let { TextUtils.localizeDate(it) } videoInfo.text = video.uploadDate?.let { TextUtils.localizeDate(it) }
thumbnailDuration.setFormattedDuration(video.duration!!, null) thumbnailDuration.setFormattedDuration(video.duration!!, null)
ImageHelper.loadImage(video.thumbnailUrl, thumbnail) ImageHelper.loadImage(video.thumbnailUrl, thumbnail)
ImageHelper.loadImage(video.uploaderAvatar, channelImage) ImageHelper.loadImage(video.uploaderAvatar, channelImage, true)
channelImage.setOnClickListener { channelImage.setOnClickListener {
NavigationHelper.navigateChannel(root.context, video.uploaderUrl) NavigationHelper.navigateChannel(root.context, video.uploaderUrl)

View File

@ -216,7 +216,7 @@ class ChannelFragment : DynamicLayoutManagerFragment() {
} }
ImageHelper.loadImage(response.bannerUrl, binding.channelBanner) ImageHelper.loadImage(response.bannerUrl, binding.channelBanner)
ImageHelper.loadImage(response.avatarUrl, binding.channelImage) ImageHelper.loadImage(response.avatarUrl, binding.channelImage, true)
binding.channelImage.setOnClickListener { binding.channelImage.setOnClickListener {
NavigationHelper.openImagePreview( NavigationHelper.openImagePreview(

View File

@ -1038,7 +1038,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
binding.descriptionLayout.setStreams(streams) binding.descriptionLayout.setStreams(streams)
binding.apply { binding.apply {
ImageHelper.loadImage(streams.uploaderAvatar, binding.playerChannelImage) ImageHelper.loadImage(streams.uploaderAvatar, binding.playerChannelImage, true)
playerChannelName.text = streams.uploader playerChannelName.text = streams.uploader
titleTextView.text = streams.title titleTextView.text = streams.title
playerChannelSubCount.text = context?.getString( playerChannelSubCount.text = context?.getString(