@@ -57,8 +57,14 @@ import java.util.LinkedList
5757import java.util.Locale
5858
5959class ItemsAdapter (
60- activity : SimpleActivity , var listItems : MutableList <ListItem >, val listener : ItemOperationsListener ? , recyclerView : MyRecyclerView ,
61- val isPickMultipleIntent : Boolean , val swipeRefreshLayout : SwipeRefreshLayout ? , canHaveIndividualViewType : Boolean = true , itemClick : (Any ) -> Unit
60+ activity : SimpleActivity ,
61+ var listItems : MutableList <ListItem >,
62+ private val listener : ItemOperationsListener ? ,
63+ recyclerView : MyRecyclerView ,
64+ private val isPickMultipleIntent : Boolean ,
65+ private val swipeRefreshLayout : SwipeRefreshLayout ? ,
66+ canHaveIndividualViewType : Boolean = true ,
67+ itemClick : (Any ) -> Unit ,
6268) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
6369
6470 private lateinit var fileDrawable: Drawable
@@ -401,12 +407,12 @@ class ItemsAdapter(
401407 val firstFile = files[0 ]
402408 val source = firstFile.getParentPath()
403409 FilePickerDialog (
404- activity,
405- activity.getDefaultCopyDestinationPath(config.shouldShowHidden(), source),
406- false ,
407- config.shouldShowHidden(),
408- true ,
409- true ,
410+ activity = activity ,
411+ currPath = activity.getDefaultCopyDestinationPath(config.shouldShowHidden(), source),
412+ pickFile = false ,
413+ showHidden = config.shouldShowHidden(),
414+ showFAB = true ,
415+ canAddShowHiddenButton = true ,
410416 showFavoritesButton = true
411417 ) {
412418 config.lastCopyPath = it
@@ -749,28 +755,32 @@ class ItemsAdapter(
749755 return
750756 }
751757
752- activity.handleSAFDialog(SAFPath ) {
753- if (! it ) {
758+ activity.handleSAFDialog(SAFPath ) { granted ->
759+ if (! granted ) {
754760 return @handleSAFDialog
755761 }
756762
757763 val files = ArrayList <FileDirItem >(selectedKeys.size)
758764 val positions = ArrayList <Int >()
759- selectedKeys.forEach {
760- config.removeFavorite(getItemWithKey(it)?.path ? : " " )
761- val key = it
762- val position = listItems.indexOfFirst { it.path.hashCode() == key }
763- if (position != - 1 ) {
764- positions.add(position)
765- files.add(listItems[position])
765+
766+ ensureBackgroundThread {
767+ selectedKeys.forEach { key ->
768+ config.removeFavorite(getItemWithKey(key)?.path ? : " " )
769+ val position = listItems.indexOfFirst { it.path.hashCode() == key }
770+ if (position != - 1 ) {
771+ positions.add(position)
772+ files.add(listItems[position])
773+ }
766774 }
767- }
768775
769- positions.sortDescending()
770- removeSelectedItems(positions)
771- listener?.deleteFiles(files)
772- positions.forEach {
773- listItems.removeAt(it)
776+ positions.sortDescending()
777+ activity.runOnUiThread {
778+ removeSelectedItems(positions)
779+ listener?.deleteFiles(files)
780+ positions.forEach {
781+ listItems.removeAt(it)
782+ }
783+ }
774784 }
775785 }
776786 }
0 commit comments