HmsPickerView

Additional

Language
Kotlin
Version
0.2.0 (May 27, 2020)
Created
Feb 27, 2019
Updated
May 27, 2020 (Retired)
Owner
DeweyReed
Contributors
DeweyReed
pawelsa
2
Activity
Badge
Generate
Download
Source code

HmsPickerView

A beautiful little Android view to pick hours, minutes and seconds.

Installation

Step 1. 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 "xyz.aprildown:HmsPickerView:${version}"
}

Usage

In the XML:

<xyz.aprildown.hmspickerview.HmsPickerView
    android:id="@+id/hmsPickerView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<attr name="hpv_time_text_size" format="dimension" />
<!--default: 40sp port, 32sp land-->
<attr name="hpv_digit_text_size" format="dimension" />
<!--default: 40sp port, 24sp land-->

In the code:

fun getHours(): Int
fun setHours(hours: Int)

fun getMinutes(): Int
fun setMinutes(minutes: Int)

fun getSeconds(): Int
fun setSeconds(seconds: Int)

fun getTimeInMillis(): Long
fun setTimeInMillis(time: Long)

fun setTimeTextSize(@Px textSize: Int)
fun setDigitTextSize(@Px textSize: Int)

fun setListener(l: HmsPickerView.Listener)
interface Listener {
    /**
     * Indicates [HmsPickerView] now has an valid input(anything except 00h 00m 00s).
     * This methods can be used to allow user to go forward (such as enabling "next" button).
     */
    fun onHmsPickerViewHasValidInput(hmsPickerView: HmsPickerView)

    /**
     * Indicates [HmsPickerView]'s input becomes 00h 00m 00s.
     * This methods can be used to prevent user from going forward(such as disabling "next" button).
     */
    fun onHmsPickerViewHasNoInput(hmsPickerView: HmsPickerView)
}

Use this view in a dialog

  1. Create a XML file like this one.
  2. Wrap it into an AlertDialog like this one.

???? Please star this repo if you like it ????

License

LICENSE