// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/NumberUtil.java
// public final class NumberUtil {
//     private NumberUtil() {
//         //to hide
//     }
// 
//     public static float clipTo(float value, float min, float max) {
//         if (value < min) {
//             return min;
//         }
// 
//         if (value > max) {
//             return max;
//         }
// 
//         return value;
//     }
// }
// 
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/SimpleAnimatorListener.java
// public class SimpleAnimatorListener implements Animator.AnimatorListener {
// 
//     @Override
//     public void onAnimationStart(Animator animation) {
//         //optional
//     }
// 
//     @Override
//     public void onAnimationEnd(Animator animation) {
//         //optional
//     }
// 
//     @Override
//     public void onAnimationCancel(Animator animation) {
//         //optional
//     }
// 
//     @Override
//     public void onAnimationRepeat(Animator animation) {
//         //optional
//     }
// 
//     public static Animator.AnimatorListener createEndListener(@NonNull Runnable runnable) {
//         return new SimpleAnimatorListener() {
//             @Override
//             public void onAnimationEnd(Animator animation) {
//                 runnable.run();
//             }
//         };
//     }
// 
// }
// 
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/ViewUtil.java
// public final class ViewUtil {
//     private ViewUtil() {
//         //to hide
//     }
// 
//     public static float distance(float x1, float y1, float x2, float y2) {
//         final float dx = x1 - x2;
//         final float dy = y1 - y2;
//         return (float) Math.sqrt(dx * dx + dy * dy);
//     }
// }


import android.animation.ValueAnimator;
import android.graphics.Rect;
import android.support.annotation.DimenRes;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.animation.AccelerateDecelerateInterpolator;
import com.mindcoders.phial.internal.util.NumberUtil;
import com.mindcoders.phial.internal.util.SimpleAnimatorListener;
import com.mindcoders.phial.internal.util.ViewUtil;
                    onMoveStart(v);
                    v.setPressed(true);
                    return true;
                case MotionEvent.ACTION_MOVE:
                    animator.cancel();
                    onMove(v, event.getRawX() - initialTouchX, event.getRawY() - initialTouchY);
                    return true;
                case MotionEvent.ACTION_UP:
                    v.setPressed(false);
                    onMoveEnd(v);
                    final long downTimeMS = event.getEventTime() - startTimeMS;
                    final float halfButtonSize = Math.min(v.getHeight(), v.getWidth()) / 2f;
                    final boolean wasClicked = downTimeMS < CLICK_MAX_DURATION_MS
                            && ViewUtil.distance(initialTouchX, initialTouchY, event.getRawX(), event.getRawY()) < halfButtonSize;
                    if (wasClicked) {
                        v.performClick();
                    }
                    return true;
                default:
                    return true;
            }
        }

        private void onMoveStart(View view) {
            final LayoutParams lp = (LayoutParams) view.getLayoutParams();
            initialX = lp.x;
            initialY = lp.y;
        }

        private void onMove(View view, float dx, float dy) {
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/NumberUtil.java
// public final class NumberUtil {
//     private NumberUtil() {
//         //to hide
//     }
// 
//     public static float clipTo(float value, float min, float max) {
//         if (value < min) {
//             return min;
//         }
// 
//         if (value > max) {
//             return max;
//         }
// 
//         return value;
//     }
// }
// 
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/SimpleAnimatorListener.java
// public class SimpleAnimatorListener implements Animator.AnimatorListener {
// 
//     @Override
//     public void onAnimationStart(Animator animation) {
//         //optional
//     }
// 
//     @Override
//     public void onAnimationEnd(Animator animation) {
//         //optional
//     }
// 
//     @Override
//     public void onAnimationCancel(Animator animation) {
//         //optional
//     }
// 
//     @Override
//     public void onAnimationRepeat(Animator animation) {
//         //optional
//     }
// 
//     public static Animator.AnimatorListener createEndListener(@NonNull Runnable runnable) {
//         return new SimpleAnimatorListener() {
//             @Override
//             public void onAnimationEnd(Animator animation) {
//                 runnable.run();
//             }
//         };
//     }
// 
// }
// 
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/ViewUtil.java
// public final class ViewUtil {
//     private ViewUtil() {
//         //to hide
//     }
// 
//     public static float distance(float x1, float y1, float x2, float y2) {
//         final float dx = x1 - x2;
//         final float dy = y1 - y2;
//         return (float) Math.sqrt(dx * dx + dy * dy);
//     }
// }


// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/overlay/DragHelper.java
import android.animation.ValueAnimator;
import android.graphics.Rect;
import android.support.annotation.DimenRes;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.animation.AccelerateDecelerateInterpolator;
import com.mindcoders.phial.internal.util.NumberUtil;
import com.mindcoders.phial.internal.util.SimpleAnimatorListener;
import com.mindcoders.phial.internal.util.ViewUtil;

                    onMoveStart(v);
                    v.setPressed(true);
                    return true;
                case MotionEvent.ACTION_MOVE:
                    animator.cancel();
                    onMove(v, event.getRawX() - initialTouchX, event.getRawY() - initialTouchY);
                    return true;
                case MotionEvent.ACTION_UP:
                    v.setPressed(false);
                    onMoveEnd(v);
                    final long downTimeMS = event.getEventTime() - startTimeMS;
                    final float halfButtonSize = Math.min(v.getHeight(), v.getWidth()) / 2f;
                    final boolean wasClicked = downTimeMS < CLICK_MAX_DURATION_MS
                            && ViewUtil.distance(initialTouchX, initialTouchY, event.getRawX(), event.getRawY()) < halfButtonSize;
                    if (wasClicked) {
                        v.performClick();
                    }
                    return true;
                default:
                    return true;
            }
        }

        private void onMoveStart(View view) {
            final LayoutParams lp = (LayoutParams) view.getLayoutParams();
            initialX = lp.x;
            initialY = lp.y;
        }

        private void onMove(View view, float dx, float dy) {
            final int newX = (int) NumberUtil.clipTo(initialX + dx, parent.left, parent.right);