Code Monkey home page Code Monkey logo

rangepicker-module-android's Introduction

Material Range Picker

It is a simple range picker can be used in most common scenarios where you've to pick the range in hours. It has some presets for the hours and days like last 12 hours to now, today, yesterday etc. There's no 'android.widget.ListView' or 'android.support.v7.widget.RecyclerView'. All the elements have been put in xml manually. So the layout is free to edit according to UI/theme of the application.

If you really dont want to waste time on making a simple time range picker, this is good for you. In this version, there's not too much customizations in this library/time picker screen. But in future, customizations can be done according response of people.

Presets Custom Time Selection Custom Date Selection

How to add library?

Simply add the following repositories to your project level build.gradle file:

allprojects {
    repositories {
        jcenter()

        maven {
            url = 'https://jitpack.io'
        }
    }
}

And add the following dependency to your app level build.gradle file:

dependencies {
    compile 'com.github.abhishek-tm:rangepicker-module-android:1.0.5'
}

How to use it?

This range picker is an Activity for Results. So simply launch it with a response code like below...

startActivityForResult(new Intent(this, TimePicker.class), 1992);

And obtain the results in onActivityResult() as following...

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK && requestCode == 1992) {
        Calendar from = (Calendar) data.getSerializableExtra(TimePicker.FROM);
        Calendar to = (Calendar) data.getSerializableExtra(TimePicker.TO);
    }
}

Customizations

  • If you want to set custom date and time format for preview, you can simply pass it to intent.
  intent.putExtra(TimePicker.TIME_FORMAT, new SimpleDateFormat("hh:mm a"));
  intent.putExtra(TimePicker.DATE_FORMAT, new SimpleDateFormat("dd MMM yyyy"));
  • To set a particular date for custom selection, pass Calendar instance of any date to intent.
  Calendar calendar = Calendar.getInstance();
  calendar.set(Calendar.DATE, 12);
  calendar.set(Calendar.MONTH, 1);
  intent.putExtra(TimePicker.DAY, calendar);
  • To select particular preset, pass Filter enumeration defined in TimePicker.class.
  intent.putExtra(TimePicker.FILTER, TimePicker.Filter.TODAY);
  • Default title is Data Setting. To set up custom title on Action Bar.
  intent.putExtra(TimePicker.SCREEN_TITLE, "Data Filter");

License

Copyright (C) 2017 Teramatrix Technologies Private Limited

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

rangepicker-module-android's People

Contributors

khan-tm avatar abhishek-tm avatar

Watchers

 avatar

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.