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 {
|
class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private var mIsSearchOpen = false
|
private var mIsSearchOpen = false
|
||||||
|
private var mLastSearchedText = ""
|
||||||
|
|
||||||
private var mSearchMenuItem: MenuItem? = null
|
private var mSearchMenuItem: MenuItem? = null
|
||||||
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
||||||
private var mAllMedia = ArrayList<ThumbnailItem>()
|
private var mAllMedia = ArrayList<ThumbnailItem>()
|
||||||
|
@ -63,6 +65,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
|
|
||||||
override fun onQueryTextChange(newText: String): Boolean {
|
override fun onQueryTextChange(newText: String): Boolean {
|
||||||
if (mIsSearchOpen) {
|
if (mIsSearchOpen) {
|
||||||
|
mLastSearchedText = newText
|
||||||
textChanged(newText)
|
textChanged(newText)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -80,6 +83,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
|
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
|
||||||
if (mIsSearchOpen) {
|
if (mIsSearchOpen) {
|
||||||
mIsSearchOpen = false
|
mIsSearchOpen = false
|
||||||
|
mLastSearchedText = ""
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -267,20 +271,24 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
setupAdapter()
|
setupAdapter()
|
||||||
}
|
}
|
||||||
startAsyncTask()
|
startAsyncTask(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startAsyncTask() {
|
private fun startAsyncTask(updateItems: Boolean) {
|
||||||
mCurrAsyncTask?.stopFetching()
|
mCurrAsyncTask?.stopFetching()
|
||||||
mCurrAsyncTask = GetMediaAsynctask(applicationContext, "", showAll = true) {
|
mCurrAsyncTask = GetMediaAsynctask(applicationContext, "", showAll = true) {
|
||||||
mAllMedia = it.clone() as ArrayList<ThumbnailItem>
|
mAllMedia = it.clone() as ArrayList<ThumbnailItem>
|
||||||
|
if (updateItems) {
|
||||||
|
textChanged(mLastSearchedText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurrAsyncTask!!.execute()
|
mCurrAsyncTask!!.execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshItems() {
|
override fun refreshItems() {
|
||||||
|
startAsyncTask(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
override fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue