redraw selected subscription list items individually
This commit is contained in:
parent
9656f9147c
commit
5f75a263d9
2 changed files with 11 additions and 6 deletions
|
@ -538,7 +538,6 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
|||
finishActionMode()
|
||||
} else {
|
||||
actionMode!!.title = adapter.selected.size.toString()
|
||||
redrawList()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,8 +592,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
|||
|
||||
private fun beginActionMode(subscription: Subscription) {
|
||||
actionMode = startActionMode(this)
|
||||
adapter.selected.add(subscription.id)
|
||||
redrawList()
|
||||
adapter.toggleSelection(subscription.id)
|
||||
|
||||
// Fade out FAB
|
||||
fab.alpha = 1f
|
||||
|
@ -647,9 +645,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
|||
if (!this::mainList.isInitialized) {
|
||||
return
|
||||
}
|
||||
runOnUiThread {
|
||||
mainList.adapter = adapter // Oh, what a hack ...
|
||||
}
|
||||
adapter.notifyItemRangeChanged(0, adapter.currentList.size)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.heckel.ntfy.ui
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -46,6 +47,12 @@ class MainAdapter(private val repository: Repository, private val onClick: (Subs
|
|||
} else {
|
||||
selected.add(subscriptionId)
|
||||
}
|
||||
|
||||
if (selected.size != 0) {
|
||||
val listIds = currentList.map { subscription -> subscription.id }
|
||||
val subscriptionPosition = listIds.indexOf(subscriptionId)
|
||||
notifyItemChanged(subscriptionPosition)
|
||||
}
|
||||
}
|
||||
|
||||
/* ViewHolder for Topic, takes in the inflated view and the onClick behavior. */
|
||||
|
@ -111,6 +118,8 @@ class MainAdapter(private val repository: Repository, private val onClick: (Subs
|
|||
itemView.setOnLongClickListener { onLongClick(subscription); true }
|
||||
if (selected.contains(subscription.id)) {
|
||||
itemView.setBackgroundResource(Colors.itemSelectedBackground(context))
|
||||
} else {
|
||||
itemView.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue