Skip to content

Commit

Permalink
1 days left ==> 1 day left, -5 days left ==> 5 days ago
Browse files Browse the repository at this point in the history
  • Loading branch information
v4lpt committed Sep 7, 2024
1 parent 7902062 commit b9adbea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions app/src/main/java/v4lpt/vpt/f036/esw/EventAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi

eventHolder.titleTextView.setText(event.getTitle());
long daysLeft = event.getDaysLeft();
eventHolder.daysLeftTextView.setText(daysLeft + " days left");

String daysText;
if (daysLeft < 0) {
daysText = Math.abs(daysLeft) + (Math.abs(daysLeft) == 1 ? " day ago" : " days ago");
} else if (daysLeft == 0) {
daysText = "Today";
} else {
daysText = daysLeft + (daysLeft == 1 ? " day left" : " days left");
}
eventHolder.daysLeftTextView.setText(daysText);
String formattedDate = event.getDate().format(dateFormatter);
eventHolder.dateTextView.setText(formattedDate);

Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/v4lpt/vpt/f036/esw/PreviewEventAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ public void onBindViewHolder(@NonNull EventViewHolder holder, int position) {
if (previewEvent != null) {
holder.titleTextView.setText(previewEvent.getTitle());
long daysLeft = previewEvent.getDaysLeft();
holder.daysLeftTextView.setText(daysLeft + " days left");

String daysText;
if (daysLeft < 0) {
daysText = Math.abs(daysLeft) + (Math.abs(daysLeft) == 1 ? " day ago" : " days ago");
} else if (daysLeft == 0) {
daysText = "Today";
} else {
daysText = daysLeft + (daysLeft == 1 ? " day left" : " days left");
}
holder.daysLeftTextView.setText(daysText);
String formattedDate = previewEvent.getDate().format(dateFormatter);
holder.dateTextView.setText(formattedDate);

Expand Down

0 comments on commit b9adbea

Please sign in to comment.