add file fetching at the search activity
This commit is contained in:
parent
10f903129d
commit
e7edb729a4
1 changed files with 29 additions and 0 deletions
|
@ -8,14 +8,20 @@ import android.view.MenuItem
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.view.MenuItemCompat
|
import androidx.core.view.MenuItemCompat
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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() {
|
class SearchActivity : SimpleActivity() {
|
||||||
private var mIsSearchOpen = false
|
private var mIsSearchOpen = false
|
||||||
private var mSearchMenuItem: MenuItem? = null
|
private var mSearchMenuItem: MenuItem? = null
|
||||||
|
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
||||||
|
private var mAllMedia = ArrayList<ThumbnailItem>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_search)
|
setContentView(R.layout.activity_search)
|
||||||
|
getAllMedia()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
@ -23,6 +29,11 @@ class SearchActivity : SimpleActivity() {
|
||||||
mSearchMenuItem?.collapseActionView()
|
mSearchMenuItem?.collapseActionView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
mCurrAsyncTask?.stopFetching()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_search, menu)
|
menuInflater.inflate(R.menu.menu_search, menu)
|
||||||
setupSearch(menu)
|
setupSearch(menu)
|
||||||
|
@ -68,4 +79,22 @@ class SearchActivity : SimpleActivity() {
|
||||||
private fun textChanged(text: String) {
|
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 a new issue