// 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.content.Context;
import android.graphics.*;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.OvershootInterpolator;
import com.jpeng.jptabbar.DensityUtils;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.AnimatorListenerAdapter;
import com.nineoldandroids.animation.ValueAnimator;
import java.lang.ref.WeakReference;
        super(context);
        mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        mBadgeViewHelper = badgeViewHelper;
        initBadgePaint();
        initLayoutParams();
        initStick();

        mSetExplosionAnimatorNullTask = new SetExplosionAnimatorNullTask(this);
    }

    private void initBadgePaint() {
        mBadgePaint = new Paint();
        mBadgePaint.setAntiAlias(true);
        mBadgePaint.setStyle(Paint.Style.FILL);
        // 设置mBadgeText居中，保证mBadgeText长度为1时，文本也能居中
        mBadgePaint.setTextAlign(Paint.Align.CENTER);
        mBadgePaint.setTextSize(mBadgeViewHelper.getBadgeTextSize());
    }

    private void initLayoutParams() {
        mLayoutParams = new WindowManager.LayoutParams();
        mLayoutParams.gravity = Gravity.LEFT + Gravity.TOP;
        mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        mLayoutParams.format = PixelFormat.TRANSLUCENT;
        mLayoutParams.type = WindowManager.LayoutParams.TYPE_TOAST;
        mLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        mLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
    }

    private void initStick() {
// 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/DragBadgeView.java
import android.content.Context;
import android.graphics.*;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.OvershootInterpolator;
import com.jpeng.jptabbar.DensityUtils;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.AnimatorListenerAdapter;
import com.nineoldandroids.animation.ValueAnimator;
import java.lang.ref.WeakReference;

        super(context);
        mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        mBadgeViewHelper = badgeViewHelper;
        initBadgePaint();
        initLayoutParams();
        initStick();

        mSetExplosionAnimatorNullTask = new SetExplosionAnimatorNullTask(this);
    }

    private void initBadgePaint() {
        mBadgePaint = new Paint();
        mBadgePaint.setAntiAlias(true);
        mBadgePaint.setStyle(Paint.Style.FILL);
        // 设置mBadgeText居中，保证mBadgeText长度为1时，文本也能居中
        mBadgePaint.setTextAlign(Paint.Align.CENTER);
        mBadgePaint.setTextSize(mBadgeViewHelper.getBadgeTextSize());
    }

    private void initLayoutParams() {
        mLayoutParams = new WindowManager.LayoutParams();
        mLayoutParams.gravity = Gravity.LEFT + Gravity.TOP;
        mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        mLayoutParams.format = PixelFormat.TRANSLUCENT;
        mLayoutParams.type = WindowManager.LayoutParams.TYPE_TOAST;
        mLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        mLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
    }

    private void initStick() {
        mMaxDragRadius = DensityUtils.dp2px(getContext(), 11);