mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-30 03:36:44 +01:00
properly handle item refreshing at the search screen
This commit is contained in:
parent
49510884b7
commit
b2cd19109f
1 changed files with 10 additions and 2 deletions
|
@ -30,6 +30,8 @@ import kotlinx.android.synthetic.main.activity_search.*
|
|||
|
||||
class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||
private var mIsSearchOpen = false
|
||||
private var mLastSearchedText = ""
|
||||
|
||||
private var mSearchMenuItem: MenuItem? = null
|
||||
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
||||
private var mAllMedia = ArrayList<ThumbnailItem>()
|
||||
|
@ -63,6 +65,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
|||
|
||||
override fun onQueryTextChange(newText: String): Boolean {
|
||||
if (mIsSearchOpen) {
|
||||
mLastSearchedText = newText
|
||||
textChanged(newText)
|
||||
}
|
||||
return true
|
||||
|
@ -80,6 +83,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
|||
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
|
||||
if (mIsSearchOpen) {
|
||||
mIsSearchOpen = false
|
||||
mLastSearchedText = ""
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -267,20 +271,24 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
|||
runOnUiThread {
|
||||
setupAdapter()
|
||||
}
|
||||
startAsyncTask()
|
||||
startAsyncTask(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startAsyncTask() {
|
||||
private fun startAsyncTask(updateItems: Boolean) {
|
||||
mCurrAsyncTask?.stopFetching()
|
||||
mCurrAsyncTask = GetMediaAsynctask(applicationContext, "", showAll = true) {
|
||||
mAllMedia = it.clone() as ArrayList<ThumbnailItem>
|
||||
if (updateItems) {
|
||||
textChanged(mLastSearchedText)
|
||||
}
|
||||
}
|
||||
|
||||
mCurrAsyncTask!!.execute()
|
||||
}
|
||||
|
||||
override fun refreshItems() {
|
||||
startAsyncTask(true)
|
||||
}
|
||||
|
||||
override fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
||||
|
|
Loading…
Reference in a new issue