Skip to content
This repository has been archived by the owner on Mar 3, 2019. It is now read-only.
/ HmsPicker Public archive

A simple Hours-Minutes-Seconds time picker. Available for a custom view or a dialog.

License

Notifications You must be signed in to change notification settings

DeweyReed/HmsPicker

Repository files navigation

Android Arsenal Newest version Chinese Translation

This library has been deprecated in favor of HmsPickerView

HmsPicker

A simple Hours-Minutes-Seconds time picker. Available for a custom view or a dialog.

Separated and optimized from android-betterpickers hmspicker(in order to shrink apk size and add features).

Screenshots

Light Theme Custom Theme In the XML
Light Theme Custom Theme In the XML

Install

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 => Newest version

dependencies {
    implementation 'com.github.DeweyReed:HmsPicker:+'
}

Usage

XML

<io.github.deweyreed.hmspicker.HmsPicker
    android:id="@+id/hmsPicker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Then, use hmsPicker.getHours() to get users' input.

Show a dialog fragment

Implement HmsPickerDialog.HmsPickHandler for your activity or whatever.

class MainActivity : AppCompatActivity(), HmsPickerDialog.HmsPickHandler {
override fun onHmsPick(reference: Int, hours: Int, minutes: Int, seconds: Int) {
    longToast("reference: $reference, hours: $hours, minutes: $minutes, seconds: $seconds")
}

Then, build it.

HmsPickerBuilder(supportFragmentManager, this)
    .setStyleResId(R.style.CustomHmsPickerTheme)
    .setReference(255)
    .setTime(1, 23, 45)
    .setLeftButton("×", object : HmsPicker.OnLeftRightClickHandler {
        override fun onClick(view: HmsPicker) {
        }
    })
    .setRightButton("", object : HmsPicker.OnLeftRightClickHandler {
        override fun onClick(view: HmsPicker) {
        }
    })
    .setDismissListener(DialogInterface.OnDismissListener {
    })
    .show()

Theme

Default is a light one(R.style.HmsPickerThemeLight) and a dark one(R.style.HmsPickerThemeDark) is also available.

You can create your own theme. Example can be found here.

Remember that drawables you use should be selector or ripple.

License

Apache License 2.0 for android-betterpickers.

MIT License for this project.