Horizontal Calendar


Source link: https://github.com/Mulham-Raee/HorizontalCalendar

Horizontal Calendar

A material horizontal calendar view for Android based on RecyclerView.

Installation

The library is hosted on jcenter, add this to your build.gradle:

repositories {

 jcenter()
  
}

 dependencies {

 compile 'devs.mulham.horizontalcalendar:horizontalcalendar:1.2.0'
  
}

Prerequisites

The minimum API level supported by this library is API 9 (GINGERBREAD).

Usage

  • Add HorizontalCalendarView to your layout file, for example:
<android.support.design.widget.AppBarLayout
............ >

<devs.mulham.horizontalcalendar.HorizontalCalendarView

 android:id="@+id/calendarView"

 android:layout_width="match_parent"

 android:layout_height="wrap_content"

 android:background="@color/colorPrimary"

 app:textColorSelected="#FFFF"/>

  </android.support.design.widget.AppBarLayout>
  • In your Activity or Fragment, define your start and end dates to set the range of the calendar:
/** end after 1 month from now */ Calendar endDate = Calendar.getInstance();
 endDate.add(Calendar.MONTH, 1);
  /** start before 1 month from now */ Calendar startDate = Calendar.getInstance();
 startDate.add(Calendar.MONTH, -1);
  • Then setup HorizontalCalendar in your Activity through its Builder:
HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder(this, R.id.calendarView)

  .startDate(startDate.getTime())

  .endDate(endDate.getTime())

  .build();
  • Or if you are using a Fragment:
HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder(rootView, R.id.calendarView)  ...................
  • To listen to date change events you need to set a listener:
horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() {

 @Override

 public void onDateSelected(Date date, int position) {

  //do something

 
}

}
);
  • You can also listen to scroll and long press events by overriding each prespective method within HorizontalCalendarListener:
horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() {

 @Override

 public void onDateSelected(Date date, int position) {

  
}

  @Override

 public void onCalendarScroll(HorizontalCalendarView calendarView,

  int dx, int dy) {

}

  @Override

 public boolean onDateLongClicked(Date date, int position) {

  return true;

 
}

}
);

Customization

You can customize it directly inside your layout:

<devs.mulham.horizontalcalendar.HorizontalCalendarView

 android:id="@+id/calendarView"

 android:layout_width="match_parent"

 android:layout_height="wrap_content"

 android:background="@color/colorPrimary"

 app:textColorNormal="#bababa"

 app:textColorSelected="#FFFF"

 app:selectorColor="#c62828"
// default to colorAccent.

 app:selectedDateBackground="@drawable/myDrwable"/>

Or you can do it programmatically in your Activity using the Builder:

HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder(this, R.id.calendarView)

  .startDate(startDate.getTime())

  .endDate(endDate.getTime())

  .datesNumberOnScreen(5)
// Number of Dates cells shown on screen (Recommended 5)

  .dayNameFormat("EEE")
// WeekDay text format

  .dayNumberFormat("dd")
 // Date format

  .monthFormat("MMM")
 // Month format

  .showDayName(true)
// Show or Hide dayName text

  .showMonthName(true)
// Show or Hide month text

  .textColor(Color.LTGRAY, Color.WHITE)
 // Text color for none selected Dates, Text color for selected Date.

  .selectedDateBackground(Drawable)  // Background Drawable of the selected date cell.

  .selectorColor(Color.RED)
// Color of the selection indicator bar (default to colorAccent).

  .defaultSelectedDate(date)  // Date to be seleceted at start (default to Today)

  .build();

Features

  • You can select a specific Date programmatically with the option whether to play the animation or not, with:
horizontalCalendar.selectDate(Date date, boolean immediate);
 // set immediate to false to ignore animation.  // or simply horizontalCalendar.goToday(boolean immediate);
  • Check if two dates' days are equal:
horizontalCalendar.isDatesDaysEquals(Date date1, Date date2);
  • Check if a date is contained in the Calendar:
horizontalCalendar.contains(Date date);

Contributing

Contributions are welcome, feel free to submit a pull request.

License

Copyright 2017 Mulham Raee

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

Scaling layout just like in Blinkist and Spotify app.

MaterialTabsTemplate is solely created to reduce the burden of writing same boiler plate codes for Tab creation in Android.

Pretty print the result of Android lint tool. Would work great when you run lint as part of continuous integration flow.

This lib provides simple and fluent API for creating Android Spannable.

An android library containing most of the helper classes every android developer needs.

The Problem

Every Android developer faces few problems while developing Android Apps. Listing down some of them, which I have faced everytime I create a new android project.

  1. The problem of writing boilerplate code while creating Activities, Fragments is annoying.
  2. Need of readymade methods which can come handy such as showing a toast, or showing a progress dialog or launching a new activity.
  3. The problem of applying proper styles and themes to activities and handling those for pre-lollipop and post-lollipop.

What if we had a library which takes care of all these problems and let the developers concentrate on writing the actual business logic and create awesome functionalities.

The Solution

Using the Helper library developer can solve the above mentioned problems. Using this Helper library is pretty simple.

Ready to use one time password component.

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