mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 08:18:00 +01:00
update Commons with the recyclerview adapter, fix some inconsistency glitches
This commit is contained in:
parent
132953c25a
commit
f1b4391d93
5 changed files with 27 additions and 21 deletions
|
@ -47,7 +47,7 @@ ext {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
implementation 'com.android.support:multidex:1.0.3'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
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 getActionMenuId() = R.menu.cab_directories
|
||||||
|
|
||||||
override fun prepareItemSelection(view: View) {
|
override fun prepareItemSelection(viewHolder: ViewHolder) {
|
||||||
view.dir_check?.background?.applyColorFilter(primaryColor)
|
viewHolder.itemView.dir_check?.background?.applyColorFilter(primaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun markItemSelection(select: Boolean, view: View?) {
|
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
||||||
view?.dir_check?.beVisibleIf(select)
|
viewHolder?.itemView?.dir_check?.beVisibleIf(select)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
@ -234,17 +234,23 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
affectedPositions.sortedDescending().forEach {
|
affectedPositions.sortedDescending().forEach {
|
||||||
notifyItemRemoved(it)
|
notifyItemRemoved(it)
|
||||||
itemViews.put(it, null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val newItems = SparseArray<View>()
|
val newViewHolders = SparseArray<ViewHolder>()
|
||||||
(0 until itemViews.size())
|
val cnt = viewHolders.size()
|
||||||
.filter { itemViews[it] != null }
|
for (i in 0..cnt) {
|
||||||
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
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()
|
currentDirectoriesHash = newDirs.hashCode()
|
||||||
itemViews = newItems
|
|
||||||
dirs = newDirs
|
dirs = newDirs
|
||||||
|
|
||||||
finishActMode()
|
finishActMode()
|
||||||
fastScroller?.measureRecyclerView()
|
fastScroller?.measureRecyclerView()
|
||||||
listener?.updateDirectories(newDirs)
|
listener?.updateDirectories(newDirs)
|
||||||
|
|
|
@ -25,10 +25,10 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<
|
||||||
|
|
||||||
override fun prepareActionMode(menu: Menu) {}
|
override fun prepareActionMode(menu: Menu) {}
|
||||||
|
|
||||||
override fun prepareItemSelection(view: View) {}
|
override fun prepareItemSelection(viewHolder: ViewHolder) {}
|
||||||
|
|
||||||
override fun markItemSelection(select: Boolean, view: View?) {
|
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
||||||
view?.manage_folder_holder?.isSelected = select
|
viewHolder?.itemView?.manage_folder_holder?.isSelected = select
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun actionItemPressed(id: Int) {
|
override fun actionItemPressed(id: Int) {
|
||||||
|
|
|
@ -27,10 +27,10 @@ class ManageHiddenFoldersAdapter(activity: BaseSimpleActivity, var folders: Arra
|
||||||
|
|
||||||
override fun prepareActionMode(menu: Menu) {}
|
override fun prepareActionMode(menu: Menu) {}
|
||||||
|
|
||||||
override fun prepareItemSelection(view: View) {}
|
override fun prepareItemSelection(viewHolder: ViewHolder) {}
|
||||||
|
|
||||||
override fun markItemSelection(select: Boolean, view: View?) {
|
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
||||||
view?.manage_folder_holder?.isSelected = select
|
viewHolder?.itemView?.manage_folder_holder?.isSelected = select
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun actionItemPressed(id: Int) {
|
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 getActionMenuId() = R.menu.cab_media
|
||||||
|
|
||||||
override fun prepareItemSelection(view: View) {
|
override fun prepareItemSelection(viewHolder: ViewHolder) {
|
||||||
view.medium_check?.background?.applyColorFilter(primaryColor)
|
viewHolder.itemView?.medium_check?.background?.applyColorFilter(primaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun markItemSelection(select: Boolean, view: View?) {
|
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
||||||
view?.medium_check?.beVisibleIf(select)
|
viewHolder?.itemView?.medium_check?.beVisibleIf(select)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
|
Loading…
Reference in a new issue