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:
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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user