use a thread pool executor for the asynctasks

This commit is contained in:
tibbi 2017-04-04 18:16:34 +02:00
parent 5d0ff30e67
commit 9c0cecc76f
3 changed files with 6 additions and 3 deletions

View file

@ -5,6 +5,7 @@ import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.AsyncTask
import android.os.Bundle
import android.provider.MediaStore
import android.support.v4.app.ActivityCompat
@ -175,7 +176,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) {
gotDirectories(it)
}
mCurrAsyncTask!!.execute()
mCurrAsyncTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
}
private fun showSortingDialog() {

View file

@ -5,6 +5,7 @@ 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
@ -230,7 +231,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
mCurrAsyncTask = GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mShowAll) {
gotMedia(it)
}
mCurrAsyncTask!!.execute()
mCurrAsyncTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
}
private fun isDirEmpty(): Boolean {

View file

@ -11,6 +11,7 @@ import android.graphics.Matrix
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
@ -414,7 +415,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
invalidateOptionsMenu()
checkOrientation()
}
mCurrAsyncTask!!.execute()
mCurrAsyncTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
}
private fun getProperPosition(): Int {