mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-03-04 03:17:51 +01:00
refresh the daily events list if something gets deleted
This commit is contained in:
parent
47f601bd21
commit
f53aaa857e
@ -24,11 +24,12 @@ import com.simplemobiletools.calendar.pro.models.DayMonthly
|
|||||||
import com.simplemobiletools.calendar.pro.models.Event
|
import com.simplemobiletools.calendar.pro.models.Event
|
||||||
import com.simplemobiletools.calendar.pro.models.ListEvent
|
import com.simplemobiletools.calendar.pro.models.ListEvent
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import kotlinx.android.synthetic.main.fragment_month_day.*
|
import kotlinx.android.synthetic.main.fragment_month_day.*
|
||||||
import kotlinx.android.synthetic.main.fragment_month_day.view.*
|
import kotlinx.android.synthetic.main.fragment_month_day.view.*
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
class MonthDayFragment : Fragment(), MonthlyCalendar {
|
class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListener {
|
||||||
private var mSundayFirst = false
|
private var mSundayFirst = false
|
||||||
private var mShowWeekNumbers = false
|
private var mShowWeekNumbers = false
|
||||||
private var mDayCode = ""
|
private var mDayCode = ""
|
||||||
@ -112,14 +113,7 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val startDateTime = Formatter.getLocalDateTimeFromCode(mDayCode).minusWeeks(1)
|
refreshItems()
|
||||||
val endDateTime = startDateTime.plusWeeks(6)
|
|
||||||
context.eventsHelper.getEvents(startDateTime.seconds(), endDateTime.seconds()) { events ->
|
|
||||||
mListEvents = events
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
updateVisibleEvents()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateVisibleEvents() {
|
private fun updateVisibleEvents() {
|
||||||
@ -145,12 +139,18 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
|||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
mHolder.month_day_no_events_placeholder.beVisibleIf(listItems.isEmpty())
|
mHolder.month_day_no_events_placeholder.beVisibleIf(listItems.isEmpty())
|
||||||
EventListAdapter(activity as SimpleActivity, listItems, true, null, month_day_events_list, false) {
|
|
||||||
if (it is ListEvent) {
|
val currAdapter = mHolder.month_day_events_list.adapter
|
||||||
activity?.editEvent(it)
|
if (currAdapter == null) {
|
||||||
|
EventListAdapter(activity as SimpleActivity, listItems, true, this, month_day_events_list, false) {
|
||||||
|
if (it is ListEvent) {
|
||||||
|
activity?.editEvent(it)
|
||||||
|
}
|
||||||
|
}.apply {
|
||||||
|
month_day_events_list.adapter = this
|
||||||
}
|
}
|
||||||
}.apply {
|
} else {
|
||||||
month_day_events_list.adapter = this
|
(currAdapter as EventListAdapter).updateListItems(listItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,4 +176,15 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
|||||||
}
|
}
|
||||||
return month
|
return month
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun refreshItems() {
|
||||||
|
val startDateTime = Formatter.getLocalDateTimeFromCode(mDayCode).minusWeeks(1)
|
||||||
|
val endDateTime = startDateTime.plusWeeks(6)
|
||||||
|
activity?.eventsHelper?.getEvents(startDateTime.seconds(), endDateTime.seconds()) { events ->
|
||||||
|
mListEvents = events
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
updateVisibleEvents()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user