赞
踩
@JvmStatic
suspend fun getImageWidthAndHeight(res: Any?): Pair<Int, Int> = suspendCancellableCoroutine { coroutine ->
Glide.with(_context).asBitmap().load(res).into(object : ICustomTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
Log.d(TAG, "onResourceReady: res $res resource width ${resource.width} height ${resource.height}")
coroutine.resume(resource.width to resource.height)
}
override fun onLoadFailed(errorDrawable: Drawable?) {
Log.d(TAG, "onLoadFailed: resource width 0 height 0")
coroutine.resume(0 to 0)
}
})
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。