add file fetching at the search activity
This commit is contained in:
parent
10f903129d
commit
e7edb729a4
|
@ -8,14 +8,20 @@ import android.view.MenuItem
|
|||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.MenuItemCompat
|
||||
import com.simplemobiletools.gallery.pro.R
|
||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.pro.extensions.getCachedMedia
|
||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
||||
|
||||
class SearchActivity : SimpleActivity() {
|
||||
private var mIsSearchOpen = false
|
||||
private var mSearchMenuItem: MenuItem? = null
|
||||
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
||||
private var mAllMedia = ArrayList<ThumbnailItem>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_search)
|
||||
getAllMedia()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
@ -23,6 +29,11 @@ class SearchActivity : SimpleActivity() {
|
|||
mSearchMenuItem?.collapseActionView()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mCurrAsyncTask?.stopFetching()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_search, menu)
|
||||
setupSearch(menu)
|
||||
|
@ -68,4 +79,22 @@ class SearchActivity : SimpleActivity() {
|
|||
private fun textChanged(text: String) {
|
||||
|
||||
}
|
||||
|
||||
private fun getAllMedia() {
|
||||
getCachedMedia("") {
|
||||
if (it.isNotEmpty()) {
|
||||
mAllMedia = it
|
||||
}
|
||||
startAsyncTask()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startAsyncTask() {
|
||||
mCurrAsyncTask?.stopFetching()
|
||||
mCurrAsyncTask = GetMediaAsynctask(applicationContext, "", showAll = true) {
|
||||
mAllMedia = it
|
||||
}
|
||||
|
||||
mCurrAsyncTask!!.execute()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue