/Persian-Date-Picker-Dialog

Persian Date Picker Dialog for Android

Primary LanguageJava

Persian Date Picker Dialog

Hero Image

Persian Date Picker Dialog

This library provides you a beautiful Persian Date picker dialog with easy API.

Usages

Use this dependency in your build.gradle file to reference this library in your project

Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

dependencies {
    implementation 'com.github.aliab:Persian-Date-Picker-Dialog:1.4'
}

Then in your Java Code, you use it like below.

 picker = new PersianDatePickerDialog(this)
                .setPositiveButtonString("باشه")
                .setNegativeButton("بیخیال")
                .setTodayButton("امروز")
                .setTodayButtonVisible(true)
                .setInitDate(initDate)
                .setMaxYear(PersianDatePickerDialog.THIS_YEAR)
                .setMinYear(1300)
                .setActionTextColor(Color.GRAY)
                .setTypeFace(typeface)
                .setListener(new Listener() {
                    @Override
                    public void onDateSelected(PersianCalendar persianCalendar) {
                        Toast.makeText(context, persianCalendar.getPersianYear() + "/" + persianCalendar.getPersianMonth() + "/" + persianCalendar.getPersianDay(), Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onDismissed() {

                    }
                });

        picker.show();

If you need to set an initial date, just simply set it like below.

 PersianCalendar initDate = new PersianCalendar();
 initDate.setPersianDate(1370, 3, 13);

 persianDatePickerDialog.setInitDate(initDate)

Public Methods

Name Description
setMaxYear(int) set maximum year can be selected
setMinYear(int) set minimum year can be selected
setTypeFace(TypeFace) set dialog typeface
setInitDate(PersianCalendar) set date that dialog will launch on that
setInitDate(PersianCalendar,boolean) set date that dialog will launch on that and force min/max year to be compatible with it
setPositiveButtonString(String) set positive button text
setPositiveButtonResource(@StringRes int) set positive button text from strings.xml
setNegativeButton(String) set negative button text
setNegativeButtonResource(@StringRes int) set negative button text from strings.xml
setTodayButton(String) set today button text
setTodayButtonResource(@StringRes int) set today button text from strings.xml
setTodayButtonVisible(boolean) set today button visible/invisible
setActionTextColor(@ColorInt int) set dialog buttons texts color
setActionTextColorResource(@ColorRes int) set dialog buttons texts color form colors.xml
setCancelable(boolean) set dialog cancelable or not
setBackgroundColor(@ColorInt int) set dialog background color
setPickerBackgroundColor(@ColorInt int) set date pickers background color
setPickerBackgroundDrawable(@DrawableRes int) set date pickers background drawable from res/drawable folder
setListener(Listener) set dialog callback listener

CREDITS

License

   
The MIT License (MIT)

Copyright (c) 2018 Ali Abdolahi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.