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 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) {
private val allDayString = resources.getString(R.string.all_day)
@ -89,7 +89,15 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
event_item_title.checkViewStrikeThrough(event.isTaskCompleted())
event_item_time.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS)
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", " ")

View File

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