// Path: library/src/main/java/com/jpeng/jptabbar/DensityUtils.java
// public class DensityUtils {
// 
//     public static int dp2sp(Context context, float dipValue) {
//         float pxValue = dp2px(context, dipValue);
//         return px2sp(context, pxValue);
//     }
// 
//     public static int sp2dp(@NonNull Context context, float spValue) {
//         float pxValue = sp2px(context, spValue);
//         return px2dp(context, pxValue);
//     }
// 
//     public static int px2dp(@NonNull Context context, float pxValue) {
//         final float scale = context.getResources().getDisplayMetrics().density;
//         return (int) (pxValue / scale);
//     }
// 
//     public static int dp2px(@NonNull Context context, float dipValue) {
//         final float scale = context.getResources().getDisplayMetrics().density;
//         return (int) (dipValue * scale);
//     }
// 
//     public static int px2sp(@NonNull Context context, float pxValue) {
//         final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
//         return (int) (pxValue / fontScale);
//     }
// 
//     public static int sp2px(@NonNull Context context, float spValue) {
//         final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
//         return (int) (spValue * fontScale);
//     }
// 
// }


import android.graphics.*;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Interpolator;
import com.jpeng.jptabbar.DensityUtils;
import com.nineoldandroids.animation.ValueAnimator;
import java.util.Random;
/**
 * Copyright 2015 bingoogolapple
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.jpeng.jptabbar.badgeview;



/**
 * Author jpeng
 * Date: 16-11-15
 * E-mail:peng8350@gmail.com
 * 徽章爆炸动画
 */
public class ExplosionAnimator extends ValueAnimator {
    public static final int ANIM_DURATION = 300;
    private static final Interpolator DEFAULT_INTERPOLATOR = new AccelerateInterpolator(0.6f);
    private static final float END_VALUE = 1.4f;
    private static final int REFRESH_RATIO = 3;
    private static float X;
    private static float Y;
    private static float V;
    private static float W;

    private Particle[] mParticles;
    private Paint mPaint;
    private DragBadgeView mDragBadgeView;
    private Rect mRect;
    private Rect mInvalidateRect;

    public ExplosionAnimator(DragBadgeView dragBadgeView, Rect rect, Bitmap bitmap) {
        setFloatValues(0.0f, END_VALUE);
        setDuration(ANIM_DURATION);
        setInterpolator(DEFAULT_INTERPOLATOR);

// Path: library/src/main/java/com/jpeng/jptabbar/DensityUtils.java
// public class DensityUtils {
// 
//     public static int dp2sp(Context context, float dipValue) {
//         float pxValue = dp2px(context, dipValue);
//         return px2sp(context, pxValue);
//     }
// 
//     public static int sp2dp(@NonNull Context context, float spValue) {
//         float pxValue = sp2px(context, spValue);
//         return px2dp(context, pxValue);
//     }
// 
//     public static int px2dp(@NonNull Context context, float pxValue) {
//         final float scale = context.getResources().getDisplayMetrics().density;
//         return (int) (pxValue / scale);
//     }
// 
//     public static int dp2px(@NonNull Context context, float dipValue) {
//         final float scale = context.getResources().getDisplayMetrics().density;
//         return (int) (dipValue * scale);
//     }
// 
//     public static int px2sp(@NonNull Context context, float pxValue) {
//         final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
//         return (int) (pxValue / fontScale);
//     }
// 
//     public static int sp2px(@NonNull Context context, float spValue) {
//         final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
//         return (int) (spValue * fontScale);
//     }
// 
// }


// Path: library/src/main/java/com/jpeng/jptabbar/badgeview/ExplosionAnimator.java
import android.graphics.*;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Interpolator;
import com.jpeng.jptabbar.DensityUtils;
import com.nineoldandroids.animation.ValueAnimator;
import java.util.Random;

/**
 * Copyright 2015 bingoogolapple
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.jpeng.jptabbar.badgeview;



/**
 * Author jpeng
 * Date: 16-11-15
 * E-mail:peng8350@gmail.com
 * 徽章爆炸动画
 */
public class ExplosionAnimator extends ValueAnimator {
    public static final int ANIM_DURATION = 300;
    private static final Interpolator DEFAULT_INTERPOLATOR = new AccelerateInterpolator(0.6f);
    private static final float END_VALUE = 1.4f;
    private static final int REFRESH_RATIO = 3;
    private static float X;
    private static float Y;
    private static float V;
    private static float W;

    private Particle[] mParticles;
    private Paint mPaint;
    private DragBadgeView mDragBadgeView;
    private Rect mRect;
    private Rect mInvalidateRect;

    public ExplosionAnimator(DragBadgeView dragBadgeView, Rect rect, Bitmap bitmap) {
        setFloatValues(0.0f, END_VALUE);
        setDuration(ANIM_DURATION);
        setInterpolator(DEFAULT_INTERPOLATOR);

        X = DensityUtils.dp2px(dragBadgeView.getContext(), 5);