From ca554c998d01856225677b57086b8b9a0d367c14 Mon Sep 17 00:00:00 2001 From: ZCShou <72115@163.com> Date: Fri, 17 Jun 2022 15:25:31 +0800 Subject: [PATCH] format code --- .../java/com/zcshou/gogogo/MainActivity.java | 3 +- .../java/com/zcshou/joystick/ButtonView.java | 791 +++++++++--------- 2 files changed, 396 insertions(+), 398 deletions(-) diff --git a/app/src/main/java/com/zcshou/gogogo/MainActivity.java b/app/src/main/java/com/zcshou/gogogo/MainActivity.java index da98294..6caecdb 100644 --- a/app/src/main/java/com/zcshou/gogogo/MainActivity.java +++ b/app/src/main/java/com/zcshou/gogogo/MainActivity.java @@ -114,8 +114,7 @@ import okhttp3.OkHttpClient; import okhttp3.Response; import okhttp3.ResponseBody; -public class MainActivity extends BaseActivity - implements SensorEventListener { +public class MainActivity extends BaseActivity implements SensorEventListener { /* 对外 */ public static final String LAT_MSG_ID = "LAT_VALUE"; public static final String LNG_MSG_ID = "LNG_VALUE"; diff --git a/app/src/main/java/com/zcshou/joystick/ButtonView.java b/app/src/main/java/com/zcshou/joystick/ButtonView.java index c80c83d..5e59cbc 100644 --- a/app/src/main/java/com/zcshou/joystick/ButtonView.java +++ b/app/src/main/java/com/zcshou/joystick/ButtonView.java @@ -9,434 +9,433 @@ import android.widget.LinearLayout; import com.zcshou.gogogo.R; public class ButtonView extends LinearLayout { + private ButtonViewClickListener mListener; + private boolean isCenter = true; + private ImageButton btnCenter; + private boolean isNorth; + private ImageButton btnNorth; + private boolean isSouth; + private ImageButton btnSouth; + private boolean isWest; + private ImageButton btnWest; + private boolean isEast; + private ImageButton btnEast; + private boolean isEastNorth; + private ImageButton btnEastNorth; + private boolean isEastSouth; + private ImageButton btnEastSouth; + private boolean isWestNorth; + private ImageButton btnWestNorth; + private boolean isWestSouth; + private ImageButton btnWestSouth; + private final Context mContext; - private ButtonViewClickListener mListener; - private boolean isCenter = true; - private ImageButton btnCenter; - private boolean isNorth; - private ImageButton btnNorth; - private boolean isSouth; - private ImageButton btnSouth; - private boolean isWest; - private ImageButton btnWest; - private boolean isEast; - private ImageButton btnEast; - private boolean isEastNorth; - private ImageButton btnEastNorth; - private boolean isEastSouth; - private ImageButton btnEastSouth; - private boolean isWestNorth; - private ImageButton btnWestNorth; - private boolean isWestSouth; - private ImageButton btnWestSouth; - private final Context mContext; + public ButtonView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + mContext = context; + LayoutInflater.from(context).inflate(R.layout.joystick_button, this); - public ButtonView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - mContext = context; - LayoutInflater.from(context).inflate(R.layout.joystick_button, this); + initButtonView(); + } - initButtonView(); - } + public ButtonView(Context context, AttributeSet attrs) { + super(context, attrs); + mContext = context; - public ButtonView(Context context, AttributeSet attrs) { - super(context, attrs); - mContext = context; + LayoutInflater.from(context).inflate(R.layout.joystick_button, this); + initButtonView(); + } - LayoutInflater.from(context).inflate(R.layout.joystick_button, this); - initButtonView(); - } + public ButtonView(Context context) { + super(context); + mContext = context; - public ButtonView(Context context) { - super(context); - mContext = context; + LayoutInflater.from(context).inflate(R.layout.joystick_button, this); - LayoutInflater.from(context).inflate(R.layout.joystick_button, this); + initButtonView(); + } - initButtonView(); - } + private void initButtonView() { + btnCenter = findViewById(R.id.btn_center); + btnCenter.setOnClickListener(view -> { + if (!isCenter) { + isCenter = true; + btnCenter.setImageResource(R.drawable.ic_lock_close); + btnCenter.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + } else { + isCenter = false; + btnCenter.setImageResource(R.drawable.ic_lock_open); + btnCenter.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - private void initButtonView() { - btnCenter = findViewById(R.id.btn_center); - btnCenter.setOnClickListener(view -> { - if (!isCenter) { - isCenter = true; - btnCenter.setImageResource(R.drawable.ic_lock_close); - btnCenter.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - } else { - isCenter = false; - btnCenter.setImageResource(R.drawable.ic_lock_open); - btnCenter.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (isNorth) { + isNorth = false; + btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + } + if (isSouth) { + isSouth = false; + btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + } + if (isWest) { + isWest = false; + btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + } + if (isEast) { + isEast = false; + btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + } + if (isEastNorth) { + isEastNorth = false; + btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + } + if (isEastSouth) { + isEastSouth = false; + btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + } + if (isWestNorth) { + isWestNorth = false; + btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + } + if (isWestSouth) { + isWestSouth = false; + btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + } + if (mListener != null) { + mListener.clickAngleInfo(false,0, 0); + } + } + }); + /* 默认 */ + isCenter = true; + btnCenter.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - if (isNorth) { - isNorth = false; - btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - } - if (isSouth) { - isSouth = false; - btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - } - if (isWest) { - isWest = false; - btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - } - if (isEast) { - isEast = false; - btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - } - if (isEastNorth) { - isEastNorth = false; - btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - } - if (isEastSouth) { - isEastSouth = false; - btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - } - if (isWestNorth) { - isWestNorth = false; - btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - } - if (isWestSouth) { - isWestSouth = false; - btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - } - if (mListener != null) { - mListener.clickAngleInfo(false,0, 0); - } - } - }); - /* 默认 */ - isCenter = true; - btnCenter.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isNorth = false; + btnNorth = findViewById(R.id.btn_north); + btnNorth.setOnClickListener(view -> { + if (isCenter) { + if (!isNorth) { + isNorth = true; + btnNorth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - isNorth = false; - btnNorth = findViewById(R.id.btn_north); - btnNorth.setOnClickListener(view -> { - if (isCenter) { - if (!isNorth) { - isNorth = true; - btnNorth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isSouth = false; + btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWest = false; + btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEast = false; + btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastNorth = false; + btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastSouth = false; + btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestNorth = false; + btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestSouth = false; + btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (mListener != null) { + mListener.clickAngleInfo(true,90, 1); + } + } else { + isNorth = false; + btnNorth.setImageResource(R.drawable.ic_up); + if (mListener != null) { + mListener.clickAngleInfo(false,90, 0); + } + } + } else { + if (mListener != null) { + mListener.clickAngleInfo(false,90, 1); + } + } + }); - isSouth = false; - btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWest = false; - btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEast = false; - btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastNorth = false; - btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastSouth = false; - btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestNorth = false; - btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestSouth = false; - btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - if (mListener != null) { - mListener.clickAngleInfo(true,90, 1); - } - } else { - isNorth = false; - btnNorth.setImageResource(R.drawable.ic_up); - if (mListener != null) { - mListener.clickAngleInfo(false,90, 0); - } - } - } else { - if (mListener != null) { - mListener.clickAngleInfo(false,90, 1); - } - } - }); + isSouth = false; + btnSouth = findViewById(R.id.btn_south); + btnSouth.setOnClickListener(view -> { + if (isCenter) { + if (!isSouth) { + isSouth = true; + btnSouth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - isSouth = false; - btnSouth = findViewById(R.id.btn_south); - btnSouth.setOnClickListener(view -> { - if (isCenter) { - if (!isSouth) { - isSouth = true; - btnSouth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isNorth = false; + btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWest = false; + btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEast = false; + btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastNorth = false; + btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastSouth = false; + btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestNorth = false; + btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestSouth = false; + btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isNorth = false; - btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWest = false; - btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEast = false; - btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastNorth = false; - btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastSouth = false; - btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestNorth = false; - btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestSouth = false; - btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (mListener != null) { + mListener.clickAngleInfo(true,270, 1); + } + } else { + isSouth = false; + btnSouth.setImageResource(R.drawable.ic_down); + if (mListener != null) { + mListener.clickAngleInfo(false,270, 0); + } + } + } else { + if (mListener != null) { + mListener.clickAngleInfo(false,270, 1); + } + } + }); - if (mListener != null) { - mListener.clickAngleInfo(true,270, 1); - } - } else { - isSouth = false; - btnSouth.setImageResource(R.drawable.ic_down); - if (mListener != null) { - mListener.clickAngleInfo(false,270, 0); - } - } - } else { - if (mListener != null) { - mListener.clickAngleInfo(false,270, 1); - } - } - }); + isWest = false; + btnWest = findViewById(R.id.btn_west); + btnWest.setOnClickListener(view -> { + if (isCenter) { + if (!isWest) { + isWest = true; + btnWest.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - isWest = false; - btnWest = findViewById(R.id.btn_west); - btnWest.setOnClickListener(view -> { - if (isCenter) { - if (!isWest) { - isWest = true; - btnWest.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isSouth = false; + btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isNorth = false; + btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEast = false; + btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastNorth = false; + btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastSouth = false; + btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestNorth = false; + btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestSouth = false; + btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isSouth = false; - btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isNorth = false; - btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEast = false; - btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastNorth = false; - btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastSouth = false; - btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestNorth = false; - btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestSouth = false; - btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (mListener != null) { + mListener.clickAngleInfo(true,180, 1); + } + } else { + isWest = false; + btnWest.setImageResource(R.drawable.ic_left); + if (mListener != null) { + mListener.clickAngleInfo(false,180, 0); + } + } + } else { + if (mListener != null) { + mListener.clickAngleInfo(false,180, 1); + } + } + }); - if (mListener != null) { - mListener.clickAngleInfo(true,180, 1); - } - } else { - isWest = false; - btnWest.setImageResource(R.drawable.ic_left); - if (mListener != null) { - mListener.clickAngleInfo(false,180, 0); - } - } - } else { - if (mListener != null) { - mListener.clickAngleInfo(false,180, 1); - } - } - }); + isEast = false; + btnEast = findViewById(R.id.btn_east); + btnEast.setOnClickListener(view -> { + if (isCenter) { + if (!isEast) { + isEast = true; + btnEast.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - isEast = false; - btnEast = findViewById(R.id.btn_east); - btnEast.setOnClickListener(view -> { - if (isCenter) { - if (!isEast) { - isEast = true; - btnEast.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isSouth = false; + btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isNorth = false; + btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWest = true; + btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastNorth = false; + btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastSouth = false; + btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestNorth = false; + btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestSouth = false; + btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isSouth = false; - btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isNorth = false; - btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWest = true; - btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastNorth = false; - btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastSouth = false; - btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestNorth = false; - btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestSouth = false; - btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (mListener != null) { + mListener.clickAngleInfo(true,0, 1); + } + } else { + isEast = false; + btnEast.setImageResource(R.drawable.ic_right); + if (mListener != null) { + mListener.clickAngleInfo(false,0, 0); + } + } + } else { + if (mListener != null) { + mListener.clickAngleInfo(false,0, 1); + } + } + }); - if (mListener != null) { - mListener.clickAngleInfo(true,0, 1); - } - } else { - isEast = false; - btnEast.setImageResource(R.drawable.ic_right); - if (mListener != null) { - mListener.clickAngleInfo(false,0, 0); - } - } - } else { - if (mListener != null) { - mListener.clickAngleInfo(false,0, 1); - } - } - }); + isEastNorth = false; + btnEastNorth = findViewById(R.id.btn_north_east); + btnEastNorth.setOnClickListener(view -> { + if (isCenter) { + if (!isEastNorth) { + isEastNorth = true; + btnEastNorth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - isEastNorth = false; - btnEastNorth = findViewById(R.id.btn_north_east); - btnEastNorth.setOnClickListener(view -> { - if (isCenter) { - if (!isEastNorth) { - isEastNorth = true; - btnEastNorth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isSouth = false; + btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isNorth = false; + btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWest = true; + btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEast = false; + btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastSouth = false; + btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestNorth = false; + btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestSouth = false; + btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isSouth = false; - btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isNorth = false; - btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWest = true; - btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEast = false; - btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastSouth = false; - btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestNorth = false; - btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestSouth = false; - btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (mListener != null) { + mListener.clickAngleInfo(true,45, 1); + } + } else { + isEastNorth = false; + btnEastNorth.setImageResource(R.drawable.ic_right_up); + if (mListener != null) { + mListener.clickAngleInfo(false,45, 0); + } + } + } else { + if (mListener != null) { + mListener.clickAngleInfo(false,45, 1); + } + } + }); - if (mListener != null) { - mListener.clickAngleInfo(true,45, 1); - } - } else { - isEastNorth = false; - btnEastNorth.setImageResource(R.drawable.ic_right_up); - if (mListener != null) { - mListener.clickAngleInfo(false,45, 0); - } - } - } else { - if (mListener != null) { - mListener.clickAngleInfo(false,45, 1); - } - } - }); + isEastSouth = false; + btnEastSouth = findViewById(R.id.btn_south_east); + btnEastSouth.setOnClickListener(view -> { + if (isCenter) { + if (!isEastSouth) { + isEastSouth = true; + btnEastSouth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - isEastSouth = false; - btnEastSouth = findViewById(R.id.btn_south_east); - btnEastSouth.setOnClickListener(view -> { - if (isCenter) { - if (!isEastSouth) { - isEastSouth = true; - btnEastSouth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isSouth = false; + btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isNorth = false; + btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWest = true; + btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEast = false; + btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastNorth = false; + btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestNorth = false; + btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestSouth = false; + btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isSouth = false; - btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isNorth = false; - btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWest = true; - btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEast = false; - btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastNorth = false; - btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestNorth = false; - btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestSouth = false; - btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (mListener != null) { + mListener.clickAngleInfo(true,315, 1); + } + } else { + isEastSouth = false; + btnEastSouth.setImageResource(R.drawable.ic_right_down); + if (mListener != null) { + mListener.clickAngleInfo(false,315, 0); + } + } + } else { + if (mListener != null) { + mListener.clickAngleInfo(false,315, 1); + } + } + }); - if (mListener != null) { - mListener.clickAngleInfo(true,315, 1); - } - } else { - isEastSouth = false; - btnEastSouth.setImageResource(R.drawable.ic_right_down); - if (mListener != null) { - mListener.clickAngleInfo(false,315, 0); - } - } - } else { - if (mListener != null) { - mListener.clickAngleInfo(false,315, 1); - } - } - }); + isWestNorth = false; + btnWestNorth = findViewById(R.id.btn_north_west); + btnWestNorth.setOnClickListener(view -> { + if (isCenter) { + if (!isWestNorth) { + isWestNorth = true; + btnWestNorth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - isWestNorth = false; - btnWestNorth = findViewById(R.id.btn_north_west); - btnWestNorth.setOnClickListener(view -> { - if (isCenter) { - if (!isWestNorth) { - isWestNorth = true; - btnWestNorth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isSouth = false; + btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isNorth = false; + btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWest = true; + btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEast = false; + btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastNorth = false; + btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastSouth = false; + btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestSouth = false; + btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isSouth = false; - btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isNorth = false; - btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWest = true; - btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEast = false; - btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastNorth = false; - btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastSouth = false; - btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestSouth = false; - btnWestSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (mListener != null) { + mListener.clickAngleInfo(true,135, 1); + } + } else { + isWestNorth = false; + btnWestNorth.setImageResource(R.drawable.ic_left_up); + if (mListener != null) { + mListener.clickAngleInfo(false,135, 0); + } + } + } else { + if (mListener != null) { + mListener.clickAngleInfo(false,135, 1); + } + } + }); - if (mListener != null) { - mListener.clickAngleInfo(true,135, 1); - } - } else { - isWestNorth = false; - btnWestNorth.setImageResource(R.drawable.ic_left_up); - if (mListener != null) { - mListener.clickAngleInfo(false,135, 0); - } - } - } else { - if (mListener != null) { - mListener.clickAngleInfo(false,135, 1); - } - } - }); + isWestSouth = false; + btnWestSouth = findViewById(R.id.btn_south_west); + btnWestSouth.setOnClickListener(view -> { + if (isCenter) { + if (!isWestSouth) { + isWestSouth = true; + btnWestSouth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); - isWestSouth = false; - btnWestSouth = findViewById(R.id.btn_south_west); - btnWestSouth.setOnClickListener(view -> { - if (isCenter) { - if (!isWestSouth) { - isWestSouth = true; - btnWestSouth.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + isSouth = false; + btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isNorth = false; + btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWest = true; + btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEast = false; + btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastNorth = false; + btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isEastSouth = false; + btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + isWestNorth = false; + btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isSouth = false; - btnSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isNorth = false; - btnNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWest = true; - btnWest.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEast = false; - btnEast.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastNorth = false; - btnEastNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isEastSouth = false; - btnEastSouth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); - isWestNorth = false; - btnWestNorth.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme())); + if (mListener != null) { + mListener.clickAngleInfo(true,225, 1); + } + } else { + isWestSouth = false; + btnWestSouth.setImageResource(R.drawable.ic_left_down); + if (mListener != null) { + mListener.clickAngleInfo(false,225, 0); + } + } + } else { + if (mListener != null) { + mListener.clickAngleInfo(false,225, 1); + } + } + }); + } - if (mListener != null) { - mListener.clickAngleInfo(true,225, 1); - } - } else { - isWestSouth = false; - btnWestSouth.setImageResource(R.drawable.ic_left_down); - if (mListener != null) { - mListener.clickAngleInfo(false,225, 0); - } - } - } else { - if (mListener != null) { - mListener.clickAngleInfo(false,225, 1); - } - } - }); - } + public void setListener(ButtonViewClickListener mListener) { + this.mListener = mListener; + } - public void setListener(ButtonViewClickListener mListener) { - this.mListener = mListener; - } - - public interface ButtonViewClickListener { - /** - * 点击的角度信息 - */ - void clickAngleInfo(boolean auto, double angle, double r); - } + public interface ButtonViewClickListener { + /** + * 点击的角度信息 + */ + void clickAngleInfo(boolean auto, double angle, double r); + } }