Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
heysupratim committed Sep 18, 2015
2 parents 9b5f6d1 + ee55530 commit 34679f9
Showing 1 changed file with 45 additions and 7 deletions.
52 changes: 45 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
Material Date Picker with FROM and TO Date Range Selection
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MaterialDateRangePicker-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2501)

Material Date and Time Picker with Range Selection
======================================================


Credit to the original amazing material date picker library by wdullaer - https://github.com/wdullaer/MaterialDateTimePicker

Screens
##Update
-Added Time Range Picker


![FROM](/screenshots/1.png?raw=true)
##Date Selection

![FROM](/screenshots/2.png?raw=true)
![TO](/screenshots/1.png?raw=true)

##Time Selection

![FROM](/screenshots/3.png?raw=true)
![TO](/screenshots/4.png?raw=true)

Support for Android 4.0 and up.

From the original library documentation -
Expand All @@ -18,18 +29,34 @@ You may also add the library as an Android Library to your project. All the libr
Using the Pickers
--------------------------------

1. Implement an `OnDateSetListener`
1. Implement an `OnDateSetListener` or `OnTimeSetListener`
2. Create a ``DatePickerDialog` using the supplied factory

### Implement an `OnDateSetListener`
In order to receive the date set in the picker, you will need to implement the `OnDateSetListener` interfaces. Typically this will be the `Activity` or `Fragment` that creates the Pickers.

or
### Implement an `OnTimeSetListener`
In order to receive the time set in the picker, you will need to implement the `OnTimeSetListener` interfaces. Typically this will be the `Activity` or `Fragment` that creates the Pickers.

```java

//new onDateSet
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth,int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {

}

@Override
public void onTimeSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth,int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {
String hourString = hourOfDay < 10 ? "0"+hourOfDay : ""+hourOfDay;
String minuteString = minute < 10 ? "0"+minute : ""+minute;
String hourStringEnd = hourOfDayEnd < 10 ? "0"+hourOfDayEnd : ""+hourOfDayEnd;
String minuteStringEnd = minuteEnd < 10 ? "0"+minuteEnd : ""+minuteEnd;
String time = "You picked the following time: From - "+hourString+"h"+minuteString+" To - "+hourStringEnd+"h"+minuteStringEnd;

timeTextView.setText(time);

}
```

Expand All @@ -46,10 +73,21 @@ DatePickerDialog dpd = DatePickerDialog.newInstance(
dpd.show(getFragmentManager(), "Datepickerdialog");
```

### Create a TimePickerDialog` using the supplied factory
You will need to create a new instance of `TimePickerDialog` using the static `newInstance()` method, supplying proper default values and a callback. Once the dialogs are configured, you can call `show()`.
```java
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(
MainActivity.this,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
false
);
tpd.show(getFragmentManager(), "Timepickerdialog");
```

For other documentation regarding theming , handling orientation changes , and callbacks - check out the original documentation - https://github.com/wdullaer/MaterialDateTimePicker

TODO
----

1. Add the range picker for time too
2. More device config handling
1. More device config handling

0 comments on commit 34679f9

Please sign in to comment.