GithubHelp home page GithubHelp logo

morristech / slidedaytimepicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jjobes/slidedaytimepicker

0.0 1.0 0.0 1.03 MB

A combined day of week and time picker in a DialogFragment for Android

License: Apache License 2.0

Java 100.00%

slidedaytimepicker's Introduction

SlideDayTimePicker

AndroidLibs

SlideDayTimePicker is an Android library that displays a single DialogFragment in which the user can select a day of week and a time. The user can swipe between the day picker and time picker, and the tab underline will gradually animate as the user swipes. The colors of the tab indicator and divider lines are customizable to fit your project's theme. Tested on Android 4.0+.

Setup

To add this library to your project, add the following to your build.gradle:

dependencies {
    compile project(':slideDayTimePicker')
}

How to Use

(See SampleActivity for a more complete example)

First create a listener object:

final SlideDayTimeListener listener = new SlideDayTimeListener() {

    @Override
    public void onDayTimeSet(int day, int hour, int minute)
    {
        // Do something with the day, hour and minute
        // the user has selected.
    }

    @Override
    public void onDayTimeCancel()
    {
        // The user has canceled the dialog.
        // This override is optional.
    }
};

Then pass the listener into the builder and show the dialog:

new SlideDayTimePicker.Builder(getSupportFragmentManager())
    .setListener(listener)
    .setInitialDay(1)
    .setInitialHour(13)
    .setInitialMinute(30)
    .build()
    .show();

To set the initial day of week to display

.setInitialDay(int)

The integer that you pass in to setInitialDay() should correspond to a java.util.Calendar day of week constant. So either 1 or Calendar.SUNDAY would be acceptable arguments to setInitialDay(). (However, if you specify a custom days array with setCustomDaysArray(), pass in the raw index instead.)

To set the initial hour to display:

.setInitialHour(int)

Acceptable range of values: 0-23

To set the initial minute to display:

.setInitialMinute(int)

Acceptable range of values: 0-59

The default time format is the current device's default, but you can force a 24-hour or 12-hour time format:

To force 24-hour time:

.setIs24HourTime(true)

To force 12-hour time:

.setIs24HourTime(false)

To display a custom days array: By default, the dialog will display the normal seven days of the week. However, if you want to customize the days to display, you can pass in your own String array.

.setCustomDaysArray(String[])

The default theme is Holo Light, but you can specify either Holo Light or Dark explicitly:

.setTheme(SlideDayTimePicker.HOLO_LIGHT)

or

.setTheme(SlideDayTimePicker.HOLO_DARK)

To specify the color for the sliding tab underline (indicator):

.setIndicatorColor(Color.parseColor("#FF0000"))

To specify the color of the horizontal divider lines in the day picker and TimePicker: You can also set a custom color for the horizontal divider lines in the day picker and TimePicker, but for this you have to paste your own version of selection_divider.9.png into the the library's drawable-xxxx folders that has your desired color. To do this, open selection_divider.9.png in a graphics editor, change the color, then paste your new files into the drawable-xxxx folders.

Note on Reflection

To allow for the modification of the horizontal dividers in the NumberPicker and TimePicker, this library uses reflection in the CustomNumberPicker and CustomTimePicker classes.

Contributing

Contributions are welcome. Please open up an issue in GitHub or submit a PR.

Translations are especially needed in strings.xml

Changelog

v1.0.2

  • Update build.gradle

v1.0.1

  • Changed to Android Studio / Gradle project

v1.0.0

  • First release

License

Licensed under the Apache License, Version 2.0

The following files:

  • SlidingTabLayout.java
  • SlidingTabStrip.java

are Copyright (C) 2013 The Android Open Source Project and are licensed under the Apache License, Version 2.0.

Acknowledgements

Thanks to Arman Pagilagan's blog post for the initial idea.

slidedaytimepicker's People

Contributors

jjobes 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.