show the swipeRefreshLayout spinner at loading images after filtering change

This commit is contained in:
tibbi 2017-08-28 23:12:07 +02:00
parent 141953338e
commit ab35c970b9
2 changed files with 6 additions and 4 deletions

View file

@ -183,7 +183,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mIsGettingDirs = true
val dirs = getCachedDirectories()
if (dirs.isNotEmpty() && !mLoadedInitialPhotos) {
gotDirectories(dirs)
gotDirectories(dirs, true)
}
if (!mLoadedInitialPhotos) {
@ -205,6 +205,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private fun showFilterMediaDialog() {
FilterMediaDialog(this) {
directories_refresh_layout.isRefreshing = true
getDirectories()
}
}
@ -389,7 +390,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
}
private fun gotDirectories(dirs: ArrayList<Directory>) {
private fun gotDirectories(dirs: ArrayList<Directory>, isFromCache: Boolean = false) {
mLastMediaModified = getLastMediaModified()
directories_refresh_layout.isRefreshing = false
mIsGettingDirs = false

View file

@ -237,6 +237,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private fun showFilterMediaDialog() {
FilterMediaDialog(this) {
media_refresh_layout.isRefreshing = true
getMedia()
}
}
@ -304,7 +305,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
val token = object : TypeToken<List<Medium>>() {}.type
val media = Gson().fromJson<ArrayList<Medium>>(config.loadFolderMedia(mPath), token) ?: ArrayList<Medium>(1)
if (media.isNotEmpty() && !mLoadedInitialPhotos) {
gotMedia(media)
gotMedia(media, true)
} else {
media_refresh_layout.isRefreshing = true
}
@ -453,7 +454,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
}
private fun gotMedia(media: ArrayList<Medium>) {
private fun gotMedia(media: ArrayList<Medium>, isFromCache: Boolean = false) {
mLastMediaModified = getLastMediaModified()
mIsGettingMedia = false
media_refresh_layout.isRefreshing = false