Answer the question
In order to leave comments, you need to log in
How to speed up image loading using Picasso?
I have a RecyclerView that loads thumbnails using Picasso.
thumbnail example . As you can see, the picture is not big, but it loads quite slowly.
Tried doing resize(), noFade() - doesn't help.
What else can be done to increase download speed?
ViewHolder code:
inner class MediaPreviewViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val mediaPreviewImageView: ImageView =
view.findViewById(R.id.media_preview_recycler_view_image)
val playVideoImageView: ImageView = view.findViewById(R.id.play_video_image_view)
val playAudioImageView: ImageView = view.findViewById(R.id.play_audio_image_view)
val descriptionTextView: TextView = view.findViewById(R.id.description_text_view)
val dateCreatedTextView: TextView = view.findViewById(R.id.date_created_text_view)
val divider: View = view.findViewById(R.id.divider)
fun bind(mediaPreview: MediaPreview, hideDivider: Boolean) {
descriptionTextView.text = mediaPreview.description
dateCreatedTextView.text = mediaPreview.dateCreated
divider.visibility = View.VISIBLE
if (hideDivider) {
divider.visibility = View.INVISIBLE
}
when (mediaPreview.mediaType) {
ContentType.IMAGE -> {
picasso
.load(mediaPreview.previewUrl)
.fit()
.centerCrop()
.into(mediaPreviewImageView)
playVideoImageView.visibility = View.GONE
playAudioImageView.visibility = View.GONE
}
ContentType.VIDEO -> {
picasso
.load(mediaPreview.previewUrl)
.fit()
.centerCrop()
.into(mediaPreviewImageView);
playVideoImageView.visibility = View.VISIBLE
playAudioImageView.visibility = View.GONE
}
ContentType.AUDIO -> {
mediaPreviewImageView.setImageResource(android.R.color.black)
playVideoImageView.visibility = View.GONE
playAudioImageView.visibility = View.VISIBLE
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question