Merge pull request #1766 from DoozyDoz/bugfix_multiple_day_events

multiple day event
This commit is contained in:
Tibor Kaputa 2022-07-23 12:44:57 +02:00 committed by GitHub
commit e94bfef179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -20,7 +20,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.event_list_item.view.* import kotlinx.android.synthetic.main.event_list_item.view.*
class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, recyclerView: MyRecyclerView, var dayCode: String, itemClick: (Any) -> Unit) :
MyRecyclerViewAdapter(activity, recyclerView, itemClick) { MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
private val allDayString = resources.getString(R.string.all_day) private val allDayString = resources.getString(R.string.all_day)
@ -77,7 +77,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
} else { } else {
activity.getProperTextColor() activity.getProperTextColor()
} }
notifyDataSetChanged() notifyDataSetChanged()
} }
@ -89,7 +89,15 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
event_item_title.checkViewStrikeThrough(event.isTaskCompleted()) event_item_title.checkViewStrikeThrough(event.isTaskCompleted())
event_item_time.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS) event_item_time.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS)
if (event.startTS != event.endTS && !event.getIsAllDay()) { if (event.startTS != event.endTS && !event.getIsAllDay()) {
event_item_time.text = "${event_item_time.text} - ${Formatter.getTimeFromTS(context, event.endTS)}" val startDayCode = Formatter.getDayCodeFromTS(event.startTS)
val endDayCode = Formatter.getDayCodeFromTS(event.endTS)
val startDate = Formatter.getDayTitle(activity, startDayCode, false)
val endDate = Formatter.getDayTitle(activity, endDayCode, false)
val startTimeString = event_item_time.text
val endTimeString = Formatter.getTimeFromTS(context, event.endTS)
val startDayString = if (startDayCode != dayCode) " ($startDate)" else ""
val endDayString = if (endDayCode != dayCode) " ($endDate)" else ""
event_item_time.text = "$startTimeString$startDayString - $endTimeString$endDayString"
} }
event_item_description.text = if (replaceDescriptionWithLocation) event.location else event.description.replace("\n", " ") event_item_description.text = if (replaceDescriptionWithLocation) event.location else event.description.replace("\n", " ")
@ -103,7 +111,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
} else { } else {
dimPastEvents && event.isPastEvent && !isPrintVersion dimPastEvents && event.isPastEvent && !isPrintVersion
} }
if (adjustAlpha) { if (adjustAlpha) {
newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA) newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA)
} }
@ -119,7 +127,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
} else { } else {
mediumMargin mediumMargin
} }
(event_item_title.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin (event_item_title.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin
} }
} }

View File

@ -112,7 +112,7 @@ class DayFragment : Fragment() {
if (activity == null) if (activity == null)
return return
DayEventsAdapter(activity as SimpleActivity, events, mHolder.day_events) { DayEventsAdapter(activity as SimpleActivity, events, mHolder.day_events, mDayCode) {
editEvent(it as Event) editEvent(it as Event)
}.apply { }.apply {
mHolder.day_events.adapter = this mHolder.day_events.adapter = this