fix a glitch at updating synced events

This commit is contained in:
tibbi 2017-10-08 19:04:03 +02:00
parent 669a931224
commit 0c1c752260
3 changed files with 43 additions and 44 deletions

View File

@ -136,6 +136,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
val addHours = if (intent.getBooleanExtra(NEW_EVENT_SET_HOUR_DURATION, false)) 1 else 0
mEventEndDateTime = mEventStartDateTime.plusHours(addHours)
mEventCalendarId = config.lastUsedCaldavCalendar
}
private fun showReminder1Dialog() {

View File

@ -76,7 +76,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
mCalendar.apply {
mTargetDate = Formatter.getDateTimeFromCode(mDayCode)
getDays() // prefill the screen asap, even if without events
getDays(false) // prefill the screen asap, even if without events
}
updateCalendar()
}

View File

@ -18,7 +18,6 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
private val mToday: String = DateTime().toString(Formatter.DAYCODE_PATTERN)
private var mEvents = ArrayList<Event>()
private var days = ArrayList<DayMonthly>(DAYS_CNT)
private var mFilterEventTypes = true
lateinit var mTargetDate: DateTime
@ -34,12 +33,11 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
}
fun getMonth(targetDate: DateTime) {
days.clear()
updateMonthlyCalendar(targetDate)
}
fun getDays() {
if (days.isEmpty()) {
fun getDays(markDaysWithEvents: Boolean) {
val days = ArrayList<DayMonthly>(DAYS_CNT)
val currMonthDays = mTargetDate.dayOfMonth().maximumValue
var firstDayIndex = mTargetDate.withDayOfMonth(1).dayOfWeek
if (!mContext.config.isSundayFirst)
@ -77,12 +75,11 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
days.add(day)
value++
}
}
if (mEvents.isEmpty()) {
mCallback.updateMonthlyCalendar(monthName, days)
} else {
if (markDaysWithEvents) {
markDaysWithEvents(days)
} else {
mCallback.updateMonthlyCalendar(monthName, days)
}
}
@ -133,11 +130,12 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
}
private fun gotEvents(events: ArrayList<Event>) {
mEvents = if (mFilterEventTypes)
mEvents = if (mFilterEventTypes) {
mContext.getFilteredEvents(events) as ArrayList<Event>
else
} else {
events
}
getDays()
getDays(true)
}
}