Commit 4fdd84c7 authored by Matthieu's avatar Matthieu
Browse files

Merge branch 'previewFix' into 'master'

Fix #300 in manner suggested by dansup

Closes #300

See merge request !386
parents 6e7b1a63 2e3d912c
Pipeline #807 failed with stages
in 16 minutes and 50 seconds
......@@ -172,7 +172,7 @@ class NotificationsFragment : CachedFeedFragment<Notification>() {
Glide.with(itemView).load(notification?.account?.anyAvatar()).circleCrop()
.into(avatar)
val previewUrl = notification?.status?.media_attachments?.getOrNull(0)?.preview_url
val previewUrl = notification?.status?.getPostPreviewURL()
if (!previewUrl.isNullOrBlank()) {
Glide.with(itemView).load(previewUrl)
.placeholder(R.drawable.ic_picture_fallback).into(photoThumbnail)
......
......@@ -121,7 +121,7 @@ class SearchDiscoverFragment : BaseFragment() {
} else {
holder.albumIcon.visibility = View.GONE
}
ImageConverter.setSquareImageFromURL(holder.postView, post?.media_attachments?.firstOrNull()?.preview_url, holder.postPreview, post?.media_attachments?.firstOrNull()?.blurhash)
ImageConverter.setSquareImageFromURL(holder.postView, post?.getPostPreviewURL(), holder.postPreview, post?.media_attachments?.firstOrNull()?.blurhash)
holder.postPreview.setOnClickListener {
val intent = Intent(holder.postView.context, PostActivity::class.java)
intent.putExtra(Status.POST_TAG, post)
......
......@@ -38,4 +38,8 @@ data class Attachment(
val aspect: Double?
) : Serializable
}
val previewNoPlaceholder: String?
get() = if (preview_url?.contains(Regex("public/no-preview\\.(png|jpg|webp)")) == true) url else preview_url
}
......@@ -65,7 +65,7 @@ open class Status(
fun getPostUrl() : String? = media_attachments?.firstOrNull()?.url
fun getProfilePicUrl() : String? = account?.anyAvatar()
fun getPostPreviewURL() : String? = media_attachments?.firstOrNull()?.preview_url
fun getPostPreviewURL() : String? = media_attachments?.firstOrNull()?.previewNoPlaceholder
fun getNLikes(context: Context) : CharSequence {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment