diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt index 7cda8cc21..6c3d75c65 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt @@ -107,7 +107,7 @@ class FocusIndicatorView val imageSize = this.imageSize val focus = this.focus - if (imageSize != null && focus != null) { + if (imageSize != null && focus?.x != null && focus.y != null) { val x = axisFromFocus(focus.x, imageSize.x, this.width) val y = axisFromFocus(-focus.y, imageSize.y, this.height) val circleRadius = getCircleRadius() diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt index 564ba3dad..553d6a8b3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt @@ -71,8 +71,8 @@ data class Attachment( @JsonClass(generateAdapter = true) @Parcelize data class Focus( - val x: Float, - val y: Float + val x: Float?, + val y: Float? ) : Parcelable { fun toMastodonApiString(): String = "$x,$y" } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/FocalPointUtil.kt b/app/src/main/java/com/keylesspalace/tusky/util/FocalPointUtil.kt index d26d70cef..28bfdd694 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/FocalPointUtil.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/FocalPointUtil.kt @@ -72,9 +72,9 @@ object FocalPointUtil { var top = 0f var left = 0f if (isVerticalCrop(viewWidth, viewHeight, imageWidth, imageHeight)) { - top = focalOffset(viewHeight, imageHeight, scale, focalYToCoordinate(focus.y)) + top = focalOffset(viewHeight, imageHeight, scale, focalYToCoordinate(focus.y ?: 0f)) } else { // horizontal crop - left = focalOffset(viewWidth, imageWidth, scale, focalXToCoordinate(focus.x)) + left = focalOffset(viewWidth, imageWidth, scale, focalXToCoordinate(focus.x ?: 0f)) } mat.postTranslate(left, top)