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