Fix issue with list adapter.

This commit is contained in:
Amine Bou 2018-01-12 06:24:06 +01:00
parent 0d007f1492
commit ec71ab3c6f

View File

@ -67,7 +67,6 @@ class ItemListAdapter(
val itm = items[position] val itm = items[position]
holder.mView.favButton.isLiked = itm.starred
holder.mView.title.text = Html.fromHtml(itm.title) holder.mView.title.text = Html.fromHtml(itm.title)
holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText() holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText()
@ -108,11 +107,16 @@ class ItemListAdapter(
c.bitmapCenterCrop(itm.getThumbnail(c), holder.mView.itemImage) c.bitmapCenterCrop(itm.getThumbnail(c), holder.mView.itemImage)
} }
// TODO: maybe handle this differently. It crashes when changing tab
try {
if (bars[position]) { if (bars[position]) {
holder.mView.actionBar.visibility = View.VISIBLE holder.mView.actionBar.visibility = View.VISIBLE
} else { } else {
holder.mView.actionBar.visibility = View.GONE holder.mView.actionBar.visibility = View.GONE
} }
} catch (e: IndexOutOfBoundsException) {
holder.mView.actionBar.visibility = View.GONE
}
holder.mView.favButton.isLiked = itm.starred holder.mView.favButton.isLiked = itm.starred
} }