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()
|
finishActionMode()
|
||||||
} else {
|
} else {
|
||||||
actionMode!!.title = adapter.selected.size.toString()
|
actionMode!!.title = adapter.selected.size.toString()
|
||||||
redrawList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,8 +592,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
|
|
||||||
private fun beginActionMode(subscription: Subscription) {
|
private fun beginActionMode(subscription: Subscription) {
|
||||||
actionMode = startActionMode(this)
|
actionMode = startActionMode(this)
|
||||||
adapter.selected.add(subscription.id)
|
adapter.toggleSelection(subscription.id)
|
||||||
redrawList()
|
|
||||||
|
|
||||||
// Fade out FAB
|
// Fade out FAB
|
||||||
fab.alpha = 1f
|
fab.alpha = 1f
|
||||||
|
@ -647,9 +645,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
if (!this::mainList.isInitialized) {
|
if (!this::mainList.isInitialized) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
runOnUiThread {
|
adapter.notifyItemRangeChanged(0, adapter.currentList.size)
|
||||||
mainList.adapter = adapter // Oh, what a hack ...
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.heckel.ntfy.ui
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
|
import android.graphics.Color
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -46,6 +47,12 @@ class MainAdapter(private val repository: Repository, private val onClick: (Subs
|
||||||
} else {
|
} else {
|
||||||
selected.add(subscriptionId)
|
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. */
|
/* 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 }
|
itemView.setOnLongClickListener { onLongClick(subscription); true }
|
||||||
if (selected.contains(subscription.id)) {
|
if (selected.contains(subscription.id)) {
|
||||||
itemView.setBackgroundResource(Colors.itemSelectedBackground(context))
|
itemView.setBackgroundResource(Colors.itemSelectedBackground(context))
|
||||||
|
} else {
|
||||||
|
itemView.setBackgroundColor(Color.TRANSPARENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue