set up the weekly view hour height dynamically too

This commit is contained in:
tibbi 2020-03-22 18:10:20 +01:00
parent 7062cc3b49
commit def42889dc
2 changed files with 10 additions and 1 deletions

View File

@ -62,6 +62,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun setupFragment() { private fun setupFragment() {
val weekTSs = getWeekTimestamps(currentWeekTS) val weekTSs = getWeekTimestamps(currentWeekTS)
val weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this) val weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this)
val itemHeight = context!!.config.weeklyViewItemHeight.toInt()
val textColor = context!!.config.textColor val textColor = context!!.config.textColor
weekHolder!!.week_view_hours_holder.removeAllViews() weekHolder!!.week_view_hours_holder.removeAllViews()
@ -71,6 +72,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
(layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView).apply { (layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView).apply {
text = formattedHours text = formattedHours
setTextColor(textColor) setTextColor(textColor)
height = itemHeight
weekHolder!!.week_view_hours_holder.addView(this) weekHolder!!.week_view_hours_holder.addView(this)
} }
} }
@ -107,6 +109,14 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
updateActionBarTitle() updateActionBarTitle()
} }
private fun updateRowHeight() {
val childCnt = weekHolder!!.week_view_hours_holder.childCount
for (i in 0..childCnt) {
val textView = weekHolder!!.week_view_hours_holder.getChildAt(i) as? TextView ?: continue
textView.layoutParams.height = context!!.config.weeklyViewItemHeight.toInt()
}
}
private fun getWeekTimestamps(targetSeconds: Long): List<Long> { private fun getWeekTimestamps(targetSeconds: Long): List<Long> {
val weekTSs = ArrayList<Long>(PREFILLED_WEEKS) val weekTSs = ArrayList<Long>(PREFILLED_WEEKS)
val dateTime = Formatter.getDateTimeFromTS(targetSeconds) val dateTime = Formatter.getDateTimeFromTS(targetSeconds)

View File

@ -5,7 +5,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="bottom|center_horizontal" android:gravity="bottom|center_horizontal"
android:minHeight="@dimen/weekly_view_row_height"
android:paddingStart="@dimen/small_margin" android:paddingStart="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin" android:paddingEnd="@dimen/small_margin"
android:textSize="@dimen/normal_text_size" /> android:textSize="@dimen/normal_text_size" />