package com.lvla.android.animation_progress_bar;

import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.animation.DecelerateInterpolator;
import android.widget.ProgressBar;

import com.nineoldandroids.animation.ObjectAnimator;

/**
 * Created by lvla on 2016/04/13.
 */
public class AnimationProgressBar extends ProgressBar {
    public AnimationProgressBar(Context context) {
        super(context);
    }

    public AnimationProgressBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public AnimationProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setProgress(int progress, int animationDurationMilliSec) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            android.animation.ObjectAnimator animator
                    = android.animation.ObjectAnimator.ofInt(this, "progress", progress);
            animator.setDuration(animationDurationMilliSec);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.start();
        } else {
            ObjectAnimator animator = ObjectAnimator.ofInt(this, "progress", progress);
            animator.setDuration(animationDurationMilliSec);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.start();
        }
    }
}


@@ -62,48 +62,75 @@
 oid.
-content.Context;%0Aimport android.os.Build
+animation.ObjectAnimator;%0Aimport android.animation.TimeInterpolator
 ;%0Aim
@@ -146,24 +146,22 @@
 oid.
-util.AttributeSe
+content.Contex
 t;%0Ai
@@ -178,133 +178,59 @@
 oid.
-view.animation.DecelerateInterpolator;%0Aimport android.widget.ProgressBar;%0A%0Aimport com.nineoldandroids.animation.ObjectAnimato
+util.AttributeSet;%0Aimport android.widget.ProgressBa
 r;%0A%0A
@@ -327,16 +327,111 @@
 ssBar %7B%0A
+    private ObjectAnimator animator = null;%0A    private TimeInterpolator interpolator = null;%0A%0A
     publ
@@ -777,227 +777,197 @@
  set
-Progress(int progress, int animationDurationMilliSec) %7B%0A        if(Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.HONEYCOMB) %7B
+Interpolator(TimeInterpolator interpolator) %7B%0A        this.interpolator = interpolator;
 %0A    
+%7D%0A%0A
     
-    android.animation.ObjectAnimator animator%0A                    = android.
+public void setProgress(int progress, int animationDurationMilliSec) %7B%0A        
 animat
-ion.
+or = 
 Obje
@@ -1012,36 +1012,32 @@
 gress);%0A        
-  
-  
 animator.setDura
@@ -1061,32 +1061,67 @@
 ationMilliSec);%0A
+        if(interpolator != null) %7B%0A
             anim
@@ -1137,39 +1137,25 @@
 nterpolator(
-new DecelerateI
+i
 nterpolator(
@@ -1149,33 +1149,37 @@
 interpolator
-()
 );%0A    
+    %7D%0A
         anim
@@ -1196,268 +1196,94 @@
 ();%0A
-    
     %7D
- else %7B%0A            ObjectAnimator animator = ObjectAnimator.ofInt(this, %22progress%22, progress);%0A            animator.setDuration(animationDurationMilliSec);%0A            animator.setInterpolator(new DecelerateInterpolator());%0A            animator.start
+%0A%0A    public void end() %7B%0A        if(animator != null) %7B%0A            animator.end
 ();%0A

Add methods to end animation, set a interpolator