Skip to content
Open
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.kongqw.rockerlibrary.view;

public class AngelConstants {
// 角度
public static final double ANGLE_0 = 0;
public static final double ANGLE_360 = 360;

// 360°水平方向平分2份的边缘角度
public static final double ANGLE_HORIZONTAL_2D_OF_0P = 90;
public static final double ANGLE_HORIZONTAL_2D_OF_1P = 270;

// 360°垂直方向平分2份的边缘角度
public static final double ANGLE_VERTICAL_2D_OF_0P = 0;
public static final double ANGLE_VERTICAL_2D_OF_1P = 180;

// 360°平分4份的边缘角度
public static final double ANGLE_4D_OF_0P = 0;
public static final double ANGLE_4D_OF_1P = 90;
public static final double ANGLE_4D_OF_2P = 180;
public static final double ANGLE_4D_OF_3P = 270;

// 360°平分4份的边缘角度(旋转45度)
public static final double ANGLE_ROTATE45_4D_OF_0P = 45;
public static final double ANGLE_ROTATE45_4D_OF_1P = 135;
public static final double ANGLE_ROTATE45_4D_OF_2P = 225;
public static final double ANGLE_ROTATE45_4D_OF_3P = 315;

// 360°平分8份的边缘角度
public static final double ANGLE_8D_OF_0P = 22.5;
public static final double ANGLE_8D_OF_1P = 67.5;
public static final double ANGLE_8D_OF_2P = 112.5;
public static final double ANGLE_8D_OF_3P = 157.5;
public static final double ANGLE_8D_OF_4P = 202.5;
public static final double ANGLE_8D_OF_5P = 247.5;
public static final double ANGLE_8D_OF_6P = 292.5;
public static final double ANGLE_8D_OF_7P = 337.5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.kongqw.rockerlibrary.view;

/**
* 回调模式
*/
public enum CallBackMode {
/**
* 有移动就立刻回调
*/
CALL_BACK_MODE_MOVE,
/**
* 只有状态变化的时候才回调
*/
CALL_BACK_MODE_STATE_CHANGE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.kongqw.rockerlibrary.view;

/**
* 方向
*/
public enum Direction {
/**
* 左
*/
DIRECTION_LEFT,
/**
* 右
*/
DIRECTION_RIGHT,
/**
* 上
*/
DIRECTION_UP,
/**
* 下
*/
DIRECTION_DOWN,
/**
* 左上
*/
DIRECTION_UP_LEFT,
/**
* 右上
*/
DIRECTION_UP_RIGHT,
/**
* 左下
*/
DIRECTION_DOWN_LEFT,
/**
* 右下
*/
DIRECTION_DOWN_RIGHT,
/**
* 中间
*/
DIRECTION_CENTER
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.kongqw.rockerlibrary.view;

/**
* 摇杆支持几个方向
*/
public enum DirectionMode {
/**
* <img src="https://img-blog.csdn.net/20160901183144896">
*/
DIRECTION_2_HORIZONTAL,// 横向 左右两个方向
/**
* <img src="https://img-blog.csdn.net/20160901183332084">
*/
DIRECTION_2_VERTICAL, // 纵向 上下两个方向
/**
* <img src="https://img-blog.csdn.net/20160901183347055">
*/
DIRECTION_4_ROTATE_0, // 四个方向
/**
* <img src="https://img-blog.csdn.net/20160901183404461">
*/
DIRECTION_4_ROTATE_45, // 四个方向 旋转45度
/**
* <img src="https://img-blog.csdn.net/20160901183419477">
*/
DIRECTION_8 // 八个方向
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.kongqw.rockerlibrary.view;

import static com.kongqw.rockerlibrary.view.AngelConstants.ANGLE_0;
import static com.kongqw.rockerlibrary.view.AngelConstants.ANGLE_360;

public class JudgmentUtil {
/**
* 判断当前角度是否处于某多个区间
* 判断targetAngle是否处于 0度-firstAngle度区间 以及 secondAngle度-360度 区间内
*
* @param targetAngle 当前角度
* @param firstAngle 区间左边的角度
* @param secondAngle 区间右边的角度
* @return 是否当前角度是否处于某多个区间
*/
public static boolean multiConditionJudgmentIsInRange(double targetAngle, double firstAngle, double secondAngle) {
return judgmentIsInRange(targetAngle, ANGLE_0, firstAngle) || judgmentIsInRange(targetAngle, secondAngle, ANGLE_360);
}

/**
* 判断当前角度是否处于某个区间
*
* @param targetAngle 当前角度
* @param smallAngle 区间左边的角度
* @param bigAngle 区间右边的角度
* @return 是否当前角度是否处于某个区间
*/
public static boolean judgmentIsInRange(double targetAngle, double smallAngle, double bigAngle) {
return smallAngle <= targetAngle && bigAngle > targetAngle;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.kongqw.rockerlibrary.view;

/**
* 摇动角度的监听接口
*/
public interface OnAngleChangeListener {
// 开始
void onStart();

/**
* 摇杆角度变化
*
* @param angle 角度[0,360)
*/
void angle(double angle);

// 结束
void onFinish();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.kongqw.rockerlibrary.view;

/**
* 摇动方向监听接口
*/
public interface OnShakeListener {
// 开始
void onStart();

/**
* 摇动方向
*
* @param direction 方向
*/
void direction(Direction direction);

// 结束
void onFinish();
}
Loading