Merge pull request #5654 from Bnyro/master

fix: placeholders not properly shown at fast scrolling
This commit is contained in:
Bnyro 2024-02-25 13:14:04 +01:00 committed by GitHub
commit 9c41a2d76b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 9 deletions

View File

@ -64,6 +64,9 @@ object ImageHelper {
* load an image from a url into an imageView
*/
fun loadImage(url: String?, target: ImageView, whiteBackground: Boolean = false) {
// clear image to avoid loading issues at fast scrolling
target.setImageBitmap(null)
// only load the image if the data saver mode is disabled
if (DataSaverMode.isEnabled(target.context) || url.isNullOrEmpty()) return
val urlToLoad = ProxyHelper.unwrapImageUrl(url)

View File

@ -69,7 +69,6 @@ class CommentPagingAdapter(
commentText.text = comment.commentText?.replace("</a>", "</a> ")
?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {})))
commentorImage.setImageDrawable(null)
ImageHelper.loadImage(comment.thumbnail, commentorImage, true)
likesTextView.text = comment.likeCount.formatShort()

View File

@ -76,17 +76,20 @@ class PlaylistAdapter(
override fun onBindViewHolder(holder: PlaylistViewHolder, position: Int) {
val streamItem = sortedFeed[position]
val videoId = streamItem.url!!.toID()
holder.binding.apply {
videoTitle.text = streamItem.title
videoInfo.text = streamItem.uploaderName
channelImage.isGone = true
thumbnailDuration.setFormattedDuration(streamItem.duration!!, streamItem.isShort)
ImageHelper.loadImage(streamItem.thumbnail, thumbnail)
root.setOnClickListener {
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
}
val videoId = streamItem.url!!.toID()
val activity = (root.context as BaseActivity)
val fragmentManager = activity.supportFragmentManager

View File

@ -70,7 +70,6 @@ class SearchChannelAdapter : ListAdapter<ContentItem, SearchViewHolder>(SearchCa
private fun bindVideo(item: ContentItem, binding: VideoRowBinding, position: Int) {
binding.apply {
thumbnail.setImageDrawable(null)
ImageHelper.loadImage(item.thumbnail, thumbnail)
thumbnailDuration.setFormattedDuration(item.duration, item.isShort)
videoTitle.text = item.title
@ -117,7 +116,6 @@ class SearchChannelAdapter : ListAdapter<ContentItem, SearchViewHolder>(SearchCa
private fun bindChannel(item: ContentItem, binding: ChannelRowBinding) {
binding.apply {
searchChannelImage.setImageDrawable(null)
ImageHelper.loadImage(item.thumbnail, searchChannelImage, true)
searchChannelName.text = item.name
@ -156,7 +154,6 @@ class SearchChannelAdapter : ListAdapter<ContentItem, SearchViewHolder>(SearchCa
private fun bindPlaylist(item: ContentItem, binding: PlaylistsRowBinding) {
binding.apply {
playlistThumbnail.setImageDrawable(null)
ImageHelper.loadImage(item.thumbnail, playlistThumbnail)
if (item.videos != -1L) videoCount.text = item.videos.toString()
playlistTitle.text = item.name

View File

@ -103,8 +103,6 @@ class VideosAdapter(
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: VideosViewHolder, position: Int) {
holder.trendingRowBinding?.thumbnail?.setImageDrawable(null)
val video = streamItems[position]
val videoId = video.url?.toID()