Skip to content

Commit f07ac7b

Browse files
author
Jens Claes
committed
Merge branch 'pr-276' into develop
Conflicts: library/src/main/java/com/alamkanak/weekview/WeekView.java library/src/main/res/values/attrs.xml
2 parents 1599e2f + c575888 commit f07ac7b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ You can customize the look of the `WeekView` in xml. Use the following attribute
127127
- `showNowLine`
128128
- `nowLineColor`
129129
- `nowLineThickness`
130+
- `scrollDuration`
130131

131132
Interfaces
132133
----------

library/src/main/java/com/alamkanak/weekview/WeekView.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private enum Direction {
141141
private boolean mHorizontalFlingEnabled = true;
142142
private boolean mVerticalFlingEnabled = true;
143143
private int mAllDayEventHeight = 100;
144+
private int mScrollDuration = 250;
144145

145146
// Listeners.
146147
private EventClickListener mEventClickListener;
@@ -349,6 +350,7 @@ public WeekView(Context context, AttributeSet attrs, int defStyleAttr) {
349350
mHorizontalFlingEnabled = a.getBoolean(R.styleable.WeekView_horizontalFlingEnabled, mHorizontalFlingEnabled);
350351
mVerticalFlingEnabled = a.getBoolean(R.styleable.WeekView_verticalFlingEnabled, mVerticalFlingEnabled);
351352
mAllDayEventHeight = a.getDimensionPixelSize(R.styleable.WeekView_allDayEventHeight, mAllDayEventHeight);
353+
mScrollDuration = a.getInt(R.styleable.WeekView_scrollDuration, mScrollDuration);
352354
} finally {
353355
a.recycle();
354356
}
@@ -1828,6 +1830,21 @@ public void setAllDayEventHeight(int height) {
18281830
mAllDayEventHeight = height;
18291831
}
18301832

1833+
/**
1834+
* Get scroll duration
1835+
* @return scroll duration
1836+
*/
1837+
public int getScrollDuration() {
1838+
return mScrollDuration;
1839+
}
1840+
1841+
/**
1842+
* Set the scroll duration
1843+
*/
1844+
public void setScrollDuration(int scrollDuration) {
1845+
mScrollDuration = scrollDuration;
1846+
}
1847+
18311848
/////////////////////////////////////////////////////////////////
18321849
//
18331850
// Functions related to scrolling.
@@ -1873,7 +1890,7 @@ private void goToNearestOrigin(){
18731890
// Stop current animation.
18741891
mScroller.forceFinished(true);
18751892
// Snap to date.
1876-
mScroller.startScroll((int) mCurrentOrigin.x, (int) mCurrentOrigin.y, -nearestOrigin, 0, (int) (Math.abs(nearestOrigin) / mWidthPerDay * 500));
1893+
mScroller.startScroll((int) mCurrentOrigin.x, (int) mCurrentOrigin.y, -nearestOrigin, 0, (int) (Math.abs(nearestOrigin) / mWidthPerDay * mScrollDuration));
18771894
ViewCompat.postInvalidateOnAnimation(WeekView.this);
18781895
}
18791896
// Reset scrolling and fling direction.

library/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@
5050
<attr name="horizontalFlingEnabled" format="boolean"/>
5151
<attr name="verticalFlingEnabled" format="boolean"/>
5252
<attr name="allDayEventHeight" format="dimension"/>
53+
<attr name="scrollDuration" format="integer"/>
5354
</declare-styleable>
5455
</resources>

0 commit comments

Comments
 (0)