Skip to content

Commit

Permalink
Fix min and max time
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoobergs committed Feb 12, 2017
1 parent f9821f0 commit 8341365
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 61 deletions.
3 changes: 1 addition & 2 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alamkanak.weekview">
<manifest package="com.alamkanak.weekview">
</manifest>
127 changes: 73 additions & 54 deletions library/src/main/java/com/alamkanak/weekview/WeekView.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.alamkanak.weekview;

import android.graphics.Shader;
import android.widget.ShareActionProvider;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import static com.alamkanak.weekview.WeekViewUtil.*;
import static com.alamkanak.weekview.WeekViewUtil.isSameDay;

/**
* Created by Raquib-ul-Alam Kanak on 7/21/2014.
Expand Down
23 changes: 21 additions & 2 deletions library/src/main/java/com/alamkanak/weekview/WeekViewUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,29 @@ public static boolean isSameDayAndHour(Calendar dateOne, Calendar dateTwo) {
* @param dateTwo the second date
* @return the amount of days between dateTwo and dateOne
*/
public static int daysBetween(Calendar dateOne, Calendar dateTwo){
public static int daysBetween(Calendar dateOne, Calendar dateTwo) {
return (int) (
(dateTwo.getTimeInMillis() + dateTwo.getTimeZone().getOffset(dateTwo.getTimeInMillis()) -
(dateOne.getTimeInMillis() + dateOne.getTimeZone().getOffset(dateOne.getTimeInMillis())))
(dateOne.getTimeInMillis() + dateOne.getTimeZone().getOffset(dateOne.getTimeInMillis())))
/ (1000 * 60 * 60 * 24f));
}

/*
* Returns the amount of minutes passed in the day before the time in the given date
* @param date
* @return amount of minutes in day before time
*/
public static int getPassedMinutesInDay(Calendar date){
return getPassedMinutesInDay(date.get(Calendar.HOUR_OF_DAY), date.get(Calendar.MINUTE));
}

/**
* Returns the amount of minutes in the given hours and minutes
* @param hour
* @param minute
* @return amount of minutes in the given hours and minutes
*/
public static int getPassedMinutesInDay(int hour, int minute){
return hour * 60 + minute;
}
}
2 changes: 2 additions & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@
<attr name="scrollDuration" format="integer"/>
<attr name="showHalfHours" format="boolean" />
<attr name="autoLimitTime" format="boolean"/>
<attr name="minTime" format="integer"/>
<attr name="maxTime" format="integer"/>
</declare-styleable>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ protected void onCreate(Bundle savedInstanceState) {
calendar.add(Calendar.DATE, -2);
mWeekView.goToDate(calendar);*/

//mWeekView.setAutoLimitTime(true);
//mWeekView.setLimitTime(4, 16);


// Set up a date time interpreter to interpret how the date and time will be formatted in
// the week view. This is optional.
setupDateTimeInterpreter(false);
Expand Down
5 changes: 4 additions & 1 deletion sample/src/main/res/layout/activity_base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
app:headerRowPadding="12dp"
app:columnGap="8dp"
app:noOfVisibleDays="3"
app:minTime="4"
app:maxTime="16"
app:autoLimitTime="false"
app:headerRowBackgroundColor="@color/toolbar"
app:dayBackgroundColor="#05000000"
app:todayBackgroundColor="#1848adff"
app:headerColumnBackground="#ffffffff"
app:todayHeaderTextColor="@color/accent"
app:newEventTimeResolutionInMinutes="15"
app:showHalfHours="false" />
app:showHalfHours="true" />

</RelativeLayout>

0 comments on commit 8341365

Please sign in to comment.