diff --git a/app/src/main/java/v4lpt/vpt/f036/esw/EventAdapter.java b/app/src/main/java/v4lpt/vpt/f036/esw/EventAdapter.java index 3ca0d09..45d5a32 100644 --- a/app/src/main/java/v4lpt/vpt/f036/esw/EventAdapter.java +++ b/app/src/main/java/v4lpt/vpt/f036/esw/EventAdapter.java @@ -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); diff --git a/app/src/main/java/v4lpt/vpt/f036/esw/PreviewEventAdapter.java b/app/src/main/java/v4lpt/vpt/f036/esw/PreviewEventAdapter.java index 51de612..09520dc 100644 --- a/app/src/main/java/v4lpt/vpt/f036/esw/PreviewEventAdapter.java +++ b/app/src/main/java/v4lpt/vpt/f036/esw/PreviewEventAdapter.java @@ -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);