From d3db8e944e5177e9ee7138da22680d10e3d47610 Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Sun, 27 Jun 2021 10:57:36 +0200 Subject: [PATCH] Don't assume non null for discover --- .../pixeldroid/app/searchDiscover/SearchDiscoverFragment.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/pixeldroid/app/searchDiscover/SearchDiscoverFragment.kt b/app/src/main/java/org/pixeldroid/app/searchDiscover/SearchDiscoverFragment.kt index 2285b6cd..31dfb11d 100644 --- a/app/src/main/java/org/pixeldroid/app/searchDiscover/SearchDiscoverFragment.kt +++ b/app/src/main/java/org/pixeldroid/app/searchDiscover/SearchDiscoverFragment.kt @@ -100,7 +100,7 @@ class SearchDiscoverFragment : BaseFragment() { * [RecyclerView.Adapter] that can display a list of [Status]s' thumbnails for the discover view */ class DiscoverRecyclerViewAdapter: RecyclerView.Adapter() { - private val posts: ArrayList = ArrayList() + private val posts: ArrayList = ArrayList() fun addPosts(newPosts : List) { posts.clear() @@ -116,12 +116,12 @@ class SearchDiscoverFragment : BaseFragment() { override fun onBindViewHolder(holder: ProfilePostViewHolder, position: Int) { val post = posts[position] - if(post.media_attachments?.size ?: 0 > 1) { + if(post?.media_attachments?.size ?: 0 > 1) { holder.albumIcon.visibility = View.VISIBLE } 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?.media_attachments?.firstOrNull()?.preview_url, 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)