diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt index c4c3c7013..96cac93db 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt @@ -955,7 +955,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { search_results_list.beVisibleIf(events.isNotEmpty()) search_placeholder.beVisibleIf(events.isEmpty()) val listItems = getEventListItems(events) - val eventsAdapter = EventListAdapter(this, listItems, true, this, search_results_list) { + val eventsAdapter = EventListAdapter(this, listItems, true, this, search_results_list, true) { if (it is ListEvent) { Intent(applicationContext, EventActivity::class.java).apply { putExtra(EVENT_ID, it.id) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt index 29f2c8f50..72cc256e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt @@ -46,7 +46,7 @@ class WidgetListConfigureActivity : SimpleActivity() { finish() } - EventListAdapter(this, getListItems(), false, null, config_events_list) {}.apply { + EventListAdapter(this, getListItems(), false, null, config_events_list, true) {}.apply { updateTextColor(mTextColor) config_events_list.adapter = this } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt index 188e15212..9f05f928e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt @@ -28,7 +28,7 @@ import kotlinx.android.synthetic.main.event_list_section.view.* import java.util.* class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList, val allowLongClick: Boolean, val listener: RefreshRecyclerViewListener?, - recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) { + recyclerView: MyRecyclerView, val tryDimPastEvents: Boolean, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) { private val topDivider = resources.getDrawable(R.drawable.divider_width) private val allDayString = resources.getString(R.string.all_day) @@ -176,7 +176,7 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList() var listener: NavigationListener? = null @@ -45,6 +48,14 @@ class MonthDayFragment : Fragment(), MonthlyCalendar { mPackageName = activity!!.packageName mHolder = view.month_day_calendar_holder mDayCode = arguments!!.getString(DAY_CODE)!! + + val shownMonthDateTime = Formatter.getDateTimeFromCode(mDayCode) + val todayCode = Formatter.getTodayCode() + val todayDateTime = Formatter.getDateTimeFromCode(todayCode) + if (todayDateTime.year == shownMonthDateTime.year && todayDateTime.monthOfYear == shownMonthDateTime.monthOfYear) { + mCurrentDayCode = todayCode + } + mConfig = context!!.config storeStateVariables() setupButtons() @@ -93,22 +104,32 @@ class MonthDayFragment : Fragment(), MonthlyCalendar { activity?.runOnUiThread { mHolder.month_day_view_wrapper.updateDays(days, false) { - + mCurrentDayCode = it.code + updateVisibleEvents() } } val startDateTime = Formatter.getLocalDateTimeFromCode(mDayCode).minusWeeks(1) val endDateTime = startDateTime.plusWeeks(6) context.eventsHelper.getEvents(startDateTime.seconds(), endDateTime.seconds()) { events -> - val listItems = context.getEventListItems(events, false) - activity?.runOnUiThread { - EventListAdapter(activity as SimpleActivity, listItems, true, null, month_day_events_list) { - if (it is ListEvent) { - context.editEvent(it) - } - }.apply { - month_day_events_list.adapter = this + mListEvents = events + updateVisibleEvents() + } + } + + private fun updateVisibleEvents() { + val filtered = mListEvents.filter { + Formatter.getDayCodeFromTS(it.startTS) == mCurrentDayCode + } + + val listItems = context!!.getEventListItems(filtered, false) + activity?.runOnUiThread { + EventListAdapter(activity as SimpleActivity, listItems, true, null, month_day_events_list, false) { + if (it is ListEvent) { + activity?.editEvent(it) } + }.apply { + month_day_events_list.adapter = this } } }