PagerDatePicker


Source link: https://github.com/rspective/PagerDatePicker

PagerDatePicker

Version: 1.2.0

Description

PagerDatePicker is a library for Android which allows to setup horizontal (for now;)) date list picker. It is a combination of few main Android components:

  • android.support.v7.widget.RecyclerView
  • android.support.v4.view.ViewPager
  • android.support.v4.app.FragmentStatePagerAdapter
  • android.support.v7.widget.RecyclerView.Adapter

Notice that PagerDatePicker is a project under development.

Welcome to fork and pull request.

Features

XML attributes:

Support date format MM-dd-yyyy

 <attr name="date_start" format="string"/>
  <attr name="date_end" format="string"/>
  <attr name="default_day_selection" format="string"/>

API

  • Animations You can assign animation for selected day. This could be set for whole date item view or just for single one. To achieve this you have to load and assign animation to the adapter:
dateAdapter.setCurrentViewAnimation(AnimationUtils.loadAnimation(CONTEXT, ANIM_ID_FOR_YOUR_ANIMATION));

To select which view has to be animated you have to override below method in your ViewHolder

protected abstract View getCurrentViewToAnimate();

Deafult and custom date adapter

If default date item is not enough for you don't worry, you can create your own custom date adapter where you can apply default style/view/functions to your date item.

Things to know:
  • You have to create your custom adapter which has to extend AbsDateAdapter
  • Your view holder has to extend AbsDateItemHolder
  • Implement required methods and add your own if you need

To check details, please see demo app.

Screenshot

Quick Setup?Basic Usage)

1.Integration
Gradle
dependencies {

  compile 'pl.rspective.pagerdatepicker:pagerdatepicker:1.2.0' 
}
2.Usage (for default date adapter)

Please note, that supported date format is MM-dd-yyyy

1. Add picker and pager to your view
<pl.rspective.pagerdatepicker.view.DateRecyclerView
  android:id="@+id/date_list"
  android:layout_width="match_parent"
  android:layout_height="100dp"
  android:background="#ff343434"/>  <android.support.v4.view.ViewPager
 android:id="@+id/pager"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_below="@id/date_list"/>
2. Add item decoration for your picker (OPTIONAL)

You can do this in two ways:

dateList.addItemDecoration(new RecyclerViewInsetDecoration(this);

Default insets is 1dp

dateList.addItemDecoration(new RecyclerViewInsetDecoration(this, R.dimen.date_card_insets));

Add your own insets value

3. Create deafult adapter with date range and assign it to our picker
dateList.setAdapter(new DefaultDateAdapter(start, end));
4. Init pager adapter and assign it to our datepicker
DatePagerFragmentAdapter fragmentAdapter = new DatePagerFragmentAdapter(getSupportFragmentManager(), dateList.getDateAdapter()) {

  @Override
  protected Fragment getFragment(int position, long date) {

return ...
  
}
 
}
;  pager.setAdapter(fragmentAdapter);
 dateList.setPager(pager);
5. We are almost there. Now you have to assign a listener to your picker
dateList.setDatePickerListener(new DateRecyclerView.DatePickerListener() {

  @Override
  public void onDatePickerItemClick(DateItem dateItem, int position) {

//User clicked date item from top date picker
  
}

@Override
  public void onDatePickerPageSelected(int position) {

//User changed date using swipe (left/right)
  
}

@Override
  public void onDatePickerPageStateChanged(int state) {

//User changed page
  
}

@Override
  public void onDatePickerPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

//User changed page
  
}
 
}
);

If you want to change the default color, just override below colors in your colors.xml:

<color name="date_item_unselected_indicator">#ff5c5c5c</color> <color name="date_item_selected_indicator">#ffff353b</color>  <color name="date_item_background">#ff373737</color> <color name="date_item_month_name">#ffd5d5d5</color> <color name="date_item_day_name">#ff9a9a9a</color> <color name="date_item_day">#FFFFFFFF</color>

If you want to see more details, go ahead and check the demo!

Assets

Demo launcher icon was made by jerrylow

License

Copyright 2015 RSPECTIVE P RYCHLIK SPĂ“?KA JAWNA  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

You can use WaveSideBar in the contacts page of your application.

CameraView aims to help Android developers easily integrate Camera features.

Delta offers your android app the hot fix and incremental upgrade powers.

If you want pick image from gallery or take picture, this library can help easily.

Reactive layer (similar to the pattern repository) for the Realm.

AndroidYouTubePlayer is a simple View that can be easily integrated in every Activity/Fragment. The interaction with YouTube is based on the IFrame Player API, therefore the YouTube app is not required to use the player.

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