Skip to content

Commit f753839

Browse files
committed
Support for "go to hour" added
1 parent 94c1c73 commit f753839

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ Usage
3131
<dependency>
3232
<groupId>com.github.alamkanak</groupId>
3333
<artifactId>android-week-view</artifactId>
34-
<version>1.1.6</version>
34+
<version>1.1.7</version>
3535
<type>aar</type>
3636
</dependency>
3737
```
3838
* Grab via gradle
3939

4040
```groovy
41-
compile 'com.github.alamkanak:android-week-view:1.1.6'
41+
compile 'com.github.alamkanak:android-week-view:1.1.7'
4242
```
4343
2. Add WeekView in your xml layout.
4444

@@ -132,6 +132,10 @@ To do
132132
Changelog
133133
---------
134134

135+
**Version 1.1.7**
136+
137+
* You can now dynamically scroll to an hour of your preference.
138+
135139
**Version 1.1.6**
136140

137141
* Added support for events that expands to multiple days

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION_NAME=1.1.6
1+
VERSION_NAME=1.1.7
22
GROUP=com.github.alamkanak
33

44
POM_DESCRIPTION=Dissect layout traversals on Android.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,23 @@ public void notifyDatasetChanged(){
12151215
invalidate();
12161216
}
12171217

1218+
/**
1219+
* Vertically scroll to a specific hour in the week view.
1220+
* @param hour The hour to scroll to in 24-hour format. Supported values are 0-24.
1221+
*/
1222+
public void goToHour(double hour){
1223+
if (hour < 0)
1224+
throw new IllegalArgumentException("Cannot scroll to an hour of negative value.");
1225+
else if (hour > 24)
1226+
throw new IllegalArgumentException("Cannot scroll to an hour of value greater than 24.");
1227+
else if (hour * mHourHeight > mHourHeight * 24 - getHeight() + mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom)
1228+
throw new IllegalArgumentException("Cannot scroll to an hour which will result the calendar to go off the screen.");
1229+
1230+
int verticalOffset = (int) (mHourHeight * hour);
1231+
mCurrentOrigin.y = -verticalOffset;
1232+
invalidate();
1233+
}
1234+
12181235

12191236

12201237
/////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)