Skip to content

Commit

Permalink
Change Readme for add minimum and maximum
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Jamet committed Jan 12, 2017
1 parent 5ed0655 commit db65b37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
22 changes: 16 additions & 6 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Add the JitPack repository in your build.gradle at the end of repositories:
And add the dependency
```
dependencies {
compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.3'
compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.4'
}
```

Expand All @@ -48,6 +48,12 @@ For launch Dialog with a specific view, call :
`dateTimeFragment.startAtTimeView();`, `dateTimeFragment.startAtCalendarView();` or `dateTimeFragment.startAtYearView();`
before the "show"

### Define minimum and maximum
For just allow selection after or/and before dates, use :
`dateTimeFragment.setMinimumDateTime(Date minimum);`
and
`dateTimeFragment.setMaximumDateTime(Date maximum);`

### Style
You can customize the style to change color, bold, etc... of each element.
You need to use a Theme.AppCompat theme (or descendant) with SwitchDateTime's activity. (`compile 'com.android.support:appcompat-v7:25.1.0'` in gradle)
Expand Down Expand Up @@ -92,11 +98,15 @@ SwitchDateTimeDialogFragment dateTimeDialogFragment = SwitchDateTimeDialogFragme
// Assign values
dateTimeFragment.startAtCalendarView();
dateTimeFragment.set24HoursMode(true);
dateTimeFragment.setDefaultHourOfDay(15);
dateTimeFragment.setDefaultMinute(20);
dateTimeFragment.setDefaultDay(4);
dateTimeFragment.setDefaultMonth(Calendar.DECEMBER);
dateTimeFragment.setDefaultYear(2018);
dateTimeFragment.setMinimumDateTime(new GregorianCalendar(2015, Calendar.JANUARY, 1).getTime());
dateTimeFragment.setMaximumDateTime(new GregorianCalendar(2025, Calendar.DECEMBER, 31).getTime());
dateTimeFragment.setDefaultDateTime(new GregorianCalendar(2017, Calendar.MARCH, 4, 15, 20).getTime());
// Or assign each element, default element is the current moment
// dateTimeFragment.setDefaultHourOfDay(15);
// dateTimeFragment.setDefaultMinute(20);
// dateTimeFragment.setDefaultDay(4);
// dateTimeFragment.setDefaultMonth(Calendar.MARCH);
// dateTimeFragment.setDefaultYear(2017);
// Define new day and month format
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ protected void onCreate(Bundle savedInstanceState) {
final SimpleDateFormat myDateFormat = new SimpleDateFormat("d MMM yyyy HH:mm", java.util.Locale.getDefault());
dateTimeFragment.startAtCalendarView();
dateTimeFragment.set24HoursMode(true);
// WARNING 0 <= MONTH <= 11
dateTimeFragment.setMinimumDateTime(new GregorianCalendar(2015, Calendar.JANUARY, 1).getTime());
dateTimeFragment.setMaximumDateTime(new GregorianCalendar(2025, Calendar.DECEMBER, 31).getTime());
dateTimeFragment.setDefaultDateTime(new GregorianCalendar(2017, Calendar.MARCH, 4, 15, 20).getTime());
Expand Down

0 comments on commit db65b37

Please sign in to comment.