diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/utils/FrameAnimatorContainer.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/utils/FrameAnimatorContainer.kt index eed566129f..82c809d15d 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/utils/FrameAnimatorContainer.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/utils/FrameAnimatorContainer.kt @@ -7,7 +7,8 @@ import android.os.Handler import android.os.Looper import android.widget.ImageView import com.mogo.commons.AbsMogoApplication -import java.lang.RuntimeException +import com.mogo.eagle.core.utilcode.mogo.logger.Logger +import com.mogo.eagle.core.utilcode.util.ThreadUtils import java.lang.ref.SoftReference class FrameAnimatorContainer (resId: Int, @@ -115,6 +116,7 @@ class FrameAnimatorContainer (resId: Int, mHandler?.removeCallbacksAndMessages(null) val runnable: Runnable = object : Runnable { override fun run() { + Logger.d(TAG, "runnable: isMainThread:${ThreadUtils.isMainThread()}, threadName=${Thread.currentThread().name}") val imageView = mSoftReferenceImageView!!.get() if (!mShouldRun || imageView == null) { mIsRunning = false @@ -136,22 +138,28 @@ class FrameAnimatorContainer (resId: Int, } mHandler?.postDelayed(this, mDelayMillis.toLong()) if (mBitmap != null) { // so Build.VERSION.SDK_INT >= 11 - var bitmap: Bitmap? = null - try { - bitmap = BitmapFactory.decodeResource( - imageView.resources, - imageRes, - mBitmapOptions - ) - } catch (e: Exception) { - e.printStackTrace() - } - if (bitmap != null) { - imageView.setImageBitmap(bitmap) - } else { - imageView.setImageResource(imageRes) - mBitmap!!.recycle() - mBitmap = null + ThreadUtils.getFixedPool(1).submit { + Logger.d(TAG, "decodeResource Runnable: isMainThread:${ThreadUtils.isMainThread()}, threadName=${Thread.currentThread().name}") + var bitmap: Bitmap? = null + try { + bitmap = BitmapFactory.decodeResource( + imageView.resources, + imageRes, + mBitmapOptions + ) + } catch (e: Exception) { + e.printStackTrace() + } + ThreadUtils.runOnUiThread({ + Logger.d(TAG, "setImageBitmap Runnable: isMainThread:${ThreadUtils.isMainThread()}, threadName=${Thread.currentThread().name}") + if (bitmap != null) { + imageView.setImageBitmap(bitmap) + } else { + imageView.setImageResource(imageRes) + mBitmap!!.recycle() + mBitmap = null + } + }, ThreadUtils.MODE.QUEUE) } } else { imageView.setImageResource(imageRes)