Fix a crash when trying to access with size of a Photo (#347)

* Fix a crash when trying to access the size of a Photo
This commit is contained in:
Nicklas Ansman Giertz
2019-02-20 12:32:01 -05:00
committed by Dionysis Lorentzos
parent b37c3df8c9
commit f05fc12039
@@ -27,22 +27,20 @@ data class Photo(
/**
* The height of the photo.
*/
val height by lazy { decodedBounds.height }
val height: Int
get() = decodedBounds.outHeight
/**
* The width of the photo.
*/
val width by lazy { decodedBounds.width }
val width: Int
get() = decodedBounds.outWidth
private val decodedBounds by lazy {
BitmapFactory.decodeByteArray(
encodedImage,
0,
encodedImage.size,
BitmapFactory.Options().apply {
inJustDecodeBounds = true
}
)
BitmapFactory.Options().apply {
inJustDecodeBounds = true
BitmapFactory.decodeByteArray(encodedImage, 0, encodedImage.size, this)
}
}
override fun equals(other: Any?): Boolean {
@@ -73,4 +71,4 @@ data class Photo(
internal fun empty(): Photo = EMPTY
}
}
}