Skip to content

Commit

Permalink
Updated Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
muraee committed Dec 21, 2017
1 parent d15b883 commit 2d4acdd
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 26 deletions.
2 changes: 2 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
**Feature Request**: Just fill in the first section below, and label your issue as Feature Request.
**Bugs**: please describe your issue in details as possible.
**Make sure you are using the latest version of HorizontalCalendar before opening a new issue**
-->

### Expected Behavior / Goal
Expand Down
86 changes: 63 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
# Horizontal Calendar

[ ![Download](https://api.bintray.com/packages/mulham-raee/maven/horizontal-calendar/images/download.svg) ](https://bintray.com/mulham-raee/maven/horizontal-calendar/_latestVersion)
[![Download](https://api.bintray.com/packages/mulham-raee/maven/horizontal-calendar/images/download.svg) ](https://bintray.com/mulham-raee/maven/horizontal-calendar/_latestVersion)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

A material horizontal calendar view for Android based on `RecyclerView`.

![demo](/art/demo.gif)

## Installation

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

```gradle
repositories {
jcenter()
}
dependencies {
compile 'devs.mulham.horizontalcalendar:horizontalcalendar:1.2.2'
dependencies {
compile 'devs.mulham.horizontalcalendar:horizontalcalendar:1.2.5'
}
```

## Prerequisites

The minimum API level supported by this library is **API 14 (ICE_CREAM_SANDWICH)**.

## Usage

- Add `HorizontalCalendarView` to your layout file, for example:

```xml
<android.support.design.widget.AppBarLayout
............ >
<android.support.design.widget.AppBarLayout>
............

<devs.mulham.horizontalcalendar.HorizontalCalendarView
android:id="@+id/calendarView"
Expand All @@ -43,11 +46,11 @@ The minimum API level supported by this library is **API 14 (ICE_CREAM_SANDWICH)
- In your Activity or Fragment, define your **start** and **end** dates to set the range of the calendar:

```java
/** end after 1 month from now */
/* end after 1 month from now */
Calendar endDate = Calendar.getInstance();
endDate.add(Calendar.MONTH, 1);

/** start before 1 month from now */
/* start before 1 month from now */
Calendar startDate = Calendar.getInstance();
startDate.add(Calendar.MONTH, -1);
```
Expand All @@ -58,6 +61,7 @@ startDate.add(Calendar.MONTH, -1);
HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder(this, R.id.calendarView)
.startDate(startDate.getTime())
.endDate(endDate.getTime())
.datesNumberOnScreen(5)
.build();
```

Expand All @@ -79,7 +83,7 @@ horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() {
});
```

- You can also listen to **scroll** and **long press** events by overriding each prespective method within **HorizontalCalendarListener**:
- You can also listen to **scroll** and **long press** events by overriding each perspective method within **HorizontalCalendarListener**:

```java
horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() {
Expand All @@ -102,7 +106,8 @@ horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() {
```

## Customization
You can customize it directly inside your layout:

- You can customize it directly inside your **layout**:

```xml
<devs.mulham.horizontalcalendar.HorizontalCalendarView
Expand All @@ -116,27 +121,59 @@ You can customize it directly inside your layout:
app:selectedDateBackground="@drawable/myDrwable"/>
```

Or you can do it programmatically in your Activity using the **Builder**:
- Or you can do it programmatically in your **Activity** or **Fragment** using `HorizontalCalendar.Builder`:

```java
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)
.startDate(Date startDate)
.endDate(Date endDate)
.datesNumberOnScreen(int number) // Number of Dates cells shown on screen (default to 5).
.configure() // starts configuration.
.formatTopText(String dateFormat) // default to "MMM".
.formatMiddleText(String dateFormat) // default to "dd".
.formatBottomText(String dateFormat) // default to "EEE".
.showTopText(boolean show) // show or hide TopText (default to true).
.showBottomText(boolean show) // show or hide BottomText (default to true).
.textColor(int normalColor, int selectedColor) // default to (Color.LTGRAY, Color.WHITE).
.selectedDateBackground(Drawable background) // set selected date cell background.
.selectorColor(int color) // set selection indicator bar's color (default to colorAccent).
.end() // ends configuration.
.defaultSelectedDate(Date date) // Date to be seleceted at start (default to current day `new Date()`).
.build();
```

#### More Customizations

```java
builder.configure()
.textSize(float topTextSize, float middleTextSize, float bottomTextSize)
.sizeTopText(float size)
.sizeMiddleText(float size)
.sizeBottomText(float size)
.colorTextTop(int normalColor, int selectedColor)
.colorTextMiddle(int normalColor, int selectedColor)
.colorTextBottom(int normalColor, int selectedColor)
.end()
```

## Features
- You can select a specific **Date** programmatically with the option whether to play the animation or not, with:

- Disable specific dates with `HorizontalCalendarPredicate`, a unique style for disabled dates can be specified as well with `CalendarItemStyle`:
```java
builder.disableDates(new HorizontalCalendarPredicate() {
@Override
public boolean test(Date date) {
return false; // return true if this date should be disabled, false otherwise.
}

@Override
public CalendarItemStyle style() {
return null; // create and return a new Style for disabled dates, or null if no styling needed.
}
})
```

- Select a specific **Date** programmatically with the option whether to play the animation or not:
```java
horizontalCalendar.selectDate(Date date, boolean immediate); // set immediate to false to ignore animation.
// or simply
Expand All @@ -152,10 +189,13 @@ horizontalCalendar.isDatesDaysEquals(Date date1, Date date2);
```java
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @author Mulham-Raee
* @since v1.0.0
* <p>
* See {devs.mulham.horizontalcalendar.R.layout#item_calendar} Calendar CustomItem Layout
* See {devs.mulham.horizontalcalendar.R.layout#hc_item_calendar} Calendar CustomItem Layout
*/
class HorizontalCalendarAdapter extends RecyclerView.Adapter<HorizontalCalendarAdapter.DayViewHolder> {

Expand All @@ -53,7 +53,7 @@ class HorizontalCalendarAdapter extends RecyclerView.Adapter<HorizontalCalendarA

@Override
public DayViewHolder onCreateViewHolder(ViewGroup viewGroup, int position) {
View convertView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_calendar, viewGroup, false);
View convertView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.hc_item_calendar, viewGroup, false);

convertView.setMinimumWidth(cellWidth);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Or implements HorizontalCalendarPredicate {
private final HorizontalCalendarPredicate firstPredicate;
private final HorizontalCalendarPredicate secondPredicate;

public Or(HorizontalCalendarPredicate firstPredicate, HorizontalCalendarPredicate secondPredicate) {
Or(HorizontalCalendarPredicate firstPredicate, HorizontalCalendarPredicate secondPredicate) {
this.firstPredicate = firstPredicate;
this.secondPredicate = secondPredicate;
}
Expand Down

0 comments on commit 2d4acdd

Please sign in to comment.