Giter Club home page Giter Club logo

lazydatepicker's Introduction

LazyDatePicker

sample

Platform API Maven Central
Android Weekly Twitter

This is an Android project to offer an alternative to the native Android Date Picker.

Android app on Google Play

USAGE

To make a lazy date picker add LazyDatePicker in your layout XML and add LazyDatePicker library in your project or you can also grab it via Gradle:

implementation 'com.mikhaellopez:lazydatepicker:1.1.0'

XML

<com.mikhaellopez.lazydatepicker.LazyDatePicker
    android:id="@+id/lazyDatePicker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:ldp_text_color="@color/primary"
    app:ldp_hint_color="@color/accent"
    app:ldp_date_format="mm-dd-yyyy" />

You must use the following properties in your XML to change your LazyDatePicker.

Properties Type Default
app:ldp_text_color color BLACK
app:ldp_hint_color color GRAY
app:ldp_date_format mm-dd-yyyy or dd-mm-yyyy mm-dd-yyyy
app:ldp_show_full_date boolean true

KOTLIN

lazyDatePicker.setDateFormat(LazyDatePicker.DateFormat.MM_DD_YYYY)
lazyDatePicker.setMinDate(minDate)
lazyDatePicker.setMaxDate(maxDate)

// The date when is selected
lazyDatePicker.setOnDatePickListener { dateSelected ->
    //...
}

// True or false when date is selected
lazyDatePicker.setOnDateSelectedListener { dateSelected ->
    //...
}

JAVA

LazyDatePicker lazyDatePicker = findViewById(R.id.lazyDatePicker);
lazyDatePicker.setDateFormat(LazyDatePicker.DateFormat.MM_DD_YYYY);
lazyDatePicker.setMinDate(minDate);
lazyDatePicker.setMaxDate(maxDate);

lazyDatePicker.setOnDatePickListener(new LazyDatePicker.OnDatePickListener() {
    @Override
    public void onDatePick(Date dateSelected) {
        //...
    }
});

lazyDatePicker.setOnDateSelectedListener(new LazyDatePicker.OnDateSelectedListener() {
    @Override
    public void onDateSelected(Boolean dateSelected) {
        //...
    }
});

You can used LazyLocalDatePicker instead of LazyDatePicker to have all method with LocalDate instead of Date.

XML:

<com.mikhaellopez.lazydatepicker.LazyLocalDatePicker
    android:id="@+id/lazyDatePicker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:ldp_text_color="@color/primary"
    app:ldp_hint_color="@color/accent"
    app:ldp_date_format="mm-dd-yyyy" />

KOTLIN:

lazyLocalDatePicker.setDateFormat(LazyDatePicker.DateFormat.MM_DD_YYYY)
lazyLocalDatePicker.setMinLocalDate(minDate)
lazyLocalDatePicker.setMaxLocalDate(maxDate)

// The localdate when is selected
lazyLocalDatePicker.setOnLocalDatePickListener { localDateSelected ->
    //...
}

// True or false when date is selected
lazyLocalDatePicker.setOnLocalDateSelectedListener { dateSelected ->
    //...
}

OVERRIDE

You can override day, month & year if you want like this in your strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <string name="ldp_day" tools:override="true">D</string>
    <string name="ldp_month" tools:override="true">M</string>
    <string name="ldp_year" tools:override="true">Y</string>
</resources>

You can also change the design of the picker by changing the dimensions like this in your dimens.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <dimen name="lazy_date_picker_width_case" tools:override="true">12dp</dimen>
    <dimen name="lazy_date_picker_height_focus" tools:override="true">2.5dp</dimen>
    <dimen name="lazy_date_picker_width_margin" tools:override="true">1dp</dimen>
    <dimen name="lazy_date_picker_width_space" tools:override="true">6dp</dimen>
</resources>

And to finish you can also completely redefine the layout by keeping the same name layout_lazy_date_picker.xml and keep all the ids. You can find the default one here: layout_lazy_date_picker.xml

SUPPORT โค๏ธ

Find this library useful? Support it by joining stargazers for this repository โญ๏ธ
And follow me for my next creations ๐Ÿ‘

LICENCE

LazyDatePicker by Lopez Mikhael is licensed under a Apache License 2.0.

lazydatepicker's People

Contributors

lopspower avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lazydatepicker's Issues

setDate is not working properly

App crashes when you set a date programmatically and tries to change value.

lazyDatePicker.setDate(new Date());

java.lang.NullPointerException: Attempt to invoke interface method 'void android.text.TextWatcher.beforeTextChanged(java.lang.CharSequence, int, int, int)' on a null object reference

Logo Design Offer For LazyDatePicker

Hello Sir. I'm a UI/UX and Graphics Designer. who has contacted you via email last week.
This is my logo proposal for your application.
I'm very welcome if you have any comments, opinions, or revisions. Please just tell me.
I'll provide all file types and sizes you needed.
Hope you like it.

picker

[Improvement]

Hi,

Nice job on this library ! :)

I'm wondering if you're planning to add a onDateErrorListener which let developer do things such as:

  • changing color of layout to inform date in not correct(may also add a color modifier methods)
  • Toasting a message to inform user
  • setting date to specific one (such as today)

I will maybe have time to create some code about it but not sure.

lOGO OFFER FOR LazyDatePicker

Hi sir Lopez Mikhael. I'm graphic designer. I would like to offer logo. If you like, I can give you with great pleasure all the formats of the design free. If you want a change please specify.

lazydatepicker

Best regard.
Famil

Add type dd-mm

Hello, Thanks for the lib.
Please add type dd-mm and mm-dd. It is needed for credit card date view. Thx)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.