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
#215)

…nd added comments for better understanding

# Thanks for your contribution.

## PLEASE REMOVE
To support us in providing a nice (and fast) open-source experience:
1. Verify that the tests are passing
2. Check that the code is properly formatted (using AndroidStudio's
autoformatter)
3. Provide write access to the
[branch](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork)
4. If the PR is not ready for review, please submit it as a
[draft](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests)
## PLEASE REMOVE

**Describe the pull request**
A clear and concise description of what the pull request changes/adds.

**Link to the the issue**
(If available): The link to the issue that this pull request solves.

**License agreement**
By opening this pull request, you are providing your contribution under
the _Apache License 2.0_ (see [LICENSE.md](LICENSE.md)).

**Note: new dependencies/libraries**
Please refrain from introducing new libraries without consulting the
team.
  • Loading branch information
mehtavandit authored Apr 26, 2024
2 parents 18517f1 + 0bebefe commit ba1cf41
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 ba1cf41

Please sign in to comment.