Skip to content

Commit dd8c4f3

Browse files
committed
Merge pull request #41 from caske33
2 parents a478990 + 1ff6067 commit dd8c4f3

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public class WeekView extends View {
9494
private int mDayNameLength = LENGTH_LONG;
9595
private int mOverlappingEventGap = 0;
9696
private int mEventMarginVertical = 0;
97+
private float mXScrollingSpeed = 1f;
9798
private Calendar mFirstVisibleDay;
9899
private Calendar mLastVisibleDay;
99100

@@ -134,7 +135,7 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
134135
mStickyScroller.forceFinished(true);
135136

136137
if (mCurrentFlingDirection == Direction.HORIZONTAL){
137-
mScroller.fling((int) mCurrentOrigin.x, 0, (int) velocityX, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0);
138+
mScroller.fling((int) mCurrentOrigin.x, 0, (int) (velocityX * mXScrollingSpeed), 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0);
138139
}
139140
else if (mCurrentFlingDirection == Direction.VERTICAL){
140141
mScroller.fling(0, (int) mCurrentOrigin.y, 0, (int) velocityY, 0, 0, (int) -(mHourHeight * 24 + mHeaderTextHeight + mHeaderRowPadding * 2 - getHeight()), 0);
@@ -222,6 +223,7 @@ public WeekView(Context context, AttributeSet attrs, int defStyleAttr) {
222223
mDayNameLength = a.getInteger(R.styleable.WeekView_dayNameLength, mDayNameLength);
223224
mOverlappingEventGap = a.getDimensionPixelSize(R.styleable.WeekView_overlappingEventGap, mOverlappingEventGap);
224225
mEventMarginVertical = a.getDimensionPixelSize(R.styleable.WeekView_eventMarginVertical, mEventMarginVertical);
226+
mXScrollingSpeed = a.getFloat(R.styleable.WeekView_xScrollingSpeed, mXScrollingSpeed);
225227
} finally {
226228
a.recycle();
227229
}
@@ -1124,6 +1126,21 @@ public Calendar getLastVisibleDay() {
11241126
return mLastVisibleDay;
11251127
}
11261128

1129+
/**
1130+
* Get the scrolling speed factor in horizontal direction.
1131+
* @return The speed factor in horizontal direction.
1132+
*/
1133+
public float getXScrollingSpeed() {
1134+
return mXScrollingSpeed;
1135+
}
1136+
1137+
/**
1138+
* Sets the speed for horizontal scrolling.
1139+
* @param xScrollingSpeed The new horizontal scrolling speed.
1140+
*/
1141+
public void setXScrollingSpeed(float xScrollingSpeed) {
1142+
this.mXScrollingSpeed = xScrollingSpeed;
1143+
}
11271144
/////////////////////////////////////////////////////////////////
11281145
//
11291146
// Functions related to scrolling.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
</attr>
3434
<attr name="overlappingEventGap" format="dimension"/>
3535
<attr name="eventMarginVertical" format="dimension"/>
36-
36+
<attr name="xScrollingSpeed" format="float"/>
3737
</declare-styleable>
3838
</resources>

0 commit comments

Comments
 (0)