Skip to content

Commit

Permalink
merged #3 and released v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosh committed Jan 21, 2017
1 parent 0e29a98 commit d547021
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 35 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Android Library to help you with your date & time pickers while retaining the in

#### Gradle
```groovy
compile 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.1'
compile 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.2'
```

#### Maven
```xml
<dependency>
<groupId>com.github.k0shk0sh</groupId>
<artifactId>RetainedDateTimePickers</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<type>aar</type>
</dependency>
```
Expand Down Expand Up @@ -80,11 +80,6 @@ Screenshots
<img src="https://raw.github.com/k0shk0sh/RetainedDateTimePickers/master/art/custom_theme_time.png" width="250" height="444" />


TODO
=====

- ~~To supports `ParentFragment` (very soon).~~

# Why this library?

* DatePickerDialog & TimePickerDialog are not retained on orientation change, you'd do a lot of work to retain them, this library simplify that.
Expand Down
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
applicationId "com.fastaccess.datetimepicker.sample"
minSdkVersion 16
targetSdkVersion 24
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -21,8 +22,8 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
compile project(':datetimepicker')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ void onClick(View view) {
maxDate.set(2016, minDate.get(Calendar.MONTH) + 1, minDate.get(Calendar.DAY_OF_MONTH));
switch (view.getId()) {
case R.id.datePickerOnly:
DatePickerFragmentDialog.newInstance().show(getSupportFragmentManager(), "DatePickerFragmentDialog");
DatePickerFragmentDialog.newInstance().show(getSupportFragmentManager(), SampleHelper.DATE_PICKER_FRAGMENT_DIALOG);
break;
case R.id.datePickerMinMaxPicker:
DatePickerFragmentDialog.newInstance(DateTimeBuilder.get()
DatePickerFragmentDialog.newInstance(DateTimeBuilder.newInstance()
.withMinDate(minDate.getTimeInMillis())
.withMaxDate(maxDate.getTimeInMillis()))
.show(getSupportFragmentManager(), "DatePickerFragmentDialog");
.show(getSupportFragmentManager(), SampleHelper.DATE_PICKER_FRAGMENT_DIALOG);
break;
case R.id.timePickerOnly:
TimePickerFragmentDialog.newInstance().show(getSupportFragmentManager(), "TimePickerFragmentDialog");
TimePickerFragmentDialog.newInstance().show(getSupportFragmentManager(), SampleHelper.TIME_PICKER_FRAGMENT_DIALOG);
break;
case R.id.timePickerOnly24Hours:
TimePickerFragmentDialog.newInstance(true).show(getSupportFragmentManager(), "TimePickerFragmentDialog");
TimePickerFragmentDialog.newInstance(true).show(getSupportFragmentManager(), SampleHelper.TIME_PICKER_FRAGMENT_DIALOG);
break;
case R.id.dateAndTimePicker:
DatePickerFragmentDialog.newInstance(true).show(getSupportFragmentManager(), "DatePickerFragmentDialog");
DatePickerFragmentDialog.newInstance(true).show(getSupportFragmentManager(), SampleHelper.DATE_PICKER_FRAGMENT_DIALOG);
break;
case R.id.ultimatePicker:
Calendar currentDate = Calendar.getInstance();
currentDate.set(2016, currentDate.get(Calendar.MONTH) + 1, currentDate.get(Calendar.DAY_OF_MONTH));
DatePickerFragmentDialog.newInstance(
DateTimeBuilder.get()
DateTimeBuilder.newInstance()
.withTime(true)
.with24Hours(true)
.withSelectedDate(currentDate.getTimeInMillis())
Expand All @@ -74,7 +74,7 @@ void onClick(View view) {
.withCurrentHour(12)
.withCurrentMinute(30)
.withTheme(R.style.PickersTheme))
.show(getSupportFragmentManager(), "DatePickerFragmentDialog");
.show(getSupportFragmentManager(), SampleHelper.DATE_PICKER_FRAGMENT_DIALOG);
break;
case R.id.fromFragment:
getSupportFragmentManager().beginTransaction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ void onClick(View view) {
maxDate.set(2016, minDate.get(Calendar.MONTH) + 1, minDate.get(Calendar.DAY_OF_MONTH));
switch (view.getId()) {
case R.id.datePickerOnly:
DatePickerFragmentDialog.newInstance().show(getChildFragmentManager(), "DatePickerFragmentDialog");
DatePickerFragmentDialog.newInstance().show(getChildFragmentManager(), SampleHelper.DATE_PICKER_FRAGMENT_DIALOG);
break;
case R.id.datePickerMinMaxPicker:
DatePickerFragmentDialog.newInstance(DateTimeBuilder.get()
DatePickerFragmentDialog.newInstance(DateTimeBuilder.newInstance()
.withMinDate(minDate.getTimeInMillis())
.withMaxDate(maxDate.getTimeInMillis()))
.show(getChildFragmentManager(), "DatePickerFragmentDialog");
.show(getChildFragmentManager(), SampleHelper.DATE_PICKER_FRAGMENT_DIALOG);
break;
case R.id.timePickerOnly:
TimePickerFragmentDialog.newInstance().show(getChildFragmentManager(), "TimePickerFragmentDialog");
TimePickerFragmentDialog.newInstance().show(getChildFragmentManager(), SampleHelper.TIME_PICKER_FRAGMENT_DIALOG);
break;
case R.id.timePickerOnly24Hours:
TimePickerFragmentDialog.newInstance(true).show(getChildFragmentManager(), "TimePickerFragmentDialog");
TimePickerFragmentDialog.newInstance(true).show(getChildFragmentManager(), SampleHelper.TIME_PICKER_FRAGMENT_DIALOG);
break;
case R.id.dateAndTimePicker:
DatePickerFragmentDialog.newInstance(true).show(getChildFragmentManager(), "DatePickerFragmentDialog");
DatePickerFragmentDialog.newInstance(true).show(getChildFragmentManager(), SampleHelper.DATE_PICKER_FRAGMENT_DIALOG);
break;
case R.id.ultimatePicker:
Calendar currentDate = Calendar.getInstance();
currentDate.set(2016, currentDate.get(Calendar.MONTH) + 1, currentDate.get(Calendar.DAY_OF_MONTH));
DatePickerFragmentDialog.newInstance(
DateTimeBuilder.get()
DateTimeBuilder.newInstance()
.withTime(true)
.with24Hours(true)
.withSelectedDate(currentDate.getTimeInMillis())
Expand All @@ -74,7 +74,7 @@ void onClick(View view) {
.withCurrentHour(12)
.withCurrentMinute(30)
.withTheme(R.style.PickersTheme))
.show(getChildFragmentManager(), "DatePickerFragmentDialog");
.show(getChildFragmentManager(), SampleHelper.DATE_PICKER_FRAGMENT_DIALOG);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

public class SampleHelper {

public static final String DATE_PICKER_FRAGMENT_DIALOG = "DatePickerFragmentDialog";
public static final String TIME_PICKER_FRAGMENT_DIALOG = "TimePickerFragmentDialog";


public static String getDateOnly(long time) {
return new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()).format(time);
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0-beta2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions datetimepicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 11
versionName "1.0.1"
versionCode 102
versionName "1.0.2"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ public class DateTimeBuilder implements Parcelable {
private int currentMinute;
private int themeResId;

/**
* Use newInstance instead for naming convention
* return new Instance
*/
@Deprecated
public static DateTimeBuilder get() {
return newInstance();
}

public static DateTimeBuilder newInstance() {
return new DateTimeBuilder().withCurrentHour(-1).withCurrentMinute(-1);
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=1.0.1
VERSION_CODE=11
VERSION_NAME=1.0.2
VERSION_CODE=102
GROUP=com.github.k0shk0sh
POM_DESCRIPTION=Android Library to help you with your date & time pickers while retaining the instance of the pickers on orientation change.
POM_URL=https://github.com/k0shk0sh/RetainedDateTimePickers
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Sat Jan 21 08:27:16 MYT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

0 comments on commit d547021

Please sign in to comment.