mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-03-30 03:00:25 +02:00
properly refresh the events at daily view after changing filtering
This commit is contained in:
parent
c1179639d6
commit
c2fe4d6bb0
@ -293,10 +293,10 @@ private fun addTodaysBackground(textView: TextView, res: Resources, dayLabelHeig
|
||||
textView.addResizedBackgroundDrawable(res, dayLabelHeight, mPrimaryColor, R.drawable.monthly_today_circle)
|
||||
|
||||
fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resources, dividerMargin: Int) {
|
||||
val backgroundDrawable = res.getDrawable(R.drawable.day_monthly_event_background)
|
||||
val eventLayoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
|
||||
day.dayEvents.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title })).forEach {
|
||||
val backgroundDrawable = res.getDrawable(R.drawable.day_monthly_event_background)
|
||||
backgroundDrawable.applyColorFilter(it.color)
|
||||
eventLayoutParams.setMargins(dividerMargin, 0, dividerMargin, dividerMargin)
|
||||
|
||||
|
@ -117,21 +117,20 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
|
||||
}
|
||||
|
||||
private fun receivedEvents(events: List<Event>) {
|
||||
val newHash = events.hashCode()
|
||||
val filtered = context?.getFilteredEvents(events) ?: ArrayList()
|
||||
val newHash = filtered.hashCode()
|
||||
if (newHash == lastHash || !isAdded) {
|
||||
return
|
||||
}
|
||||
lastHash = newHash
|
||||
|
||||
val replaceDescription = context!!.config.replaceDescription
|
||||
val sorted = ArrayList<Event>(events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, {
|
||||
val sorted = ArrayList<Event>(filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, {
|
||||
if (replaceDescription) it.location else it.description
|
||||
})))
|
||||
|
||||
val filtered = context?.getFilteredEvents(sorted) ?: ArrayList()
|
||||
|
||||
activity?.runOnUiThread {
|
||||
updateEvents(filtered)
|
||||
updateEvents(sorted)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user