Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k0shk0sh/RetainedDateTimePickers
Android Library to help you with your date & time pickers while retaining the instance of the pickers on orientation change.
https://github.com/k0shk0sh/RetainedDateTimePickers
android-library datepickerdialog orientation-changes picker timepickerdialog
Last synced: 3 months ago
JSON representation
Android Library to help you with your date & time pickers while retaining the instance of the pickers on orientation change.
- Host: GitHub
- URL: https://github.com/k0shk0sh/RetainedDateTimePickers
- Owner: k0shk0sh
- License: apache-2.0
- Created: 2016-09-27T16:40:49.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-21T01:17:41.000Z (almost 8 years ago)
- Last Synced: 2024-06-16T03:34:18.989Z (5 months ago)
- Topics: android-library, datepickerdialog, orientation-changes, picker, timepickerdialog
- Language: Java
- Size: 710 KB
- Stars: 107
- Watchers: 7
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-github-android-ui - RetainedDateTimePickers - 在手机方向改变时保持日期时间选择器 (日历时间)
README
# RetainedDateTimePickers
Android Library to help you with your date & time pickers while retaining the instance of the pickers on orientation change.# Installation
#### Gradle
```groovy
compile 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.2'
```#### Maven
```xmlcom.github.k0shk0sh
RetainedDateTimePickers
1.0.2
aar```
Usage
=====Your `Activity` or `Fragment` must implement `DatePickerCallback` and or `TimePickerCallback` to receive the selected date & selected time if
applicable.RetainedDateTimePickers should be treated as any normal `DialogFragment`:
- DatePickerDialog Only
```java
DatePickerFragmentDialog.newInstance().show(getSupportFragmentManager(), "DatePickerFragmentDialog");
```- TimePickerDialog Only
```java
//default 12 hours format
TimePickerFragmentDialog.newInstance().show(getSupportFragmentManager(), "TimePickerFragmentDialog");
//24 hours format
TimePickerFragmentDialog.newInstance(true).show(getSupportFragmentManager(), "TimePickerFragmentDialog");
```- DateTimePickerDialog
```java
DatePickerFragmentDialog.newInstance(true).show(getSupportFragmentManager(), "DatePickerFragmentDialog");
```- Date & Time PickerDialog Customization
```java
DatePickerFragmentDialog.newInstance(
DateTimeBuilder.get()
.withTime(true)
.with24Hours(true)
.withSelectedDate(currentDate.getTimeInMillis())
.withMinDate(minDate.getTimeInMillis())
.withMaxDate(maxDate.getTimeInMillis())
.withCurrentHour(12)
.withCurrentMinute(30)
.withTheme(R.style.PickersTheme))
.show(getSupportFragmentManager(), "DatePickerFragmentDialog");
```> **To understand more how the library works, please take a look at the sample app.**
Screenshots
======- **Pickers Portrait Mode**
- **Pickers Landscape Mode**
- **Pickers Custom Themes via Styles**
# 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.
* It uses DatePickerDialog & TimePickerDialog internally.
* Its simple to use.
* Its Customizable (Support Custom Themes).
* Minimum API is 16, but it'll probably work in API 9 and above, just make sure you test it out (we use `Support Fragment`).# Dependency
Android Support Fragment Library ``v24.2.1``
**Pull requests are welcomed.**
# Copyright Notice
Copyright (C) 2016 Kosh.
Licensed under the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)
license (see the LICENSE file).