Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Apr 11, 2020
1 parent dddc0fe commit 079e31a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ open class CalendarView : RecyclerView {
*/
var wrappedPageHeightAnimationDuration = 200

private val pagerSnapHelper = CalenderPageSnapHelper()

private var startMonth: YearMonth? = null
private var endMonth: YearMonth? = null
private var firstDayOfWeek: DayOfWeek? = null
Expand All @@ -226,7 +228,7 @@ open class CalendarView : RecyclerView {
}

constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(attrs, defStyleAttr, 0)
init(attrs, defStyleAttr, defStyleAttr)
}

private fun init(attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) {
Expand Down Expand Up @@ -575,8 +577,6 @@ open class CalendarView : RecyclerView {
}
}

private val pagerSnapHelper = CalenderPageSnapHelper()

/**
* Setup the CalendarView. You can call this any time to change the
* the desired [startMonth], [endMonth] or [firstDayOfWeek] on the Calendar.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,16 @@ internal class CalendarAdapter(
visibleVH.footerView?.height.orZero()
if (calView.height != newHeight) {
ValueAnimator.ofInt(calView.height, newHeight).apply {
// Don't animate when the view is shown initially.
duration = if (initialLayout) 0 else calView.wrappedPageHeightAnimationDuration.toLong()
addUpdateListener {
calView.updateLayoutParams { height = it.animatedValue as Int }
visibleVH.itemView.requestLayout()
}
start()
}
if (initialLayout) initialLayout = false
}
if (initialLayout) initialLayout = false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ internal class CalendarLayoutManager(private val calView: CalendarView, @Recycle
targetPosition = position
}

override fun getVerticalSnapPreference(): Int {
return SNAP_TO_START
}
override fun getVerticalSnapPreference(): Int = SNAP_TO_START

override fun getHorizontalSnapPreference(): Int {
return SNAP_TO_START
}
override fun getHorizontalSnapPreference(): Int = SNAP_TO_START

override fun calculateDyToMakeVisible(view: View, snapPreference: Int): Int {
val dy = super.calculateDyToMakeVisible(view, snapPreference)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.recyclerview.widget.OrientationHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView

class CalenderPageSnapHelper : PagerSnapHelper() {
internal class CalenderPageSnapHelper : PagerSnapHelper() {

/**
* The default implementation of this method in [PagerSnapHelper.calculateDistanceToFinalSnap] uses the distance
Expand Down
3 changes: 2 additions & 1 deletion sample/src/main/res/layout/example_3_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="20dp"
android:tint="@color/white"
app:tint="@color/white"
app:backgroundTint="@color/colorAccent"
app:srcCompat="@drawable/ic_add" />

</FrameLayout>

0 comments on commit 079e31a

Please sign in to comment.