Giter Site home page Giter Site logo

k0shk0sh / retaineddatetimepickers Goto Github PK

View Code? Open in Web Editor NEW
107.0 7.0 20.0 727 KB

Android Library to help you with your date & time pickers while retaining the instance of the pickers on orientation change.

License: Apache License 2.0

Java 100.00%
picker timepickerdialog datepickerdialog android-library orientation-changes

retaineddatetimepickers's Introduction

RetainedDateTimePickers

Android Library to help you with your date & time pickers while retaining the instance of the pickers on orientation change.

Installation

Gradle

compile 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.2'

Maven

<dependency>
  <groupId>com.github.k0shk0sh</groupId>
  <artifactId>RetainedDateTimePickers</artifactId>
  <version>1.0.2</version>
  <type>aar</type>
</dependency>

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
DatePickerFragmentDialog.newInstance().show(getSupportFragmentManager(), "DatePickerFragmentDialog");
  • TimePickerDialog Only
//default  12 hours format
TimePickerFragmentDialog.newInstance().show(getSupportFragmentManager(), "TimePickerFragmentDialog");
//24 hours format
TimePickerFragmentDialog.newInstance(true).show(getSupportFragmentManager(), "TimePickerFragmentDialog");
  • DateTimePickerDialog
DatePickerFragmentDialog.newInstance(true).show(getSupportFragmentManager(), "DatePickerFragmentDialog");
  • Date & Time PickerDialog Customization
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 license (see the LICENSE file).

retaineddatetimepickers's People

Contributors

olidroide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

retaineddatetimepickers's Issues

Disable the time passed

Is there any provision to avoid selection of passed time , only future Time Should be able to select like that ...

jalali support

do you plan to support jalali calendar for this library ?

On Cancel

Sir how to implement on cancel timepicker dialog?

Can we hide AM | PM?

Can we hide AM | PM?
I wanted to hide AM | PM section from your lib is there any possibility?

How should I invoke TimePickerFragment Dialog in PreferenceFragment?

I get the following error when I try to use getChildFragmentManager() within show()

Error:(204, 51) error: no suitable method found for show(android.app.FragmentManager,String) method DialogFragment.show(android.support.v4.app.FragmentManager,String) is not applicable (argument mismatch; android.app.FragmentManager cannot be converted to android.support.v4.app.FragmentManager) method DialogFragment.show(FragmentTransaction,String) is not applicable (argument mismatch; android.app.FragmentManager cannot be converted to FragmentTransaction)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.