mirror of
				https://github.com/SimpleMobileTools/Simple-Calendar.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	update the hours scrollview margin if theres something at all-day top holder
This commit is contained in:
		| @@ -265,6 +265,7 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener { | |||||||
|  |  | ||||||
|     fun updateHoursTopMargin(margin: Int) { |     fun updateHoursTopMargin(margin: Int) { | ||||||
|         (week_view_hours_scrollview.layoutParams as LinearLayout.LayoutParams).setMargins(0, margin, 0, 0) |         (week_view_hours_scrollview.layoutParams as LinearLayout.LayoutParams).setMargins(0, margin, 0, 0) | ||||||
|  |         week_view_hours_scrollview.requestLayout() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun getWeekTimestamps(targetWeekTS: Int): List<Int> { |     private fun getWeekTimestamps(targetWeekTS: Int): List<Int> { | ||||||
|   | |||||||
| @@ -36,6 +36,9 @@ class WeekFragment : Fragment(), WeeklyCalendar { | |||||||
|     private var maxScrollY = -1 |     private var maxScrollY = -1 | ||||||
|     private var mWasDestroyed = false |     private var mWasDestroyed = false | ||||||
|     private var primaryColor = 0 |     private var primaryColor = 0 | ||||||
|  |     private var isFragmentVisible = false | ||||||
|  |     private var wasFragmentInit = false | ||||||
|  |  | ||||||
|     lateinit var mView: View |     lateinit var mView: View | ||||||
|     lateinit var mCalendar: WeeklyCalendarImpl |     lateinit var mCalendar: WeeklyCalendarImpl | ||||||
|     lateinit var mRes: Resources |     lateinit var mRes: Resources | ||||||
| @@ -70,9 +73,18 @@ class WeekFragment : Fragment(), WeeklyCalendar { | |||||||
|  |  | ||||||
|         mRes = resources |         mRes = resources | ||||||
|         mCalendar = WeeklyCalendarImpl(this, context) |         mCalendar = WeeklyCalendarImpl(this, context) | ||||||
|  |         wasFragmentInit = true | ||||||
|         return mView |         return mView | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     override fun setMenuVisibility(menuVisible: Boolean) { | ||||||
|  |         super.setMenuVisibility(menuVisible) | ||||||
|  |         isFragmentVisible = menuVisible | ||||||
|  |         if (isFragmentVisible && wasFragmentInit) { | ||||||
|  |             (activity as MainActivity).updateHoursTopMargin(mView.week_top_holder.height) | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     override fun onResume() { |     override fun onResume() { | ||||||
|         super.onResume() |         super.onResume() | ||||||
|         setupDayLabels() |         setupDayLabels() | ||||||
| @@ -86,7 +98,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { | |||||||
|                 mView.week_events_scrollview.viewTreeObserver.removeOnGlobalLayoutListener(this) |                 mView.week_events_scrollview.viewTreeObserver.removeOnGlobalLayoutListener(this) | ||||||
|                 minScrollY = mRowHeight * context.config.startWeeklyAt |                 minScrollY = mRowHeight * context.config.startWeeklyAt | ||||||
|                 maxScrollY = mRowHeight * context.config.endWeeklyAt |                 maxScrollY = mRowHeight * context.config.endWeeklyAt | ||||||
|                 (activity as MainActivity).updateHoursTopMargin(mView.week_letters_holder.height) |  | ||||||
|  |  | ||||||
|                 val bounds = Rect() |                 val bounds = Rect() | ||||||
|                 week_events_holder.getGlobalVisibleRect(bounds) |                 week_events_holder.getGlobalVisibleRect(bounds) | ||||||
| @@ -205,6 +216,15 @@ class WeekFragment : Fragment(), WeeklyCalendar { | |||||||
|                     leftMargin = firstDayIndex * dayColumnWidth |                     leftMargin = firstDayIndex * dayColumnWidth | ||||||
|                     width = (daysCnt + 1) * dayColumnWidth - mRes.displayMetrics.density.toInt() |                     width = (daysCnt + 1) * dayColumnWidth - mRes.displayMetrics.density.toInt() | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  |                 mView.week_top_holder.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { | ||||||
|  |                     override fun onGlobalLayout() { | ||||||
|  |                         mView.week_top_holder.viewTreeObserver.removeOnGlobalLayoutListener(this) | ||||||
|  |                         if (isFragmentVisible) { | ||||||
|  |                             (activity as MainActivity).updateHoursTopMargin(mView.week_top_holder.height) | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 }) | ||||||
|             } |             } | ||||||
|             setOnClickListener { |             setOnClickListener { | ||||||
|                 Intent(activity.applicationContext, EventActivity::class.java).apply { |                 Intent(activity.applicationContext, EventActivity::class.java).apply { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user