@@ -10,13 +10,13 @@ import androidx.appcompat.view.ActionMode
10
10
import androidx.core.content.ContextCompat
11
11
import androidx.recyclerview.widget.LinearLayoutManager
12
12
import com.michaelflisar.dragselectrecyclerview.DragSelectTouchListener
13
- import com.mikepenz.aboutlibraries.util.getThemeColor
14
13
import com.mikepenz.fastadapter.*
15
14
import com.mikepenz.fastadapter.adapters.FastItemAdapter
16
15
import com.mikepenz.fastadapter.adapters.GenericFastItemAdapter
17
16
import com.mikepenz.fastadapter.app.databinding.ActivitySampleBinding
18
17
import com.mikepenz.fastadapter.app.items.HeaderSelectionItem
19
18
import com.mikepenz.fastadapter.app.items.expandable.SimpleSubItem
19
+ import com.mikepenz.fastadapter.app.utils.getThemeColor
20
20
import com.mikepenz.fastadapter.expandable.ExpandableExtension
21
21
import com.mikepenz.fastadapter.expandable.getExpandableExtension
22
22
import com.mikepenz.fastadapter.helpers.ActionModeHelper
@@ -79,7 +79,12 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
79
79
mRangeSelectorHelper.onLongClick(position)
80
80
if (actionMode != null ) {
81
81
// we want color our CAB
82
- this @ExpandableMultiselectDeleteSampleActivity.findViewById<View >(R .id.action_mode_bar).setBackgroundColor(this @ExpandableMultiselectDeleteSampleActivity.getThemeColor(R .attr.colorPrimary, ContextCompat .getColor(this , R .color.colorPrimary)))
82
+ this @ExpandableMultiselectDeleteSampleActivity.findViewById<View >(R .id.action_mode_bar).setBackgroundColor(
83
+ this @ExpandableMultiselectDeleteSampleActivity.getThemeColor(
84
+ R .attr.colorPrimary,
85
+ ContextCompat .getColor(this , R .color.colorPrimary)
86
+ )
87
+ )
83
88
84
89
// start the drag selection
85
90
mDragSelectTouchListener.startDragSelection(position)
@@ -91,24 +96,24 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
91
96
92
97
// provide a custom title provider that even shows the count of sub items
93
98
mActionModeHelper = ActionModeHelper (fastItemAdapter, R .menu.cab, ActionBarCallBack ())
94
- .withTitleProvider(object : ActionModeHelper .ActionModeTitleProvider {
95
- override fun getTitle (selected : Int ): String {
96
- return selected.toString() + " /" + SubItemUtil .countItems(fastItemAdapter.itemAdapter, false )
97
- }
98
- })
99
+ .withTitleProvider(object : ActionModeHelper .ActionModeTitleProvider {
100
+ override fun getTitle (selected : Int ): String {
101
+ return selected.toString() + " /" + SubItemUtil .countItems(fastItemAdapter.itemAdapter, false )
102
+ }
103
+ })
99
104
100
105
// this will take care of selecting range of items via long press on the first and afterwards on the last item
101
106
mRangeSelectorHelper = RangeSelectorHelper (fastItemAdapter)
102
- .withSavedInstanceState(savedInstanceState)
103
- .withActionModeHelper(mActionModeHelper)
107
+ .withSavedInstanceState(savedInstanceState)
108
+ .withActionModeHelper(mActionModeHelper)
104
109
105
110
// setup the drag select listener and add it to the RecyclerView
106
111
mDragSelectTouchListener = DragSelectTouchListener ()
107
- .withSelectListener { start, end, isSelected ->
108
- mRangeSelectorHelper.selectRange(start, end, isSelected, true )
109
- // we handled the long press, so we reset the range selector
110
- mRangeSelectorHelper.reset()
111
- }
112
+ .withSelectListener { start, end, isSelected ->
113
+ mRangeSelectorHelper.selectRange(start, end, isSelected, true )
114
+ // we handled the long press, so we reset the range selector
115
+ mRangeSelectorHelper.reset()
116
+ }
112
117
binding.rv.addOnItemTouchListener(mDragSelectTouchListener)
113
118
114
119
// do basic RecyclerView setup
@@ -123,19 +128,19 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
123
128
val expandableItem = HeaderSelectionItem ()
124
129
expandableItem.withSubSelectionProvider { SubItemUtil .countSelectedSubItems(fastItemAdapter, expandableItem) }
125
130
expandableItem
126
- .withName(" Test " + (i + 1 ))
127
- .withDescription(" ID: " + (i + 1 ))
128
- .identifier = (i + 1 ).toLong()
131
+ .withName(" Test " + (i + 1 ))
132
+ .withDescription(" ID: " + (i + 1 ))
133
+ .identifier = (i + 1 ).toLong()
129
134
// .withIsExpanded(true) don't use this in such a setup, use adapter.expand() to expand all items instead
130
135
131
136
// add subItems so we can showcase the collapsible functionality
132
137
val subItems = LinkedList <ISubItem <* >>()
133
138
for (ii in 1 .. 5 ) {
134
139
val sampleItem = SimpleSubItem ()
135
140
sampleItem
136
- .withName(" -- Test " + (i + 1 ) + " ." + ii)
137
- .withDescription(" ID: " + ((i + 1 ) * 100 + ii))
138
- .identifier = ((i + 1 ) * 100 + ii).toLong()
141
+ .withName(" -- Test " + (i + 1 ) + " ." + ii)
142
+ .withDescription(" ID: " + ((i + 1 ) * 100 + ii))
143
+ .identifier = ((i + 1 ) * 100 + ii).toLong()
139
144
subItems.add(sampleItem)
140
145
}
141
146
expandableItem.subItems = subItems
@@ -144,9 +149,9 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
144
149
} else {
145
150
val sampleItem = SimpleSubItem ()
146
151
sampleItem
147
- .withName(" Test " + (i + 1 ))
148
- .withDescription(" ID: " + (i + 1 ))
149
- .identifier = (i + 1 ).toLong()
152
+ .withName(" Test " + (i + 1 ))
153
+ .withDescription(" ID: " + (i + 1 ))
154
+ .identifier = (i + 1 ).toLong()
150
155
items.add(sampleItem)
151
156
}
152
157
}
0 commit comments