Fix concurrent modification exception
This commit is contained in:
parent
2a9b5b6d85
commit
0f098fc1e1
1 changed files with 6 additions and 8 deletions
|
|
@ -30,7 +30,7 @@ abstract class BaseConversationsAdapter(
|
||||||
activity: SimpleActivity,
|
activity: SimpleActivity,
|
||||||
recyclerView: MyRecyclerView,
|
recyclerView: MyRecyclerView,
|
||||||
onRefresh: () -> Unit,
|
onRefresh: () -> Unit,
|
||||||
itemClick: (Any) -> Unit
|
itemClick: (Any) -> Unit,
|
||||||
) : MyRecyclerViewListAdapter<Conversation>(
|
) : MyRecyclerViewListAdapter<Conversation>(
|
||||||
activity = activity,
|
activity = activity,
|
||||||
recyclerView = recyclerView,
|
recyclerView = recyclerView,
|
||||||
|
|
@ -46,10 +46,8 @@ abstract class BaseConversationsAdapter(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
setupDragListener(true)
|
||||||
ensureBackgroundThread {
|
|
||||||
fetchDrafts(drafts)
|
|
||||||
}
|
|
||||||
setHasStableIds(true)
|
setHasStableIds(true)
|
||||||
|
updateDrafts()
|
||||||
|
|
||||||
registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||||
override fun onChanged() = restoreRecyclerViewState()
|
override fun onChanged() = restoreRecyclerViewState()
|
||||||
|
|
@ -69,7 +67,7 @@ abstract class BaseConversationsAdapter(
|
||||||
|
|
||||||
fun updateConversations(
|
fun updateConversations(
|
||||||
newConversations: ArrayList<Conversation>,
|
newConversations: ArrayList<Conversation>,
|
||||||
commitCallback: (() -> Unit)? = null
|
commitCallback: (() -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
saveRecyclerViewState()
|
saveRecyclerViewState()
|
||||||
submitList(newConversations.toList(), commitCallback)
|
submitList(newConversations.toList(), commitCallback)
|
||||||
|
|
@ -80,9 +78,9 @@ abstract class BaseConversationsAdapter(
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val newDrafts = HashMap<Long, String>()
|
val newDrafts = HashMap<Long, String>()
|
||||||
fetchDrafts(newDrafts)
|
fetchDrafts(newDrafts)
|
||||||
|
activity.runOnUiThread {
|
||||||
if (drafts.hashCode() != newDrafts.hashCode()) {
|
if (drafts.hashCode() != newDrafts.hashCode()) {
|
||||||
drafts = newDrafts
|
drafts = newDrafts
|
||||||
activity.runOnUiThread {
|
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue