always pass an arraylist clone to adapters, so the actual items arent updated
This commit is contained in:
parent
dd11f99382
commit
642e3e4c50
|
@ -809,7 +809,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showSortedDirs(dirs: ArrayList<Directory>) {
|
private fun showSortedDirs(dirs: ArrayList<Directory>) {
|
||||||
var sortedDirs = getSortedDirectories(dirs).clone() as ArrayList<Directory>
|
var sortedDirs = getSortedDirectories(dirs)
|
||||||
sortedDirs = sortedDirs.distinctBy { it.path.getDistinctPath() } as ArrayList<Directory>
|
sortedDirs = sortedDirs.distinctBy { it.path.getDistinctPath() } as ArrayList<Directory>
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
|
@ -847,11 +847,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
|
|
||||||
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, directories, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) {
|
DirectoryAdapter(this, dirs.clone() as ArrayList<Directory>, 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)
|
||||||
|
@ -861,7 +860,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
directories_grid.adapter = this
|
directories_grid.adapter = this
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as DirectoryAdapter).updateDirs(directories)
|
(currAdapter as DirectoryAdapter).updateDirs(dirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
getRecyclerAdapter()?.dirs?.apply {
|
getRecyclerAdapter()?.dirs?.apply {
|
||||||
|
|
|
@ -338,7 +338,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
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, mMedia.clone() as ArrayList<ThumbnailItem>, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent,
|
||||||
|
mAllowPickingMultiple, media_grid, fastscroller) {
|
||||||
if (it is Medium) {
|
if (it is Medium) {
|
||||||
itemClicked(it.path)
|
itemClicked(it.path)
|
||||||
}
|
}
|
||||||
|
@ -806,7 +807,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
mLatestMediaId = getLatestMediaId()
|
mLatestMediaId = getLatestMediaId()
|
||||||
mLatestMediaDateId = getLatestMediaByDateId()
|
mLatestMediaDateId = getLatestMediaByDateId()
|
||||||
if (!isFromCache) {
|
if (!isFromCache) {
|
||||||
val mediaToInsert = (mMedia.clone() as ArrayList<ThumbnailItem>).filter { it is Medium && it.deletedTS == 0L }.map { it as Medium }
|
val mediaToInsert = (mMedia).filter { it is Medium && it.deletedTS == 0L }.map { it as Medium }
|
||||||
galleryDB.MediumDao().insertAll(mediaToInsert)
|
galleryDB.MediumDao().insertAll(mediaToInsert)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,9 +474,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateDirs(newDirs: ArrayList<Directory>) {
|
fun updateDirs(newDirs: ArrayList<Directory>) {
|
||||||
if (newDirs.hashCode() != currentDirectoriesHash) {
|
val directories = newDirs.clone() as ArrayList<Directory>
|
||||||
currentDirectoriesHash = newDirs.hashCode()
|
if (directories.hashCode() != currentDirectoriesHash) {
|
||||||
dirs = newDirs
|
currentDirectoriesHash = directories.hashCode()
|
||||||
|
dirs = directories
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
finishActMode()
|
finishActMode()
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,10 +342,11 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
private fun getSelectedPaths() = getSelectedMedia().map { it.path } as ArrayList<String>
|
private fun getSelectedPaths() = getSelectedMedia().map { it.path } as ArrayList<String>
|
||||||
|
|
||||||
fun updateMedia(newMedia: ArrayList<ThumbnailItem>) {
|
fun updateMedia(newMedia: ArrayList<ThumbnailItem>) {
|
||||||
if (newMedia.hashCode() != currentMediaHash) {
|
val thumbnailItems = newMedia.clone() as ArrayList<ThumbnailItem>
|
||||||
currentMediaHash = newMedia.hashCode()
|
if (thumbnailItems.hashCode() != currentMediaHash) {
|
||||||
|
currentMediaHash = thumbnailItems.hashCode()
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
media = newMedia
|
media = thumbnailItems
|
||||||
enableInstantLoad()
|
enableInstantLoad()
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
finishActMode()
|
finishActMode()
|
||||||
|
|
|
@ -61,7 +61,7 @@ class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: Stri
|
||||||
return
|
return
|
||||||
|
|
||||||
shownDirectories = dirs
|
shownDirectories = dirs
|
||||||
val adapter = DirectoryAdapter(activity, dirs, null, view.directories_grid, true) {
|
val adapter = DirectoryAdapter(activity, dirs.clone() as ArrayList<Directory>, null, view.directories_grid, true) {
|
||||||
if ((it as Directory).path.trimEnd('/') == sourcePath) {
|
if ((it as Directory).path.trimEnd('/') == sourcePath) {
|
||||||
activity.toast(R.string.source_and_destination_same)
|
activity.toast(R.string.source_and_destination_same)
|
||||||
return@DirectoryAdapter
|
return@DirectoryAdapter
|
||||||
|
|
|
@ -64,7 +64,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
|
||||||
return
|
return
|
||||||
|
|
||||||
shownMedia = media
|
shownMedia = media
|
||||||
val adapter = MediaAdapter(activity, shownMedia, null, true, false, view.media_grid, null) {
|
val adapter = MediaAdapter(activity, shownMedia.clone() as ArrayList<ThumbnailItem>, null, true, false, view.media_grid, null) {
|
||||||
if (it is Medium) {
|
if (it is Medium) {
|
||||||
callback(it.path)
|
callback(it.path)
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
|
Loading…
Reference in New Issue