No description, website, or topics provided.
Clone or download
Fail
Fail Issue 1
Latest commit 223d7c8 Dec 18, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
images Sample added Dec 5, 2018
sample ViewPager replace Dec 11, 2018
slycalendarview Issue 1 Dec 18, 2018
LICENSE Create LICENSE Dec 5, 2018
README.md Sample updated Dec 11, 2018
build.gradle Beta selected dates Dec 3, 2018
settings.gradle beta 3 Dec 3, 2018

README.md

Sly Calendar View

API Android Arsenal

A calendar that allows you to select both a single date and a period. Calendar allows you to change colors programmatically without reference to the theme.

Demo Screen Capture

Installation

Step 1. Add the JitPack repository to your build file

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Step 2. Add the dependency

dependencies {
  implementation 'com.github.psinetron:slycalendarview:${version}'
}

Usage

  1. Add MaterialCalendarView into your layouts or view hierarchy.
<ru.slybeaver.slycalendarview.SlyCalendarView
        android:id="@+id/slyCalendarView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

Or show calendar as dialog:

new SlyCalendarDialog()
        .setSingle(false)
        .setCallback(listener)
        .show(getSupportFragmentManager(), "TAG_SLYCALENDAR");
  1. Set a SlyCalendarDialog.Callback when you need it
public class MainActivity extends AppCompatActivity implements SlyCalendarDialog.Callback {
...

@Override
    public void onCancelled() {
        //Nothing
    }

    @Override
    public void onDataSelected(Calendar firstDate, Calendar secondDate, int hours, int minutes) {
        if (firstDate != null) {
            if (secondDate == null) {
                firstDate.set(Calendar.HOUR_OF_DAY, hours);
                firstDate.set(Calendar.MINUTE, minutes);
                Toast.makeText(
                        this,
                        new SimpleDateFormat(getString(R.string.timeFormat), Locale.getDefault()).format(firstDate.getTime()),
                        Toast.LENGTH_LONG

                ).show();
            } else {
                Toast.makeText(
                        this,
                        getString(
                                R.string.period,
                                new SimpleDateFormat(getString(R.string.dateFormat), Locale.getDefault()).format(firstDate.getTime()),
                                new SimpleDateFormat(getString(R.string.timeFormat), Locale.getDefault()).format(secondDate.getTime())
                        ),
                        Toast.LENGTH_LONG

                ).show();
            }
        }
    }

}

Or

SlyCalendarDialog.Callback callback = new SlyCalendarDialog.Callback() {
    @Override
    public void onCancelled() {
        
    }

    @Override
    public void onDataSelected(Calendar firstDate, Calendar secondDate, int hours, int minutes) {

    }
};

Customization

Set colors:

<ru.slybeaver.slycalendarview.SlyCalendarView
        android:id="@+id/slyCalendarView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:backgroundColor="#000000"
        app:headerColor="#ff0000"
        app:firstMonday="true"
        app:textColor="#00ff00"
        app:selectedColor="#0000ff"
        />

or

new SlyCalendarDialog()
        .setSingle(false)
        .setCallback(listener)
        .setBackgroundColor(Color.parseColor("#ff0000"))
        .setSelectedTextColor(Color.parseColor("#ffff00"))
        .setSelectedColor(Color.parseColor("#0000ff"))
        .show(getSupportFragmentManager(), "TAG_SLYCALENDAR");

Parameters:

<attr name="backgroundColor" format="color"/>
        <attr name="headerColor" format="color"/>
        <attr name="headerTextColor" format="color"/>
        <attr name="textColor" format="color"/>
        <attr name="selectedColor" format="color"/>
        <attr name="selectedTextColor" format="color"/>
        <attr name="firstMonday" format="boolean"/>