Skip to content

Commit

Permalink
Fix #266
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Feb 14, 2021
1 parent 107f827 commit edb8046
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.kizitonwose.calendarview.CalendarView
import com.kizitonwose.calendarview.model.*
import com.kizitonwose.calendarview.utils.NO_INDEX
import com.kizitonwose.calendarview.utils.getVerticalMargins
import com.kizitonwose.calendarview.utils.inflate
import com.kizitonwose.calendarview.utils.orZero
import java.time.LocalDate
Expand Down Expand Up @@ -218,29 +217,26 @@ internal class CalendarAdapter(
val visibleVH =
calView.findViewHolderForAdapterPosition(visibleItemPos) as? MonthViewHolder ?: return
val newHeight = visibleVH.headerView?.height.orZero() +
visibleVH.headerView?.getVerticalMargins().orZero() +
// visibleVH.bodyLayout.height` won't not give us the right height as it differs
// depending on row count in the month. So we calculate the appropriate height
// by checking the number of visible(non-empty) rows.
visibleMonth.weekDays.size * calView.daySize.height +
visibleVH.footerView?.height.orZero() +
visibleVH.footerView?.getVerticalMargins().orZero()

This comment has been minimized.

Copy link
@caraesten

caraesten Feb 25, 2021

hey @kizitonwose , did you mean to remove this? it looks like my fix for the calendar height is no longer present in the release?

This comment has been minimized.

Copy link
@kizitonwose

kizitonwose Feb 26, 2021

Author Owner

Wow. Looks like I did remove it 🤦🏼 . It definitely was not intentional as the fix was included in the release notes for 1.0.2. I'll fix it over the weekend.

This comment has been minimized.

Copy link
@caraesten

caraesten Feb 26, 2021

no worries! and thanks for the quick response :). I had just moved us from a custom AAR to the published one and was like "hey wait a second..." haha

if (calView.height != newHeight) {
visibleVH.footerView?.height.orZero()
if (calView.height != newHeight && !initialLayout) {
ValueAnimator.ofInt(calView.height, newHeight).apply {
// Don't animate when the view is shown initially.
duration = if (initialLayout) 0 else calView.wrappedPageHeightAnimationDuration.toLong()
duration = calView.wrappedPageHeightAnimationDuration.toLong()
addUpdateListener {
calView.updateLayoutParams { height = it.animatedValue as Int }
visibleVH.itemView.requestLayout()
}
start()
}
}
if (initialLayout) {
initialLayout = false
// Request layout in case dataset was changed. See issue #199
} else {
// Fixes #199, #266
visibleVH.itemView.requestLayout()
}
if (initialLayout) initialLayout = false
}
}
}
Expand Down

0 comments on commit edb8046

Please sign in to comment.