Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Dec 13, 2023
1 parent 4955820 commit 8c6a2aa
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ open class CalendarView : RecyclerView {
}
if (
(orientation == HORIZONTAL && pageSnapHelper !== horizontalSnapHelper) ||
(orientation != VERTICAL && pageSnapHelper !== verticalSnapHelper)
(orientation == VERTICAL && pageSnapHelper !== verticalSnapHelper)
) {
// Remove the currently attached snap helper.
pageSnapHelper.attachToRecyclerView(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ internal fun <Day, Container : ViewContainer> setupItemRoot(
)

val weekHolders = List(weekSize) {
WeekHolder(dayConfig.daySize, List(7) { DayHolder(dayConfig) })
WeekHolder(
daySize = dayConfig.daySize,
dayHolders = List(size = 7) { DayHolder(dayConfig) },
)
}.onEach { weekHolder ->
rootLayout.addView(weekHolder.inflateWeekView(rootLayout))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ private class WidthDivisorLinearLayout : LinearLayout {
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) :
super(context, attrs, defStyle)

var widthDivisor: Int = 0
var widthDivisorForHeight: Int = 0

override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
@Suppress("NAME_SHADOWING")
val heightMeasureSpec = if (widthDivisor > 0) {
val heightMeasureSpec = if (widthDivisorForHeight > 0) {
val width = MeasureSpec.getSize(widthMeasureSpec)
MeasureSpec.makeMeasureSpec(width / widthDivisor, MeasureSpec.EXACTLY)
MeasureSpec.makeMeasureSpec(width / widthDivisorForHeight, MeasureSpec.EXACTLY)
} else {
heightMeasureSpec
}
Expand Down Expand Up @@ -53,7 +53,7 @@ internal class WeekHolder<Day>(
layoutParams = LinearLayout.LayoutParams(width, height, weight)
orientation = LinearLayout.HORIZONTAL
weightSum = dayHolders.count().toFloat()
widthDivisor = if (daySize == DaySize.Square) dayHolders.count() else 0
widthDivisorForHeight = if (daySize == DaySize.Square) dayHolders.count() else 0
for (holder in dayHolders) {
addView(holder.inflateDayView(this))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.kizitonwose.calendar.view.MonthHeaderFooterBinder
import com.kizitonwose.calendar.view.ViewContainer
import com.kizitonwose.calendar.view.internal.WeekHolder

internal class MonthViewHolder constructor(
internal class MonthViewHolder(
rootLayout: ViewGroup,
private val headerView: View?,
private val footerView: View?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.kizitonwose.calendar.view.ViewContainer
import com.kizitonwose.calendar.view.WeekHeaderFooterBinder
import com.kizitonwose.calendar.view.internal.WeekHolder

internal class WeekViewHolder constructor(
internal class WeekViewHolder(
rootLayout: ViewGroup,
private val headerView: View?,
private val footerView: View?,
Expand Down

0 comments on commit 8c6a2aa

Please sign in to comment.