show only the proper events at month/day view
This commit is contained in:
parent
20345e3405
commit
2051287365
|
@ -955,7 +955,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
search_results_list.beVisibleIf(events.isNotEmpty())
|
search_results_list.beVisibleIf(events.isNotEmpty())
|
||||||
search_placeholder.beVisibleIf(events.isEmpty())
|
search_placeholder.beVisibleIf(events.isEmpty())
|
||||||
val listItems = getEventListItems(events)
|
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) {
|
if (it is ListEvent) {
|
||||||
Intent(applicationContext, EventActivity::class.java).apply {
|
Intent(applicationContext, EventActivity::class.java).apply {
|
||||||
putExtra(EVENT_ID, it.id)
|
putExtra(EVENT_ID, it.id)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
EventListAdapter(this, getListItems(), false, null, config_events_list) {}.apply {
|
EventListAdapter(this, getListItems(), false, null, config_events_list, true) {}.apply {
|
||||||
updateTextColor(mTextColor)
|
updateTextColor(mTextColor)
|
||||||
config_events_list.adapter = this
|
config_events_list.adapter = this
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import kotlinx.android.synthetic.main.event_list_section.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListItem>, val allowLongClick: Boolean, val listener: RefreshRecyclerViewListener?,
|
class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListItem>, 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 topDivider = resources.getDrawable(R.drawable.divider_width)
|
||||||
private val allDayString = resources.getString(R.string.all_day)
|
private val allDayString = resources.getString(R.string.all_day)
|
||||||
|
@ -176,7 +176,7 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
|
||||||
startTextColor = adjustedPrimaryColor
|
startTextColor = adjustedPrimaryColor
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dimPastEvents && listEvent.isPastEvent && !isPrintVersion) {
|
if (tryDimPastEvents && dimPastEvents && listEvent.isPastEvent && !isPrintVersion) {
|
||||||
startTextColor = startTextColor.adjustAlpha(LOW_ALPHA)
|
startTextColor = startTextColor.adjustAlpha(LOW_ALPHA)
|
||||||
endTextColor = endTextColor.adjustAlpha(LOW_ALPHA)
|
endTextColor = endTextColor.adjustAlpha(LOW_ALPHA)
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
val currAdapter = mView.calendar_events_list.adapter
|
val currAdapter = mView.calendar_events_list.adapter
|
||||||
if (currAdapter == null || forceRecreation) {
|
if (currAdapter == null || forceRecreation) {
|
||||||
EventListAdapter(activity as SimpleActivity, listItems, true, this, mView.calendar_events_list) {
|
EventListAdapter(activity as SimpleActivity, listItems, true, this, mView.calendar_events_list, true) {
|
||||||
if (it is ListEvent) {
|
if (it is ListEvent) {
|
||||||
context?.editEvent(it)
|
context?.editEvent(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import com.simplemobiletools.calendar.pro.helpers.MonthlyCalendarImpl
|
||||||
import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
|
import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
|
||||||
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
|
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
|
||||||
import com.simplemobiletools.calendar.pro.models.DayMonthly
|
import com.simplemobiletools.calendar.pro.models.DayMonthly
|
||||||
|
import com.simplemobiletools.calendar.pro.models.Event
|
||||||
import com.simplemobiletools.calendar.pro.models.ListEvent
|
import com.simplemobiletools.calendar.pro.models.ListEvent
|
||||||
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.*
|
||||||
|
@ -29,9 +30,11 @@ 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 mPackageName = ""
|
private var mPackageName = ""
|
||||||
private var mLastHash = 0L
|
private var mLastHash = 0L
|
||||||
private var mCalendar: MonthlyCalendarImpl? = null
|
private var mCalendar: MonthlyCalendarImpl? = null
|
||||||
|
private var mListEvents = ArrayList<Event>()
|
||||||
|
|
||||||
var listener: NavigationListener? = null
|
var listener: NavigationListener? = null
|
||||||
|
|
||||||
|
@ -45,6 +48,14 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
||||||
mPackageName = activity!!.packageName
|
mPackageName = activity!!.packageName
|
||||||
mHolder = view.month_day_calendar_holder
|
mHolder = view.month_day_calendar_holder
|
||||||
mDayCode = arguments!!.getString(DAY_CODE)!!
|
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
|
mConfig = context!!.config
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
setupButtons()
|
setupButtons()
|
||||||
|
@ -93,22 +104,32 @@ 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
|
||||||
|
updateVisibleEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val startDateTime = Formatter.getLocalDateTimeFromCode(mDayCode).minusWeeks(1)
|
val startDateTime = Formatter.getLocalDateTimeFromCode(mDayCode).minusWeeks(1)
|
||||||
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 ->
|
||||||
val listItems = context.getEventListItems(events, false)
|
mListEvents = events
|
||||||
activity?.runOnUiThread {
|
updateVisibleEvents()
|
||||||
EventListAdapter(activity as SimpleActivity, listItems, true, null, month_day_events_list) {
|
}
|
||||||
if (it is ListEvent) {
|
}
|
||||||
context.editEvent(it)
|
|
||||||
}
|
private fun updateVisibleEvents() {
|
||||||
}.apply {
|
val filtered = mListEvents.filter {
|
||||||
month_day_events_list.adapter = this
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue