Skip to content

Commit

Permalink
Accommodate nullable view holder when calculating calendar height.
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Jul 30, 2019
1 parent a4d5b89 commit 7da6091
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ internal class CalendarAdapter(
calWrapsHeight = it
}
if (calWrapsHeight.not()) return // Bug only happens when the CalenderView wraps its height.
val visibleVH = calView.findViewHolderForAdapterPosition(visibleItemPos) as MonthViewHolder
val visibleVH =
calView.findViewHolderForAdapterPosition(visibleItemPos) as? MonthViewHolder ?: return
val newHeight = visibleVH.headerView?.height.orZero() +
// For some reason `visibleVH.bodyLayout.height` does not give us the updated height.
// So we calculate it again by checking the number of visible(non-empty) rows.
Expand Down

0 comments on commit 7da6091

Please sign in to comment.