diff --git a/app/src/main/java/dev/sasikanth/pinnit/notifications/adapter/NotificationsListAdapter.kt b/app/src/main/java/dev/sasikanth/pinnit/notifications/adapter/NotificationsListAdapter.kt index 8e00ebd0..15d896e4 100644 --- a/app/src/main/java/dev/sasikanth/pinnit/notifications/adapter/NotificationsListAdapter.kt +++ b/app/src/main/java/dev/sasikanth/pinnit/notifications/adapter/NotificationsListAdapter.kt @@ -28,7 +28,7 @@ import java.time.format.DateTimeFormatter import kotlin.math.hypot class NotificationsListAdapter( - utcClock: UtcClock, + private val utcClock: UtcClock, private val userClock: UserClock, private val scheduleDateFormatter: DateTimeFormatter, private val scheduleTimeFormatter: DateTimeFormatter, @@ -38,8 +38,6 @@ class NotificationsListAdapter( private val onRemoveNotificationScheduleClicked: (PinnitNotification) -> Unit ) : ListAdapter(NotificationsDiffCallback) { - private val now = Instant.now(utcClock) - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { val context = parent.context val layoutInflater = LayoutInflater.from(context) @@ -59,6 +57,7 @@ class NotificationsListAdapter( val notification = currentList[adapterPosition] onEditNotificationScheduleClicked(notification) } + R.id.removeSchedule -> { val notification = currentList[adapterPosition] onRemoveNotificationScheduleClicked(notification) @@ -107,7 +106,7 @@ class NotificationsListAdapter( binding.timeStamp.text = DateUtils.getRelativeTimeSpanString( notification.updatedAt.toEpochMilli(), - now.toEpochMilli(), + Instant.now(utcClock).toEpochMilli(), SECOND_IN_MILLIS, FORMAT_ABBREV_RELATIVE ) @@ -169,18 +168,21 @@ class NotificationsListAdapter( scheduleTimeFormatter.format(scheduleDateTime.toLocalTime()) ) } + scheduleDateTime.toLocalDate().isEqual(yesterday.toLocalDate()) -> { context.getString( R.string.notification_schedule_button_yesterday, scheduleTimeFormatter.format(scheduleDateTime.toLocalTime()) ) } + scheduleDateTime.toLocalDate().isEqual(tomorrow.toLocalDate()) -> { context.getString( R.string.notification_schedule_button_tomorrow, scheduleTimeFormatter.format(scheduleDateTime.toLocalTime()) ) } + else -> { context.getString( R.string.notification_schedule_button,