Skip to content

Commit

Permalink
GH-127 Improved the functions in the file DaySpecificActivity.java, a…
Browse files Browse the repository at this point in the history
…nd added comments for better understanding
  • Loading branch information
mehtavandit committed Apr 26, 2024
1 parent e197a58 commit 0bebefe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/de/dennisguse/opentracks/CalendarActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ public void setSelectedDate(Date date){
this.selectedDate = date;
}

/**
* Retrieves the currently selected date.
*
* @return The currently selected date.
*/
public Date getSelectedDate(){
// Assuming selectedDate is a member variable, return its value
return selectedDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,36 @@ public void updateTrackSegments() {
}
}

/**
* This method is responsible for displaying a toast message indicating that no tracks were found
* for the specific date of the activity. It finishes the current activity and displays the toast
* message with information about the date and a suggestion to import a GPX file from Moodle.
*/
private void showNoTracksFoundToast() {
finish();
Toast.makeText(DaySpecificActivity.this, "No Tracks found for date: " + activityDate + "\n Please import GPX file from Moodle", Toast.LENGTH_LONG).show();
}
/**
* Converts a string representation of a date to a Date object.
*
* @param dateString A string representing the date in the format "yyyy-MM-dd".
* @return A Date object representing the parsed date.
*/
private Date getDateFromString(String dateString) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate localDate = LocalDate.parse(dateString, formatter);
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}

/**
* Handles the intent received by the activity, extracting the date of the track from it.
* If the date is not provided in the intent extras, it falls back to a default date.
* Then, it retrieves the track for the given date from the content provider.
* If no track is found, it displays a toast message indicating no tracks were found.
* Otherwise, it sets the trackId for further use.
*
* @param intent The Intent containing the date information.
*/
private void handleIntent(Intent intent) {
activityDate = intent.getStringExtra(EXTRA_TRACK_DATE);
if (activityDate == null) {
Expand All @@ -125,6 +145,11 @@ private void handleIntent(Intent intent) {
}
}

/**
* Inflates the layout for the activity using view binding and returns the root view.
*
* @return The root view of the inflated layout.
*/
@Override
protected View getRootView() {
viewBinding = DaySpecificActivityBinding.inflate(getLayoutInflater());
Expand Down

0 comments on commit 0bebefe

Please sign in to comment.