@@ -45,9 +45,7 @@ class ScheduleSendBottomSheetDialog @Inject constructor() : BottomSheetDialogFra
45
45
private val navigationArgs: ScheduleSendBottomSheetDialogArgs by navArgs()
46
46
private var binding: BottomSheetScheduleSendBinding by safeBinding()
47
47
48
- // Navigation args does not support nullable primitive types, so we use 0L
49
- // as a replacement (corresponding to Thursday 1 January 1970 00:00:00 UT).
50
- private var lastSelectedScheduleEpoch: Long = 0L
48
+ private var lastSelectedScheduleEpoch: Long? = null
51
49
52
50
override fun onCreateView (inflater : LayoutInflater , container : ViewGroup ? , savedInstanceState : Bundle ? ): View {
53
51
return BottomSheetScheduleSendBinding .inflate(inflater, container, false ).also { binding = it }.root
@@ -56,7 +54,9 @@ class ScheduleSendBottomSheetDialog @Inject constructor() : BottomSheetDialogFra
56
54
override fun onViewCreated (view : View , savedInstanceState : Bundle ? ): Unit = with (binding) {
57
55
super .onViewCreated(view, savedInstanceState)
58
56
59
- lastSelectedScheduleEpoch = navigationArgs.lastSelectedScheduleEpoch
57
+ // Navigation args does not support nullable primitive types, so we use 0L
58
+ // as a replacement (corresponding to Thursday 1 January 1970 00:00:00 UT).
59
+ lastSelectedScheduleEpoch = navigationArgs.lastSelectedScheduleEpoch.takeIf { it != 0L }
60
60
61
61
computeLastScheduleItem()
62
62
setLastScheduleClickListener()
@@ -72,15 +72,17 @@ class ScheduleSendBottomSheetDialog @Inject constructor() : BottomSheetDialogFra
72
72
}
73
73
74
74
private fun computeLastScheduleItem () = with (binding) {
75
- if (Date (lastSelectedScheduleEpoch).isAtLeastXMinutesInTheFuture(MIN_SELECTABLE_DATE_MINUTES )) {
75
+ val lastSelectedDate = lastSelectedScheduleEpoch?.let { Date (it) }
76
+
77
+ if (lastSelectedDate?.isAtLeastXMinutesInTheFuture(MIN_SELECTABLE_DATE_MINUTES ) == true ) {
76
78
lastScheduleItem.isVisible = true
77
- lastScheduleItem.setDescription(context.dayOfWeekDateWithoutYear(date = Date (lastSelectedScheduleEpoch) ))
79
+ lastScheduleItem.setDescription(context.dayOfWeekDateWithoutYear(date = lastSelectedDate ))
78
80
}
79
81
}
80
82
81
83
private fun setLastScheduleClickListener () {
82
84
binding.lastScheduleItem.setOnClickListener {
83
- if (lastSelectedScheduleEpoch != 0L ) {
85
+ if (lastSelectedScheduleEpoch != null ) {
84
86
trackScheduleSendEvent(" lastSelectedSchedule" )
85
87
setBackNavigationResult(SCHEDULE_DRAFT_RESULT , lastSelectedScheduleEpoch)
86
88
}
0 commit comments