adding some recyclerview related performance optimizations

This commit is contained in:
tibbi 2018-10-20 19:18:30 +02:00
parent 7beff9a692
commit 7e6362cbfb
3 changed files with 9 additions and 7 deletions

View file

@ -48,7 +48,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.1.6'
implementation 'com.simplemobiletools:commons:5.1.10'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'

View file

@ -66,12 +66,13 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
return
}
val isOneItemSelected = isOneItemSelected()
menu.apply {
findItem(R.id.cab_rename).isVisible = isOneItemSelected() && !selectedPaths.contains(FAVORITES) && !selectedPaths.contains(RECYCLE_BIN)
findItem(R.id.cab_change_cover_image).isVisible = isOneItemSelected()
findItem(R.id.cab_rename).isVisible = isOneItemSelected && !selectedPaths.contains(FAVORITES) && !selectedPaths.contains(RECYCLE_BIN)
findItem(R.id.cab_change_cover_image).isVisible = isOneItemSelected
findItem(R.id.cab_empty_recycle_bin).isVisible = isOneItemSelected() && selectedPaths.first() == RECYCLE_BIN
findItem(R.id.cab_empty_disable_recycle_bin).isVisible = isOneItemSelected() && selectedPaths.first() == RECYCLE_BIN
findItem(R.id.cab_empty_recycle_bin).isVisible = isOneItemSelected && selectedPaths.first() == RECYCLE_BIN
findItem(R.id.cab_empty_disable_recycle_bin).isVisible = isOneItemSelected && selectedPaths.first() == RECYCLE_BIN
checkHideBtnVisibility(this, selectedPaths)
checkPinBtnVisibility(this, selectedPaths)

View file

@ -108,10 +108,11 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
return
}
val isOneItemSelected = isOneItemSelected()
val selectedPaths = selectedItems.map { it.path } as ArrayList<String>
menu.apply {
findItem(R.id.cab_rename).isVisible = isOneItemSelected() && selectedItems.firstOrNull()?.getIsInRecycleBin() == false
findItem(R.id.cab_open_with).isVisible = isOneItemSelected()
findItem(R.id.cab_rename).isVisible = isOneItemSelected && selectedItems.firstOrNull()?.getIsInRecycleBin() == false
findItem(R.id.cab_open_with).isVisible = isOneItemSelected
findItem(R.id.cab_confirm_selection).isVisible = isAGetIntent && allowMultiplePicks && selectedKeys.size > 0
findItem(R.id.cab_restore_recycle_bin_files).isVisible = selectedPaths.all { it.startsWith(activity.filesDir.absolutePath) }