1
0
mirror of https://gitlab.shinice.net/pixeldroid/PixelDroid synced 2024-12-25 06:23:58 +01:00

Don't assume non null: API can send bad responses

This commit is contained in:
Matthieu 2021-06-27 10:56:52 +02:00
parent b462ed0904
commit 358e1f7323
2 changed files with 4 additions and 7 deletions

View File

@ -88,8 +88,8 @@ class PostFeedFragment<T: FeedContentDatabase>: CachedFeedFragment<T>() {
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val uiModel = getItem(position) as Status
uiModel.let {
val uiModel = getItem(position) as Status?
uiModel?.let {
(holder as StatusViewHolder).bind(it, apiHolder, db, lifecycleScope, displayDimensionsInPx)
}
}

View File

@ -91,13 +91,10 @@ class UncachedPostsFragment : UncachedFeedFragment<Status>() {
return StatusViewHolder.create(parent)
}
override fun getItemViewType(position: Int): Int {
return R.layout.post_fragment
}
override fun getItemViewType(position: Int): Int = R.layout.post_fragment
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val uiModel = getItem(position) as Status
uiModel.let {
getItem(position)?.let {
(holder as StatusViewHolder).bind(it, apiHolder, db, lifecycleScope, displayDimensionsInPx)
}
}