예전에 Kotlin으로 이런 코드도 만들어 놨었네요.
도움이 되시길 바라면서 올려드리겠습니다.
object ImageLoader {
fun load(url: String): Bitmap? {
return try {
val connection = task { (URL(url).openConnection() as HttpURLConnection).also { it.connect() } }.get()
task { BitmapFactory.decodeStream(connection.inputStream) }.always { connection.disconnect() }.get()
} catch (e: Exception) {
null
}
}
}