update Commons with the recyclerview adapter, fix some inconsistency glitches
This commit is contained in:
parent
132953c25a
commit
f1b4391d93
|
@ -47,7 +47,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:4.1.17'
|
||||
implementation 'com.simplemobiletools:commons:4.2.1'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||
|
|
|
@ -47,12 +47,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
|
||||
override fun getActionMenuId() = R.menu.cab_directories
|
||||
|
||||
override fun prepareItemSelection(view: View) {
|
||||
view.dir_check?.background?.applyColorFilter(primaryColor)
|
||||
override fun prepareItemSelection(viewHolder: ViewHolder) {
|
||||
viewHolder.itemView.dir_check?.background?.applyColorFilter(primaryColor)
|
||||
}
|
||||
|
||||
override fun markItemSelection(select: Boolean, view: View?) {
|
||||
view?.dir_check?.beVisibleIf(select)
|
||||
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
||||
viewHolder?.itemView?.dir_check?.beVisibleIf(select)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
|
@ -234,17 +234,23 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
activity.runOnUiThread {
|
||||
affectedPositions.sortedDescending().forEach {
|
||||
notifyItemRemoved(it)
|
||||
itemViews.put(it, null)
|
||||
}
|
||||
|
||||
val newItems = SparseArray<View>()
|
||||
(0 until itemViews.size())
|
||||
.filter { itemViews[it] != null }
|
||||
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
||||
val newViewHolders = SparseArray<ViewHolder>()
|
||||
val cnt = viewHolders.size()
|
||||
for (i in 0..cnt) {
|
||||
if (affectedPositions.contains(i)) {
|
||||
continue
|
||||
}
|
||||
|
||||
val view = viewHolders.get(i, null)
|
||||
val newIndex = i - selectedPositions.count { it <= i }
|
||||
newViewHolders.put(newIndex, view)
|
||||
}
|
||||
viewHolders = newViewHolders
|
||||
currentDirectoriesHash = newDirs.hashCode()
|
||||
itemViews = newItems
|
||||
dirs = newDirs
|
||||
|
||||
finishActMode()
|
||||
fastScroller?.measureRecyclerView()
|
||||
listener?.updateDirectories(newDirs)
|
||||
|
|
|
@ -25,10 +25,10 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<
|
|||
|
||||
override fun prepareActionMode(menu: Menu) {}
|
||||
|
||||
override fun prepareItemSelection(view: View) {}
|
||||
override fun prepareItemSelection(viewHolder: ViewHolder) {}
|
||||
|
||||
override fun markItemSelection(select: Boolean, view: View?) {
|
||||
view?.manage_folder_holder?.isSelected = select
|
||||
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
||||
viewHolder?.itemView?.manage_folder_holder?.isSelected = select
|
||||
}
|
||||
|
||||
override fun actionItemPressed(id: Int) {
|
||||
|
|
|
@ -27,10 +27,10 @@ class ManageHiddenFoldersAdapter(activity: BaseSimpleActivity, var folders: Arra
|
|||
|
||||
override fun prepareActionMode(menu: Menu) {}
|
||||
|
||||
override fun prepareItemSelection(view: View) {}
|
||||
override fun prepareItemSelection(viewHolder: ViewHolder) {}
|
||||
|
||||
override fun markItemSelection(select: Boolean, view: View?) {
|
||||
view?.manage_folder_holder?.isSelected = select
|
||||
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
||||
viewHolder?.itemView?.manage_folder_holder?.isSelected = select
|
||||
}
|
||||
|
||||
override fun actionItemPressed(id: Int) {
|
||||
|
|
|
@ -49,12 +49,12 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
|
||||
override fun getActionMenuId() = R.menu.cab_media
|
||||
|
||||
override fun prepareItemSelection(view: View) {
|
||||
view.medium_check?.background?.applyColorFilter(primaryColor)
|
||||
override fun prepareItemSelection(viewHolder: ViewHolder) {
|
||||
viewHolder.itemView?.medium_check?.background?.applyColorFilter(primaryColor)
|
||||
}
|
||||
|
||||
override fun markItemSelection(select: Boolean, view: View?) {
|
||||
view?.medium_check?.beVisibleIf(select)
|
||||
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
||||
viewHolder?.itemView?.medium_check?.beVisibleIf(select)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
|
|
Loading…
Reference in New Issue