Fixed issue with read/unread cont when swiping.
This commit is contained in:
parent
6d7c4b40f6
commit
722b6cc06d
@ -247,14 +247,18 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
val i = items.elementAtOrNull(position)
|
||||
|
||||
if (i != null) {
|
||||
val adapter = recyclerView.adapter
|
||||
val adapter = recyclerView.adapter as ItemsAdapter<*>
|
||||
|
||||
when (adapter) {
|
||||
is ItemCardAdapter -> adapter.handleItemAtIndex(position)
|
||||
is ItemListAdapter -> adapter.handleItemAtIndex(position)
|
||||
val wasItemUnread = adapter.unreadItemStatusAtIndex(position)
|
||||
|
||||
adapter.handleItemAtIndex(position)
|
||||
|
||||
if (wasItemUnread) {
|
||||
badgeNew--
|
||||
} else {
|
||||
badgeNew++
|
||||
}
|
||||
|
||||
badgeNew--
|
||||
reloadBadgeContent()
|
||||
|
||||
val tagHashes = i.tags.tags.split(",").map { it.longHash() }
|
||||
|
@ -132,15 +132,17 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte
|
||||
}
|
||||
|
||||
fun handleItemAtIndex(position: Int) {
|
||||
val i = items[position]
|
||||
|
||||
if (i.unread) {
|
||||
if (unreadItemStatusAtIndex(position)) {
|
||||
readItemAtIndex(position)
|
||||
} else {
|
||||
unreadItemAtIndex(position)
|
||||
}
|
||||
}
|
||||
|
||||
fun unreadItemStatusAtIndex(position: Int): Boolean {
|
||||
return items[position].unread
|
||||
}
|
||||
|
||||
private fun readItemAtIndex(position: Int) {
|
||||
val i = items[position]
|
||||
items.remove(i)
|
||||
|
Loading…
Reference in New Issue
Block a user