Compare commits
1 Commits
routeFragm
...
CosmeticFi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d87adeec8d |
@@ -81,6 +81,7 @@ public class Route implements Parcelable {
|
||||
|
||||
|
||||
public int getTotalTime() {
|
||||
|
||||
return totalTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ public class RouteDetailFragment extends Fragment {
|
||||
|
||||
private Route route;
|
||||
private Refreshable refreshable;
|
||||
private String time;
|
||||
|
||||
@Override
|
||||
public void onAttach(@NotNull Context context) {
|
||||
@@ -69,11 +68,11 @@ public class RouteDetailFragment extends Fragment {
|
||||
String detailText = this.route.getDescription() + "<br><br><b>" + getResources().getString(R.string.following_locations) + "</b>" + locations + "<br><br><b>" + getResources().getString(R.string.start_location) + ": </b>" + route.getLocations().get(0).getName() + "<br>" + "<b>" + getResources().getString(R.string.end_location) + ": </b>" + route.getLocations().get(route.getLocations().size() - 1).getName();
|
||||
routeDetailText.setText(Html.fromHtml(detailText));
|
||||
|
||||
//sets the text of the totaldistance
|
||||
|
||||
TextView totalDistance = view.findViewById(R.id.total_distance);
|
||||
//looks if imperial units or metric
|
||||
String distance_tekst = getResources().getString(R.string.total_distance_route);
|
||||
boolean imperialChecked = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false);
|
||||
totalDistance.setText(getResources().getString(R.string.total_distance_route) + " " + String.format("%.1f", calculateRoute(this.route.getLocations())) + (imperialChecked ? "yd" : "m") + "\n" + getResources().getString(R.string.total_time) + " " + this.time);
|
||||
totalDistance.setText(distance_tekst + " " + String.format("%.1f", calculateRoute(this.route.getLocations())) + (imperialChecked ? "yd" : "m"));
|
||||
|
||||
//Initialises the back button
|
||||
ImageButton backButton = view.findViewById(R.id.route_detail_back_button);
|
||||
@@ -124,7 +123,6 @@ public class RouteDetailFragment extends Fragment {
|
||||
}
|
||||
System.out.println("Total Distance: " + totalDistance);
|
||||
|
||||
calculateTime(totalDistance);
|
||||
// if the imperialSwitch is checked, return feet, if not, return meters
|
||||
if (getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false))
|
||||
return totalDistance * 1.0936133;
|
||||
@@ -132,15 +130,4 @@ public class RouteDetailFragment extends Fragment {
|
||||
return totalDistance;
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public void calculateTime(double totalDistance){
|
||||
double totalTimeInMinutes = ((totalDistance / 1000) / 5) * 60;
|
||||
if(totalTimeInMinutes > 60) {
|
||||
int hours = (int)(totalTimeInMinutes / 60);
|
||||
int minutes = (int)(totalTimeInMinutes % 60);
|
||||
this.time = hours + " " + getResources().getString(R.string.hour) + " " + minutes + " " + getResources().getString(R.string.minutes);
|
||||
}
|
||||
else this.time = (int)(((totalDistance / 1000) / 5) * 60) + " " + getResources().getString(R.string.minutes);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,10 +14,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="9dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/statistics"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toEndOf="@id/coupon_back_button"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:text="@string/coupons"
|
||||
android:textSize="30sp"
|
||||
android:textColor="@color/secondaryColour"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/coupon_back_button"
|
||||
app:layout_constraintBottom_toBottomOf="@id/coupon_back_button"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/coupon_back_button"
|
||||
@@ -26,7 +29,6 @@
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@drawable/ic_back_button_24"
|
||||
android:backgroundTint="@color/buttonColour"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
android:layout_margin="9dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/locations"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toEndOf="@id/location_back_button"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageButton
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
/>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/detail_location_back_button"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -24,9 +24,11 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="9dp"
|
||||
android:text="@string/routes"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toEndOf="@id/route_back_button"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/route_back_button"
|
||||
app:layout_constraintBottom_toBottomOf="@id/route_back_button"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/route_recyclerview"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:id="@+id/route_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:textColor="@color/secondaryColour"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/route_detail_image"
|
||||
android:text=""
|
||||
|
||||
@@ -32,6 +32,4 @@
|
||||
<string name="following_locations">"Deze route bevat de volgende locaties: "</string>
|
||||
<string name="notification_title">Je bent dicht bij een locatie!</string>
|
||||
<string name="notification_text">Je bent bijna bij %1$s</string>
|
||||
<string name="hour">uur</string>
|
||||
<string name="minutes">minuten</string>
|
||||
</resources>
|
||||
@@ -30,6 +30,4 @@
|
||||
<string name="following_locations">This route contains the following locations: </string>
|
||||
<string name="end_location">End location</string>
|
||||
<string name="start_location">Start location</string>
|
||||
<string name="hour">hour</string>
|
||||
<string name="minutes">minutes</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user