HmsPicker

Additional

Language
Kotlin
Version
1.0.1 (May 16, 2018)
Created
Feb 12, 2018
Updated
May 16, 2018
Owner
Reed (DeweyReed)
Contributor
Reed (DeweyReed)
1
Activity
Badge
Generate
Download
Source code
APK file

Advertisement

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

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

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.