fix crash in AccountMediaFragment (again)

main
Conny Duck 6 years ago
parent f8423aa10b
commit e6270f1a5e
  1. 22
      app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt

@ -36,6 +36,7 @@ import com.keylesspalace.tusky.entity.Attachment
import com.keylesspalace.tusky.entity.Status import com.keylesspalace.tusky.entity.Status
import com.keylesspalace.tusky.network.MastodonApi import com.keylesspalace.tusky.network.MastodonApi
import com.keylesspalace.tusky.util.ThemeUtils import com.keylesspalace.tusky.util.ThemeUtils
import com.keylesspalace.tusky.util.visible
import com.keylesspalace.tusky.view.SquareImageView import com.keylesspalace.tusky.view.SquareImageView
import com.keylesspalace.tusky.viewdata.AttachmentViewData import com.keylesspalace.tusky.viewdata.AttachmentViewData
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
@ -92,17 +93,18 @@ class AccountMediaFragment : BaseFragment(), Injectable {
if(isAdded) { if(isAdded) {
swipe_refresh_layout.isRefreshing = false swipe_refresh_layout.isRefreshing = false
progress_bar.visibility = View.GONE progress_bar.visibility = View.GONE
}
val body = response.body() val body = response.body()
body?.let { fetched -> body?.let { fetched ->
statuses.addAll(0, fetched) statuses.addAll(0, fetched)
// flatMap requires iterable but I don't want to box each array into list // flatMap requires iterable but I don't want to box each array into list
val result = mutableListOf<AttachmentViewData>() val result = mutableListOf<AttachmentViewData>()
for (status in fetched) { for (status in fetched) {
result.addAll(AttachmentViewData.list(status)) result.addAll(AttachmentViewData.list(status))
}
adapter.addTop(result)
nothing_message.visible(statuses.isEmpty())
} }
adapter.addTop(result)
nothing_message.visibility = if (statuses.isEmpty()) View.VISIBLE else View.GONE
} }
} }
} }

Loading…
Cancel
Save