Merge branch 'previewFix' into 'master'

Fix #300 in manner suggested by dansup

Closes #300

See merge request pixeldroid/PixelDroid!386
This commit is contained in:
Matthieu 2021-09-22 22:19:23 +00:00
commit 4fdd84c71f
4 changed files with 7 additions and 3 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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
}

View File

@ -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 {