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