Fetch drafts on a background thread
This commit is contained in:
parent
6e7dbb9056
commit
2fc70b2dc5
1 changed files with 12 additions and 6 deletions
|
|
@ -40,7 +40,9 @@ class ConversationsAdapter(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
setupDragListener(true)
|
||||||
|
ensureBackgroundThread {
|
||||||
fetchDrafts(drafts)
|
fetchDrafts(drafts)
|
||||||
|
}
|
||||||
setHasStableIds(true)
|
setHasStableIds(true)
|
||||||
|
|
||||||
registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||||
|
|
@ -314,13 +316,17 @@ class ConversationsAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateDrafts() {
|
fun updateDrafts() {
|
||||||
|
ensureBackgroundThread {
|
||||||
val newDrafts = HashMap<Long, String?>()
|
val newDrafts = HashMap<Long, String?>()
|
||||||
fetchDrafts(newDrafts)
|
fetchDrafts(newDrafts)
|
||||||
if (drafts.hashCode() != newDrafts.hashCode()) {
|
if (drafts.hashCode() != newDrafts.hashCode()) {
|
||||||
drafts = newDrafts
|
drafts = newDrafts
|
||||||
|
activity.runOnUiThread {
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, conversation: Conversation) {
|
private fun setupView(view: View, conversation: Conversation) {
|
||||||
view.apply {
|
view.apply {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue