migrate IOUtils to Kotlin (#2763)

* migrate `IOUtils` to Kotlin

* Fix ktlint

* change functions inside IOUtils to extension function
This commit is contained in:
Abrar Wiryawan 2022-11-08 02:10:06 +07:00 committed by GitHub
commit c0a06f7188
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 77 additions and 81 deletions

View file

@ -75,7 +75,7 @@ fun getImageSquarePixels(contentResolver: ContentResolver, uri: Uri): Long {
options.inJustDecodeBounds = true
BitmapFactory.decodeStream(input, null, options)
IOUtils.closeQuietly(input)
input.closeQuietly()
return (options.outWidth * options.outHeight).toLong()
}
@ -158,11 +158,11 @@ fun getImageOrientation(uri: Uri, contentResolver: ContentResolver): Int {
exifInterface = ExifInterface(inputStream)
} catch (e: IOException) {
Log.w(TAG, e)
IOUtils.closeQuietly(inputStream)
inputStream.closeQuietly()
return ExifInterface.ORIENTATION_UNDEFINED
}
val orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
IOUtils.closeQuietly(inputStream)
inputStream.closeQuietly()
return orientation
}