mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
properly update everything at the weekly view on zoom
This commit is contained in:
@ -50,6 +50,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
private var currentTimeView: ImageView? = null
|
private var currentTimeView: ImageView? = null
|
||||||
private var allDayHolders = ArrayList<RelativeLayout>()
|
private var allDayHolders = ArrayList<RelativeLayout>()
|
||||||
private var allDayRows = ArrayList<HashSet<Int>>()
|
private var allDayRows = ArrayList<HashSet<Int>>()
|
||||||
|
private var currEvents = ArrayList<Event>()
|
||||||
private var eventTypeColors = LongSparseArray<Int>()
|
private var eventTypeColors = LongSparseArray<Int>()
|
||||||
private var eventTimeRanges = LinkedHashMap<String, ArrayList<EventWeeklyView>>()
|
private var eventTimeRanges = LinkedHashMap<String, ArrayList<EventWeeklyView>>()
|
||||||
|
|
||||||
@ -222,7 +223,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
override fun onScaleEnd(detector: ScaleGestureDetector) {
|
override fun onScaleEnd(detector: ScaleGestureDetector) {
|
||||||
val newFactor = Math.max(Math.min(config.weeklyViewItemHeightMultiplier * detector.scaleFactor, MAX_ZOOM_FACTOR), MIN_ZOOM_FACTOR)
|
val newFactor = Math.max(Math.min(config.weeklyViewItemHeightMultiplier * detector.scaleFactor, MAX_ZOOM_FACTOR), MIN_ZOOM_FACTOR)
|
||||||
config.weeklyViewItemHeightMultiplier = newFactor
|
config.weeklyViewItemHeightMultiplier = newFactor
|
||||||
listener?.updateRowHeight()
|
updateViewScale()
|
||||||
|
|
||||||
mView.week_events_scrollview.isScrollable = true
|
mView.week_events_scrollview.isScrollable = true
|
||||||
super.onScaleEnd(detector)
|
super.onScaleEnd(detector)
|
||||||
}
|
}
|
||||||
@ -244,11 +246,21 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
compareBy<Event> { it.startTS }.thenBy { it.endTS }.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description }
|
compareBy<Event> { it.startTS }.thenBy { it.endTS }.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description }
|
||||||
).toMutableList() as ArrayList<Event>
|
).toMutableList() as ArrayList<Event>
|
||||||
|
|
||||||
|
currEvents = sorted
|
||||||
addEvents(sorted)
|
addEvents(sorted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateViewScale() {
|
||||||
|
rowHeight = context!!.getWeeklyViewItemHeight()
|
||||||
|
listener?.updateRowHeight(rowHeight.toInt())
|
||||||
|
val fullHeight = Math.max(rowHeight.toInt() * 24, mView.week_events_scrollview.height + 5)
|
||||||
|
mView.week_horizontal_grid_holder.layoutParams.height = fullHeight
|
||||||
|
mView.week_events_columns_holder.layoutParams.height = fullHeight
|
||||||
|
addEvents(currEvents)
|
||||||
|
}
|
||||||
|
|
||||||
private fun addEvents(events: ArrayList<Event>) {
|
private fun addEvents(events: ArrayList<Event>) {
|
||||||
initGrid()
|
initGrid()
|
||||||
allDayHolders.clear()
|
allDayHolders.clear()
|
||||||
|
@ -210,14 +210,13 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||||||
|
|
||||||
override fun getCurrScrollY() = weekScrollY
|
override fun getCurrScrollY() = weekScrollY
|
||||||
|
|
||||||
override fun updateRowHeight() {
|
override fun updateRowHeight(rowHeight: Int) {
|
||||||
val childCnt = weekHolder!!.week_view_hours_holder.childCount
|
val childCnt = weekHolder!!.week_view_hours_holder.childCount
|
||||||
val itemHeight = context!!.getWeeklyViewItemHeight().toInt()
|
|
||||||
for (i in 0..childCnt) {
|
for (i in 0..childCnt) {
|
||||||
val textView = weekHolder!!.week_view_hours_holder.getChildAt(i) as? TextView ?: continue
|
val textView = weekHolder!!.week_view_hours_holder.getChildAt(i) as? TextView ?: continue
|
||||||
textView.layoutParams.height = itemHeight
|
textView.layoutParams.height = rowHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, itemHeight)
|
weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, rowHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,5 @@ interface WeekFragmentListener {
|
|||||||
|
|
||||||
fun getCurrScrollY(): Int
|
fun getCurrScrollY(): Int
|
||||||
|
|
||||||
fun updateRowHeight()
|
fun updateRowHeight(rowHeight: Int)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user