Skip to content

Commit

Permalink
fixed back to current pace
Browse files Browse the repository at this point in the history
  • Loading branch information
SNURO committed Nov 8, 2023
1 parent a673006 commit 4914b27
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,33 @@ public void onLocationResult(LocationResult locationResult) {
// unit : meter -> kilometer
double last_distance_5s_kilometer = location.distanceTo(lastLocation) / (double) 1000;
distance += last_distance_5s_kilometer;
double speed_average = distance / (double) (Duration.between(gameStartTime, LocalDateTime.now()).getSeconds() / 3600.0);

if (speed_average > 0.1) {
Log.d("debug:distance", "last 5s distance (km) : " + last_distance_5s_kilometer + "");
Log.d("debug:speed", "average speed since start (km/h) : " + speed_average + "");
String paceString = String.format("%4.2f km/h", speed_average);
pacePresentContentTextView.setText(paceString);
// double speed_average = distance / (double) (Duration.between(gameStartTime, LocalDateTime.now()).getSeconds() / 3600.0);

// if (speed_average > 0.1) {
// Log.d("debug:distance", "last 5s distance (km) : " + last_distance_5s_kilometer + "");
// Log.d("debug:speed", "average speed since start (km/h) : " + speed_average + "");
// String paceString = String.format("%4.2f km/h", speed_average);
// pacePresentContentTextView.setText(paceString);
// } else {
// String paceString = "--.-- km/h";
// pacePresentContentTextView.setText(paceString);
// }

if (last_distance_5s_kilometer != 0 ) {
int paceMinute = (int) (1 / (last_distance_5s_kilometer / 5)) / 60;
int paceSecond = (int) (1 / (last_distance_5s_kilometer / 5)) % 60;

if (paceMinute <= 30) {
String paceString = String.format("%02d'%02d\"", paceMinute, paceSecond);
pacePresentContentTextView.setText(paceString);
}
else {
String paceString = "--'--\"";
pacePresentContentTextView.setText(paceString);
}
} else {
String paceString = "--.-- km/h";
String paceString = "--'--\"";
pacePresentContentTextView.setText(paceString);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
android:layout_height="wrap_content"
android:fontFamily="@font/pretendardregular"
android:gravity="center_horizontal"
android:text="평균 속력"
android:text="현재 페이스"
android:textAppearance="@style/multi_room_play_goal" />

<TextView
Expand All @@ -40,7 +40,7 @@
android:layout_height="wrap_content"
android:fontFamily="@font/pretendardregular"
android:gravity="center_horizontal"
android:text="--:-- km/h"
android:text="--'--''"
android:textAppearance="@style/multi_room_play_goal" />
</LinearLayout>

Expand Down

0 comments on commit 4914b27

Please sign in to comment.