SlideDateTimePicker


Source link: https://github.com/jjobes/SlideDateTimePicker

SlideDateTimePicker

SlideDateTimePicker is an Android library that displays a single DialogFragment in which the user can select a date and a time. The user can swipe between the DatePicker and TimePicker, and the tab underline will gradually animate as the user swipes. The colors of the tab indicator and divider lines are customizable to fit your project's theme. Tested on Android 4.0+.

Setup

To add this library to your project, add the following to your build.gradle:

dependencies {

  compile project(':slideDateTimePicker') 
}

How to Use

(See SampleActivity for a more complete example)

First create a listener object:

private SlideDateTimeListener listener = new SlideDateTimeListener() {

@Override
  public void onDateTimeSet(Date date)
  {

// Do something with the date. This Date object contains

// the date and time that the user has selected.
  
}

@Override
  public void onDateTimeCancel()
  {

// Overriding onDateTimeCancel() is optional.
  
}
 
}
;

Then pass the listener into the builder and show the dialog:

new SlideDateTimePicker.Builder(getSupportFragmentManager())
  .setListener(listener)
  .setInitialDate(new Date())
  .build()
  .show();

Note that the Date object that you pass in to .setInitialDate() should contain both the date and time that you wish to initially display.

To set the minimum date to display:

.setMinDate(date)

To set the maximum date to display:

.setMaxDate(date)

The default time format is the current device's default, but you can force a 24-hour or 12-hour time format:

To force 24-hour time:

.setIs24HourTime(true)

To force 12-hour time:

.setIs24HourTime(false)

The default theme is Holo Light, but you can specify either Holo Light or Dark explicitly:

.setTheme(SlideDateTimePicker.HOLO_LIGHT)

or

.setTheme(SlideDateTimePicker.HOLO_DARK)

To specify the color for the sliding tab underline (indicator):

.setIndicatorColor(Color.parseColor("#FF0000"))

To specify the color of the horizontal divider lines in the DatePicker and TimePicker: You can also set a custom color for the horizontal divider lines in the DatePicker and TimePicker, but for this you have to paste your own version of selection_divider.9.png into the the library's drawable-xxxx folders that has your desired color. To do this, open selection_divider.9.png in a graphics editor, change the color, then paste your new files into the drawable-xxxx folders.

Note on Reflection

To allow for the modification of the horizontal dividers in the DatePicker and TimePicker, this library uses reflection in the CustomDatePicker and CustomTimePicker classes.

Contributing

Contributions are welcome. Please open up an issue in GitHub or submit a PR.

Changelog

v1.0.4

  • Fixed issue where the DatePicker would shift to the left when scrolled vertically (thanks to alexrainman)

v1.0.3

  • Update build.gradle

v1.0.2

  • Changed to Android Studio / Gradle Project

v1.0.1

  • Builder methods now correspond to outer class methods
  • Improved javadoc comments

v1.0.0

  • First release

License

Licensed under the Apache License, Version 2.0

The following files:

  • SlidingTabLayout.java
  • SlidingTabStrip.java

are Copyright (C) 2013 The Android Open Source Project and are licensed under the Apache License, Version 2.0

Acknowledgements

Thanks to Arman Pagilagan's blog post for the initial idea.

Resources

Elastic Progress Bar.

Android's video recording APIs are very difficult to figure out, especially since a lot of manufacturers like to mount their camera sensors upside down or sideways. This library is a result of lots of research and experimentation to get video recording to work universally.

Android Dynamic Loader is a plugin system. The host application is like a browser, but instead of loading web pages, it loads plugins which could be run natively on Android system.

A library to work with RecyclerView as easily as if you'd use ListView or GridView.

The easiest way to simplify custom View tags in layout xmls.

Wrapper around ActiveAndroid which introduces reactive queries with SQLBrite.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes