mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
remove the stoping feature of media getter asynctask
This commit is contained in:
parent
06fe8a669a
commit
946f143409
3 changed files with 4 additions and 16 deletions
|
@ -5,7 +5,6 @@ import android.app.WallpaperManager
|
|||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.GridLayoutManager
|
||||
import android.util.Log
|
||||
|
@ -36,7 +35,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
private val SAVE_MEDIA_CNT = 40
|
||||
|
||||
private var mMedia = ArrayList<Medium>()
|
||||
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
||||
|
||||
private var mPath = ""
|
||||
private var mIsGetImageIntent = false
|
||||
|
@ -81,7 +79,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mCurrAsyncTask?.shouldStop = true
|
||||
mIsGettingMedia = false
|
||||
media_refresh_layout.isRefreshing = false
|
||||
mStoredAnimateGifs = config.animateGifs
|
||||
|
@ -245,10 +242,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
mLoadedInitialPhotos = true
|
||||
mCurrAsyncTask = GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mShowAll) {
|
||||
GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mShowAll) {
|
||||
gotMedia(it)
|
||||
}
|
||||
mCurrAsyncTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
|
||||
}.execute()
|
||||
}
|
||||
|
||||
private fun isDirEmpty(): Boolean {
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.graphics.drawable.ColorDrawable
|
|||
import android.hardware.SensorManager
|
||||
import android.media.ExifInterface
|
||||
import android.net.Uri
|
||||
import android.os.AsyncTask
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
|
@ -46,7 +45,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
private var mMedia = ArrayList<Medium>()
|
||||
private var mPath = ""
|
||||
private var mDirectory = ""
|
||||
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
||||
|
||||
private var mIsFullScreen = false
|
||||
private var mPos = -1
|
||||
|
@ -155,7 +153,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mCurrAsyncTask?.shouldStop = true
|
||||
mOrientationEventListener.disable()
|
||||
}
|
||||
|
||||
|
@ -411,7 +408,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
|
||||
private fun reloadViewPager() {
|
||||
mCurrAsyncTask = GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
|
||||
GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
|
||||
mMedia = it
|
||||
if (isDirEmpty())
|
||||
return@GetMediaAsynctask
|
||||
|
@ -426,8 +423,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
updatePagerItems()
|
||||
invalidateOptionsMenu()
|
||||
checkOrientation()
|
||||
}
|
||||
mCurrAsyncTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
|
||||
}.execute()
|
||||
}
|
||||
|
||||
private fun getProperPosition(): Int {
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.util.*
|
|||
class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo: Boolean = false, val isPickImage: Boolean = false,
|
||||
val showAll: Boolean, val callback: (media: ArrayList<Medium>) -> Unit) :
|
||||
AsyncTask<Void, Void, Unit>() {
|
||||
var shouldStop = false
|
||||
var media = ArrayList<Medium>()
|
||||
|
||||
override fun doInBackground(vararg params: Void): Unit {
|
||||
|
@ -56,9 +55,6 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
|
|||
var isVideo: Boolean
|
||||
|
||||
do {
|
||||
if (shouldStop)
|
||||
cancel(true)
|
||||
|
||||
path = cur.getStringValue(MediaStore.Images.Media.DATA)
|
||||
size = cur.getLongValue(MediaStore.Images.Media.SIZE)
|
||||
if (size == 0L) {
|
||||
|
|
Loading…
Reference in a new issue