Skip to content

Commit

Permalink
fix(mian):fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCShou committed Nov 5, 2022
1 parent 18908bd commit 1b87477
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
7 changes: 6 additions & 1 deletion app/src/main/java/com/zcshou/gogogo/HistoryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ private List<Map<String, Object>> fetchAllRecord() {
}

private void recordArchive() {
final double limits = Double.parseDouble(sharedPreferences.getString("setting_pos_history", getResources().getString(R.string.history_expiration)));
double limits;
try {
limits = Double.parseDouble(sharedPreferences.getString("setting_pos_history", getResources().getString(R.string.history_expiration)));
} catch (NumberFormatException e) { // GOOD: The exception is caught.
limits = 7;
}
final long weekSecond = (long) (limits * 24 * 60 * 60);

try {
Expand Down
25 changes: 20 additions & 5 deletions app/src/main/java/com/zcshou/joystick/JoyStick.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ public void onFinish() {
}
});
// 获取参数区设置的速度
mSpeed = Double.parseDouble(sharedPreferences.getString("setting_walk", getResources().getString(R.string.setting_walk_default)));

try {
mSpeed = Double.parseDouble(sharedPreferences.getString("setting_walk", getResources().getString(R.string.setting_walk_default)));
} catch (NumberFormatException e) { // GOOD: The exception is caught.
mSpeed = 1.2;
}
mJoystickLayout = inflater.inflate(R.layout.joystick, null);

/* 整个摇杆拖动事件处理 */
Expand Down Expand Up @@ -300,7 +303,11 @@ public void onFinish() {
isRun = false;
btnBike.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme()));
isBike = false;
mSpeed = Double.parseDouble(sharedPreferences.getString("setting_walk", getResources().getString(R.string.setting_walk_default)));
try {
mSpeed = Double.parseDouble(sharedPreferences.getString("setting_walk", getResources().getString(R.string.setting_walk_default)));
} catch (NumberFormatException e) { // GOOD: The exception is caught.
mSpeed = 1.2;
}
}
});
/* 默认为步行 */
Expand All @@ -317,7 +324,11 @@ public void onFinish() {
isWalk = false;
btnBike.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme()));
isBike = false;
mSpeed = Double.parseDouble(sharedPreferences.getString("setting_run", getResources().getString(R.string.setting_run_default)));
try {
mSpeed = Double.parseDouble(sharedPreferences.getString("setting_run", getResources().getString(R.string.setting_run_default)));
} catch (NumberFormatException e) { // GOOD: The exception is caught.
mSpeed = 3.6;
}
}
});
/* 自行车按键的点击处理 */
Expand All @@ -331,7 +342,11 @@ public void onFinish() {
isWalk = false;
btnRun.setColorFilter(getResources().getColor(R.color.black, mContext.getTheme()));
isRun = false;
mSpeed = Double.parseDouble(sharedPreferences.getString("setting_bike", getResources().getString(R.string.setting_bike_default)));
try {
mSpeed = Double.parseDouble(sharedPreferences.getString("setting_bike", getResources().getString(R.string.setting_bike_default)));
} catch (NumberFormatException e) { // GOOD: The exception is caught.
mSpeed = 10.0;
}
}
});
/* 方向键点击处理 */
Expand Down

0 comments on commit 1b87477

Please sign in to comment.