do not store actual item array lists in adapters, pass clones only
This commit is contained in:
parent
43a6ececba
commit
cc5fbecabd
4 changed files with 8 additions and 6 deletions
|
@ -757,10 +757,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
private fun setupAdapter(dirs: ArrayList<Directory>) {
|
||||
val currAdapter = directories_grid.adapter
|
||||
val directories = dirs.clone() as ArrayList<Directory>
|
||||
if (currAdapter == null) {
|
||||
initZoomListener()
|
||||
val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller
|
||||
DirectoryAdapter(this, dirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) {
|
||||
DirectoryAdapter(this, directories, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) {
|
||||
val path = (it as Directory).path
|
||||
if (path != config.tempFolderPath) {
|
||||
itemClicked(path)
|
||||
|
@ -770,7 +771,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
directories_grid.adapter = this
|
||||
}
|
||||
} else {
|
||||
(currAdapter as DirectoryAdapter).updateDirs(dirs)
|
||||
(currAdapter as DirectoryAdapter).updateDirs(directories)
|
||||
}
|
||||
|
||||
setupScrollDirection()
|
||||
|
|
|
@ -312,18 +312,19 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
return
|
||||
}
|
||||
|
||||
val media = mMedia.clone() as ArrayList<Medium>
|
||||
val currAdapter = media_grid.adapter
|
||||
if (currAdapter == null) {
|
||||
initZoomListener()
|
||||
val fastscroller = if (config.scrollHorizontally) media_horizontal_fastscroller else media_vertical_fastscroller
|
||||
MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid, fastscroller) {
|
||||
MediaAdapter(this, media, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid, fastscroller) {
|
||||
itemClicked((it as Medium).path)
|
||||
}.apply {
|
||||
setupZoomListener(mZoomListener)
|
||||
media_grid.adapter = this
|
||||
}
|
||||
} else {
|
||||
(currAdapter as MediaAdapter).updateMedia(mMedia)
|
||||
(currAdapter as MediaAdapter).updateMedia(media)
|
||||
}
|
||||
setupScrollDirection()
|
||||
}
|
||||
|
|
|
@ -409,7 +409,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
fun updateDirs(newDirs: ArrayList<Directory>) {
|
||||
if (newDirs.hashCode() != currentDirectoriesHash) {
|
||||
currentDirectoriesHash = newDirs.hashCode()
|
||||
dirs = newDirs.clone() as ArrayList<Directory>
|
||||
dirs = newDirs
|
||||
notifyDataSetChanged()
|
||||
finishActMode()
|
||||
fastScroller?.measureRecyclerView()
|
||||
|
|
|
@ -288,7 +288,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
if (newMedia.hashCode() != currentMediaHash) {
|
||||
currentMediaHash = newMedia.hashCode()
|
||||
Handler().postDelayed({
|
||||
media = newMedia.clone() as ArrayList<Medium>
|
||||
media = newMedia
|
||||
enableInstantLoad()
|
||||
notifyDataSetChanged()
|
||||
finishActMode()
|
||||
|
|
Loading…
Reference in a new issue