diff --git a/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/daySpecificStats/DaySpecificActivity.java b/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/daySpecificStats/DaySpecificActivity.java index f17dde161..c9875a3e2 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/daySpecificStats/DaySpecificActivity.java +++ b/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/daySpecificStats/DaySpecificActivity.java @@ -34,25 +34,23 @@ public class DaySpecificActivity extends AbstractTrackDeleteActivity { private TrackDataHub trackDataHub; private Track.Id trackId; private List trackSegments; - private DaySpecificAdapter adapter; + private DaySpecificAdapter dataAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.day_specific_activity); + trackSegments = new ArrayList<>(); contentProviderUtils = new ContentProviderUtils(this); handleIntent(getIntent()); + updateTrackSegments(); trackDataHub = new TrackDataHub(this); setSupportActionBar(viewBinding.bottomAppBarLayout.bottomAppBar); - trackSegments = new ArrayList<>(); viewBinding = DaySpecificActivityBinding.inflate(getLayoutInflater()); - LinearLayoutManager layoutManager = new LinearLayoutManager(this); - adapter = new DaySpecificAdapter(this, viewBinding.segmentList); - viewBinding.segmentList.setLayoutManager(layoutManager); - viewBinding.segmentList.setAdapter(adapter); - + dataAdapter = new DaySpecificAdapter(this, viewBinding.segmentList); + dataAdapter.swapData(trackSegments); + viewBinding.segmentList.setAdapter(dataAdapter); } @Override @@ -64,7 +62,7 @@ protected void onStart() { protected void onResume() { super.onResume(); updateTrackSegments(); - adapter.swapData(trackSegments); + dataAdapter.swapData(trackSegments); } public void updateTrackSegments() { @@ -109,8 +107,7 @@ private Date getDummyDate() { String dateString = "2024-03-02"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate localDate = LocalDate.parse(dateString, formatter); - Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); - return date; + return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); } private void handleIntent(Intent intent) { diff --git a/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/daySpecificStats/DaySpecificAdapter.java b/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/daySpecificStats/DaySpecificAdapter.java index 3a97377c2..6585a12ec 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/daySpecificStats/DaySpecificAdapter.java +++ b/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/daySpecificStats/DaySpecificAdapter.java @@ -16,10 +16,10 @@ import java.util.List; import de.dennisguse.opentracks.R; +import de.dennisguse.opentracks.data.models.Distance; import de.dennisguse.opentracks.data.models.Track; import de.dennisguse.opentracks.data.models.TrackSegment; import de.dennisguse.opentracks.databinding.DaySpecificActivityItemBinding; -import de.dennisguse.opentracks.ui.TrackListAdapter; import de.dennisguse.opentracks.ui.util.ActivityUtils; public class DaySpecificAdapter extends RecyclerView.Adapter implements ActionMode.Callback { @@ -101,12 +101,15 @@ public ViewHolder(@NonNull View itemView) { view.setOnLongClickListener(this); } - public void bind(TrackSegment segment){ + public void bind(TrackSegment segment) { + Distance distance = segment.getDistanceBetweenFirstAndLast(); + Long time = segment.getTotalTime(); + double speed = segment.getSpeed(distance, time); viewBinding.daySpecificActivity.setText("Run"); viewBinding.daySpecificActivityDisplacement.setText("0 m"); viewBinding.daySpecificActivityDistance.setText("0.14 km"); - viewBinding.daySpecificActivitySpeed.setText("36.3 km/h"); - viewBinding.daySpecificActivityTime.setText("0.50"); + viewBinding.daySpecificActivitySpeed.setText(speed + " km/h"); + viewBinding.daySpecificActivityTime.setText("" + segment.getTotalTime()); } public void setSelected(boolean isSelected) { diff --git a/src/main/res/layout/day_specific_activity.xml b/src/main/res/layout/day_specific_activity.xml index 757564243..a2186a90a 100644 --- a/src/main/res/layout/day_specific_activity.xml +++ b/src/main/res/layout/day_specific_activity.xml @@ -1,5 +1,5 @@ - + android:layout_weight="0.8" + android:paddingTop="16dp" + android:paddingBottom="16dp" + app:layoutManager="LinearLayoutManager"/> @@ -26,4 +31,4 @@ android:id="@+id/bottom_app_bar_layout" layout="@layout/bottomappbar" /> - \ No newline at end of file + \ No newline at end of file