populate the list view at month+day view too
This commit is contained in:
parent
159f08d24c
commit
e545ff30ad
|
@ -456,7 +456,7 @@ fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resou
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.getEventListItems(events: List<Event>): ArrayList<ListItem> {
|
||||
fun Context.getEventListItems(events: List<Event>, addSections: Boolean = true): ArrayList<ListItem> {
|
||||
val listItems = ArrayList<ListItem>(events.size)
|
||||
val replaceDescription = config.replaceDescription
|
||||
|
||||
|
@ -481,7 +481,7 @@ fun Context.getEventListItems(events: List<Event>): ArrayList<ListItem> {
|
|||
|
||||
sorted.forEach {
|
||||
val code = Formatter.getDayCodeFromTS(it.startTS)
|
||||
if (code != prevCode) {
|
||||
if (code != prevCode && addSections) {
|
||||
val day = Formatter.getDayTitle(this, code)
|
||||
val isToday = day == today
|
||||
val listSection = ListSection(day, code, isToday, !isToday && it.startTS < now)
|
||||
|
@ -553,3 +553,11 @@ fun Context.printBitmap(bitmap: Bitmap) {
|
|||
printHelper.orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
printHelper.printBitmap(getString(R.string.app_name), bitmap)
|
||||
}
|
||||
|
||||
fun Context.editEvent(event: ListEvent) {
|
||||
Intent(this, EventActivity::class.java).apply {
|
||||
putExtra(EVENT_ID, event.id)
|
||||
putExtra(EVENT_OCCURRENCE_TS, event.startTS)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||
if (currAdapter == null || forceRecreation) {
|
||||
EventListAdapter(activity as SimpleActivity, listItems, true, this, mView.calendar_events_list) {
|
||||
if (it is ListEvent) {
|
||||
editEvent(it)
|
||||
context?.editEvent(it)
|
||||
}
|
||||
}.apply {
|
||||
mView.calendar_events_list.adapter = this
|
||||
|
@ -169,14 +169,6 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||
mView.calendar_empty_list_placeholder.setTextColor(activity!!.config.textColor)
|
||||
}
|
||||
|
||||
private fun editEvent(event: ListEvent) {
|
||||
Intent(context, EventActivity::class.java).apply {
|
||||
putExtra(EVENT_ID, event.id)
|
||||
putExtra(EVENT_OCCURRENCE_TS, event.startTS)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchPreviousPeriod() {
|
||||
val lastPosition = (mView.calendar_events_list.layoutManager as MyLinearLayoutManager).findLastVisibleItemPosition()
|
||||
bottomItemAtRefresh = (mView.calendar_events_list.adapter as EventListAdapter).listItems[lastPosition]
|
||||
|
|
|
@ -9,7 +9,9 @@ import android.view.ViewGroup
|
|||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.calendar.pro.adapters.EventListAdapter
|
||||
import com.simplemobiletools.calendar.pro.extensions.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.Config
|
||||
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
|
@ -17,6 +19,8 @@ import com.simplemobiletools.calendar.pro.helpers.MonthlyCalendarImpl
|
|||
import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
|
||||
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
|
||||
import com.simplemobiletools.calendar.pro.models.DayMonthly
|
||||
import com.simplemobiletools.calendar.pro.models.ListEvent
|
||||
import kotlinx.android.synthetic.main.fragment_month_day.*
|
||||
import kotlinx.android.synthetic.main.fragment_month_day.view.*
|
||||
import org.joda.time.DateTime
|
||||
|
||||
|
@ -43,10 +47,8 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
|||
mDayCode = arguments!!.getString(DAY_CODE)!!
|
||||
mConfig = context!!.config
|
||||
storeStateVariables()
|
||||
|
||||
setupButtons()
|
||||
mCalendar = MonthlyCalendarImpl(this, context!!)
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
|
@ -90,7 +92,24 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
|||
mLastHash = newHash
|
||||
|
||||
activity?.runOnUiThread {
|
||||
updateDays(days)
|
||||
mHolder.month_day_view_wrapper.updateDays(days, false) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,11 +117,5 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
|
|||
mTextColor = mConfig.textColor
|
||||
}
|
||||
|
||||
private fun updateDays(days: ArrayList<DayMonthly>) {
|
||||
mHolder.month_day_view_wrapper.updateDays(days, false) {
|
||||
// (activity as MainActivity).openDayFromMonthly(Formatter.getDateTimeFromCode(it.code))
|
||||
}
|
||||
}
|
||||
|
||||
fun printCurrentView() {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue