fix images with focal point not shown in timeline (#1256)

This commit is contained in:
Konrad Pozniak 2019-05-11 17:35:07 +02:00 committed by GitHub
parent 47104bf2cf
commit 419ae80c60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,7 +88,6 @@ defStyleAttr: Int = 0
* Overridden setScaleType method which only accepts the new type if we don't have a focal
* point set.
*
*
*/
override fun setScaleType(type: ScaleType) {
if (focus != null) {
@ -103,7 +102,7 @@ defStyleAttr: Int = 0
}
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
onSizeChanged(width, height, width, height)
recalculateMatrix(width, height, resource)
return false
}
@ -113,6 +112,12 @@ defStyleAttr: Int = 0
* matrix if we have a set focal point. It then reassigns the matrix to this imageView.
*/
override fun onSizeChanged(width: Int, height: Int, oldWidth: Int, oldHeight: Int) {
recalculateMatrix(width, height, drawable)
super.onSizeChanged(width, height, oldWidth, oldHeight)
}
private fun recalculateMatrix(width: Int, height: Int, drawable: Drawable?) {
if (drawable != null && focus != null && focalMatrix != null) {
scaleType = ScaleType.MATRIX
FocalPointUtil.updateFocalPointMatrix(width.toFloat(), height.toFloat(),
@ -120,7 +125,5 @@ defStyleAttr: Int = 0
focus as Attachment.Focus, focalMatrix as Matrix)
imageMatrix = focalMatrix
}
super.onSizeChanged(width, height, oldWidth, oldHeight)
}
}