diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 554d4f80b..d2dbba586 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -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() - 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 { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 358f1e1ca..5d100a63e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -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() 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 { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt index 949ccd7d6..d8aec86d3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -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) -> Unit) : AsyncTask() { - var shouldStop = false var media = ArrayList() 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) {