delete invalid files from cache at loading thumbnails
This commit is contained in:
parent
b7a19908c7
commit
b64f164742
1 changed files with 10 additions and 2 deletions
|
@ -585,7 +585,15 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
mCurrAsyncTask?.stopFetching()
|
mCurrAsyncTask?.stopFetching()
|
||||||
mCurrAsyncTask = GetMediaAsynctask(applicationContext, mPath, mIsGetImageIntent, mIsGetVideoIntent, mShowAll) {
|
mCurrAsyncTask = GetMediaAsynctask(applicationContext, mPath, mIsGetImageIntent, mIsGetVideoIntent, mShowAll) {
|
||||||
Thread {
|
Thread {
|
||||||
gotMedia(it)
|
val oldMedia = mMedia.clone() as ArrayList<ThumbnailItem>
|
||||||
|
val newMedia = it
|
||||||
|
gotMedia(newMedia, false)
|
||||||
|
try {
|
||||||
|
oldMedia.filter { !newMedia.contains(it) }.mapNotNull { it as? Medium }.filter { !File(it.path).exists() }.forEach {
|
||||||
|
mMediumDao.deleteMediumPath(it.path)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,7 +828,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotMedia(media: ArrayList<ThumbnailItem>, isFromCache: Boolean = false) {
|
private fun gotMedia(media: ArrayList<ThumbnailItem>, isFromCache: Boolean) {
|
||||||
mIsGettingMedia = false
|
mIsGettingMedia = false
|
||||||
checkLastMediaChanged()
|
checkLastMediaChanged()
|
||||||
mMedia = media
|
mMedia = media
|
||||||
|
|
Loading…
Reference in a new issue