Don't assume non null: API can send bad responses
This commit is contained in:
parent
b462ed0904
commit
358e1f7323
|
@ -88,8 +88,8 @@ class PostFeedFragment<T: FeedContentDatabase>: CachedFeedFragment<T>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
val uiModel = getItem(position) as Status
|
val uiModel = getItem(position) as Status?
|
||||||
uiModel.let {
|
uiModel?.let {
|
||||||
(holder as StatusViewHolder).bind(it, apiHolder, db, lifecycleScope, displayDimensionsInPx)
|
(holder as StatusViewHolder).bind(it, apiHolder, db, lifecycleScope, displayDimensionsInPx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,13 +91,10 @@ class UncachedPostsFragment : UncachedFeedFragment<Status>() {
|
||||||
return StatusViewHolder.create(parent)
|
return StatusViewHolder.create(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int {
|
override fun getItemViewType(position: Int): Int = R.layout.post_fragment
|
||||||
return R.layout.post_fragment
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
val uiModel = getItem(position) as Status
|
getItem(position)?.let {
|
||||||
uiModel.let {
|
|
||||||
(holder as StatusViewHolder).bind(it, apiHolder, db, lifecycleScope, displayDimensionsInPx)
|
(holder as StatusViewHolder).bind(it, apiHolder, db, lifecycleScope, displayDimensionsInPx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue