optimize event getting at month views a bit + fix some glitches

This commit is contained in:
tibbi 2018-03-29 20:13:26 +02:00
parent 97a6b15430
commit 5943d0991e
4 changed files with 5 additions and 5 deletions

View File

@ -88,7 +88,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
config_bg_seekbar.progress = (mBgAlpha * 100).toInt()
updateBgColor()
MonthlyCalendarImpl(this, applicationContext).updateMonthlyCalendar(DateTime(), false)
MonthlyCalendarImpl(this, applicationContext).updateMonthlyCalendar(DateTime().withDayOfMonth(1), false)
}
private fun saveConfig() {

View File

@ -72,7 +72,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
private fun getMonths(code: String): List<String> {
val months = ArrayList<String>(PREFILLED_MONTHS)
val today = Formatter.getDateTimeFromCode(code)
val today = Formatter.getDateTimeFromCode(code).withDayOfMonth(1)
for (i in -PREFILLED_MONTHS / 2..PREFILLED_MONTHS / 2) {
months.add(Formatter.getDayCodeFromDateTime(today.plusMonths(i)))
}

View File

@ -25,8 +25,8 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
fun updateMonthlyCalendar(targetDate: DateTime, filterEventTypes: Boolean = true) {
mFilterEventTypes = filterEventTypes
mTargetDate = targetDate
val startTS = mTargetDate.minusMonths(1).seconds()
val endTS = mTargetDate.plusMonths(1).seconds()
val startTS = mTargetDate.minusDays(7).seconds()
val endTS = mTargetDate.plusDays(43).seconds()
mContext.dbHelper.getEvents(startTS, endTS) {
gotEvents(it as ArrayList<Event>)
}

View File

@ -24,7 +24,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
private val NEW_EVENT = "new_event"
companion object {
private var targetDate = DateTime.now()
private var targetDate = DateTime.now().withDayOfMonth(1)
}
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {