Merge pull request #1766 from DoozyDoz/bugfix_multiple_day_events
multiple day event
This commit is contained in:
commit
e94bfef179
2 changed files with 14 additions and 6 deletions
|
@ -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)
|
||||
|
@ -77,7 +77,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
} else {
|
||||
activity.getProperTextColor()
|
||||
}
|
||||
|
||||
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
@ -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", " ")
|
||||
|
@ -103,7 +111,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
} else {
|
||||
dimPastEvents && event.isPastEvent && !isPrintVersion
|
||||
}
|
||||
|
||||
|
||||
if (adjustAlpha) {
|
||||
newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA)
|
||||
}
|
||||
|
@ -119,7 +127,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
} else {
|
||||
mediumMargin
|
||||
}
|
||||
|
||||
|
||||
(event_item_title.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue