count only the selectable items at MyAdapter actionmenu

This commit is contained in:
tibbi 2017-11-13 20:06:07 +01:00
parent 919b67d6e1
commit c1179639d6
4 changed files with 9 additions and 1 deletions

View file

@ -22,6 +22,8 @@ class DayEventsAdapter(activity: SimpleActivity, val events: List<Event>, val li
override fun getActionMenuId() = R.menu.cab_day
override fun getSelectableItemCount() = events.size
override fun markItemSelection(select: Boolean, pos: Int) {
itemViews[pos].event_item_frame.isSelected = select
}

View file

@ -32,6 +32,8 @@ class EventListAdapter(activity: SimpleActivity, val listItems: List<ListItem>,
override fun getActionMenuId() = R.menu.cab_event_list
override fun getSelectableItemCount() = listItems.filter { it is ListEvent }.size
override fun markItemSelection(select: Boolean, pos: Int) {
itemViews[pos]?.event_item_frame?.isSelected = select
}

View file

@ -19,6 +19,8 @@ class EventTypeAdapter(activity: SimpleActivity, val eventTypes: List<EventType>
override fun getActionMenuId() = R.menu.cab_event_type
override fun getSelectableItemCount() = eventTypes.size
override fun markItemSelection(select: Boolean, pos: Int) {
itemViews[pos].event_item_frame.isSelected = select
}

View file

@ -26,6 +26,8 @@ abstract class MyAdapter(val activity: SimpleActivity, val itemClick: (Any) -> U
abstract fun getActionMenuId(): Int
abstract fun getSelectableItemCount(): Int
abstract fun markItemSelection(select: Boolean, pos: Int)
abstract fun actionItemPressed(id: Int)
@ -50,7 +52,7 @@ abstract class MyAdapter(val activity: SimpleActivity, val itemClick: (Any) -> U
}
private fun updateTitle(cnt: Int) {
actMode?.title = "$cnt / $itemCount"
actMode?.title = "$cnt / ${getSelectableItemCount()}"
actMode?.invalidate()
}