always show the proper events at the list of month/day view
This commit is contained in:
parent
2051287365
commit
88a4ccfec5
2 changed files with 49 additions and 20 deletions
|
@ -30,7 +30,7 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
||||||
private var mSundayFirst = false
|
private var mSundayFirst = false
|
||||||
private var mShowWeekNumbers = false
|
private var mShowWeekNumbers = false
|
||||||
private var mDayCode = ""
|
private var mDayCode = ""
|
||||||
private var mCurrentDayCode = ""
|
private var mSelectedDayCode = ""
|
||||||
private var mPackageName = ""
|
private var mPackageName = ""
|
||||||
private var mLastHash = 0L
|
private var mLastHash = 0L
|
||||||
private var mCalendar: MonthlyCalendarImpl? = null
|
private var mCalendar: MonthlyCalendarImpl? = null
|
||||||
|
@ -52,8 +52,10 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
||||||
val shownMonthDateTime = Formatter.getDateTimeFromCode(mDayCode)
|
val shownMonthDateTime = Formatter.getDateTimeFromCode(mDayCode)
|
||||||
val todayCode = Formatter.getTodayCode()
|
val todayCode = Formatter.getTodayCode()
|
||||||
val todayDateTime = Formatter.getDateTimeFromCode(todayCode)
|
val todayDateTime = Formatter.getDateTimeFromCode(todayCode)
|
||||||
if (todayDateTime.year == shownMonthDateTime.year && todayDateTime.monthOfYear == shownMonthDateTime.monthOfYear) {
|
mSelectedDayCode = if (todayDateTime.year == shownMonthDateTime.year && todayDateTime.monthOfYear == shownMonthDateTime.monthOfYear) {
|
||||||
mCurrentDayCode = todayCode
|
todayCode
|
||||||
|
} else {
|
||||||
|
mDayCode
|
||||||
}
|
}
|
||||||
|
|
||||||
mConfig = context!!.config
|
mConfig = context!!.config
|
||||||
|
@ -104,7 +106,7 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
mHolder.month_day_view_wrapper.updateDays(days, false) {
|
mHolder.month_day_view_wrapper.updateDays(days, false) {
|
||||||
mCurrentDayCode = it.code
|
mSelectedDayCode = it.code
|
||||||
updateVisibleEvents()
|
updateVisibleEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,23 +115,33 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
||||||
val endDateTime = startDateTime.plusWeeks(6)
|
val endDateTime = startDateTime.plusWeeks(6)
|
||||||
context.eventsHelper.getEvents(startDateTime.seconds(), endDateTime.seconds()) { events ->
|
context.eventsHelper.getEvents(startDateTime.seconds(), endDateTime.seconds()) { events ->
|
||||||
mListEvents = events
|
mListEvents = events
|
||||||
updateVisibleEvents()
|
activity?.runOnUiThread {
|
||||||
|
updateVisibleEvents()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateVisibleEvents() {
|
private fun updateVisibleEvents() {
|
||||||
val filtered = mListEvents.filter {
|
if (activity == null) {
|
||||||
Formatter.getDayCodeFromTS(it.startTS) == mCurrentDayCode
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val listItems = context!!.getEventListItems(filtered, false)
|
val filtered = mListEvents.filter {
|
||||||
|
Formatter.getDayCodeFromTS(it.startTS) == mSelectedDayCode
|
||||||
|
}
|
||||||
|
|
||||||
|
val listItems = activity!!.getEventListItems(filtered, false)
|
||||||
|
month_day_selected_day_label.text = Formatter.getDateFromCode(activity!!, mSelectedDayCode, false)
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
EventListAdapter(activity as SimpleActivity, listItems, true, null, month_day_events_list, false) {
|
if (activity != null) {
|
||||||
if (it is ListEvent) {
|
EventListAdapter(activity as SimpleActivity, listItems, true, null, month_day_events_list, false) {
|
||||||
activity?.editEvent(it)
|
if (it is ListEvent) {
|
||||||
|
activity?.editEvent(it)
|
||||||
|
}
|
||||||
|
}.apply {
|
||||||
|
month_day_events_list.adapter = this
|
||||||
}
|
}
|
||||||
}.apply {
|
|
||||||
month_day_events_list.adapter = this
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/month_day_calendar_holder"
|
android:id="@+id/month_day_calendar_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -24,15 +25,31 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/month_day_view_wrapper" />
|
app:layout_constraintTop_toBottomOf="@+id/month_day_view_wrapper" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
<RelativeLayout
|
||||||
android:id="@+id/month_day_events_list"
|
android:id="@+id/month_day_list_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:clipToPadding="false"
|
|
||||||
android:overScrollMode="never"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"
|
|
||||||
app:layout_constraintHeight_percent="0.7"
|
app:layout_constraintHeight_percent="0.7"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/month_day_view_wrapper" />
|
app:layout_constraintTop_toBottomOf="@+id/month_day_view_divider">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/month_day_selected_day_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:textSize="@dimen/bigger_text_size"
|
||||||
|
tools:text="8/5/2021" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
|
android:id="@+id/month_day_events_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@+id/month_day_selected_day_label"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
Loading…
Reference in a new issue