package com.vasya.phototransition.utils;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.vpaliy.transition.AnimatedImageView;

public class DynamicImage extends AnimatedImageView {

    private float heightRation=1.f;

    public DynamicImage(Context context) {
        super(context);
    }

    public DynamicImage(Context context, @NonNull AttributeSet attrs) {
        super(context,attrs);
    }

    public void setHeightRation(float heightRation) {
        this.heightRation = heightRation;
    }

    public float getHeightRation() {
        return heightRation;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (heightMeasureSpec > 0.0 && heightRation>0.0f) {
                int width = MeasureSpec.getSize(widthMeasureSpec);
                int height = (int) (width * heightRation);
                setMeasuredDimension(width, height);
        } else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }
}

@@ -286,45 +286,8 @@
  %7B%0A%0A
-    private float heightRation=1.f;%0A%0A
     
@@ -473,553 +473,121 @@
     
-public void setHeightRation(float heightRation) %7B%0A        this.heightRation = heightRation;%0A    %7D%0A%0A    public float getHeightRation() %7B%0A        return heightRation;%0A    %7D%0A%0A    @Override%0A    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) %7B%0A        if (heightMeasureSpec %3E 0.0 && heightRation%3E0.0f) %7B%0A                int width = MeasureSpec.getSize(widthMeasureSpec);%0A                int height = (int) (width * heightRation);%0A                setMeasuredDimension(width, height);%0A        %7D else %7B%0A            super.onMeasure
+@Override%0A    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) %7B%0A       setMeasuredDimension
 (wid
@@ -600,23 +600,21 @@
 ureSpec,
- height
+width
 MeasureS
@@ -623,18 +623,8 @@
 c);%0A
-        %7D%0A
     

Update DynamicImage.java