// 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;
        }

        void animateFromDefaultPosition(Runnable endAction) {
            disposable.dispose();
            disposable = LayoutHelper.onLayout(() -> animateFromDefaultToInitial(false, endAction));
        }

        void animateToDefaultPosition(Runnable endAction) {
            disposable.dispose();
            disposable = LayoutHelper.onLayout(() -> animateFromDefaultToInitial(true, endAction));
        }

        private void animateFromDefaultToInitial(boolean reversed, Runnable endAction) {
            initParentRect();
            animator.cancel();

            final int paddingValue = view.getResources().getDimensionPixelSize(paddingRes);
            final int startX = parent.right - paddingValue;
            final int startY = parent.top + paddingValue;

            final PositionStorage.Position position = positionStorage.getPosition(DEFAULT_X, DEFAULT_Y);
            final int targetX = (int) (parent.left + parent.width() * position.x);
            final int targetY = (int) (parent.top + parent.height() * position.y);

            if (reversed) {
                animator = createMoveAnimator(view, targetX, targetY, startX, startY);
            } else {
                animator = createMoveAnimator(view, startX, startY, targetX, targetY);
            }
            if (endAction != null) {
// 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;

        }

        void animateFromDefaultPosition(Runnable endAction) {
            disposable.dispose();
            disposable = LayoutHelper.onLayout(() -> animateFromDefaultToInitial(false, endAction));
        }

        void animateToDefaultPosition(Runnable endAction) {
            disposable.dispose();
            disposable = LayoutHelper.onLayout(() -> animateFromDefaultToInitial(true, endAction));
        }

        private void animateFromDefaultToInitial(boolean reversed, Runnable endAction) {
            initParentRect();
            animator.cancel();

            final int paddingValue = view.getResources().getDimensionPixelSize(paddingRes);
            final int startX = parent.right - paddingValue;
            final int startY = parent.top + paddingValue;

            final PositionStorage.Position position = positionStorage.getPosition(DEFAULT_X, DEFAULT_Y);
            final int targetX = (int) (parent.left + parent.width() * position.x);
            final int targetY = (int) (parent.top + parent.height() * position.y);

            if (reversed) {
                animator = createMoveAnimator(view, targetX, targetY, startX, startY);
            } else {
                animator = createMoveAnimator(view, startX, startY, targetX, targetY);
            }
            if (endAction != null) {
                animator.addListener(SimpleAnimatorListener.createEndListener(endAction));