open the appropriate day after clicking it on the monthly view

This commit is contained in:
tibbi 2018-03-24 23:31:02 +01:00
parent 7c17438c0c
commit aeaa4c265f
2 changed files with 8 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import android.view.ViewGroup
import android.widget.DatePicker
import android.widget.RelativeLayout
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.MainActivity
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.helpers.Config
import com.simplemobiletools.calendar.helpers.DAY_CODE
@ -166,7 +167,9 @@ class MonthFragment : Fragment(), MonthlyCalendar {
}
private fun updateDays(days: ArrayList<DayMonthly>) {
mHolder.month_view_wrapper.updateDays(days)
mHolder.month_view_wrapper.updateDays(days) {
(activity as MainActivity).openDayFromMonthly(Formatter.getDateTimeFromCode(it.code))
}
/*val displayWeekNumbers = mConfig.displayWeekNumbers
val len = days.size

View File

@ -18,6 +18,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
private var days = ArrayList<DayMonthly>()
private var inflater: LayoutInflater
private var monthView: MonthView
private var dayClickCallback: ((day: DayMonthly) -> Unit)? = null
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)
@ -37,7 +38,8 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
}
}
fun updateDays(newDays: ArrayList<DayMonthly>) {
fun updateDays(newDays: ArrayList<DayMonthly>, callback: ((DayMonthly) -> Unit)? = null) {
dayClickCallback = callback
days = newDays
if (dayWidth != 0f) {
addViews()
@ -80,7 +82,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
x = xPos
y = yPos
setOnClickListener {
dayClickCallback?.invoke(day)
}
addView(this)
}