Skip to content

An android library to create ranged time picker dialog using material design components.

License

Notifications You must be signed in to change notification settings

ashiqursuperfly/Android-Material-Ranged-Time-Picker-Dialog

Repository files navigation

material-ranged-time-picker-dialog

License: MIT

Setup

  • Make sure you are using material components in your default AppTheme i.e your AppTheme inherits from a material theme
  • In project-level build.gradle:
  allprojects {
  	repositories {
          // ...
          maven { url 'https://jitpack.io' }
      }
  }
  • In your app-level build.gradle file:
implementation 'com.github.ashiqursuperfly:Android-Material-Ranged-Time-Picker-Dialog:x.x.x'

Make sure you use the latest release version, this project adheres to Semantic Versioning.

Usage

val dialog = TimeRangePickerDialog(
    startLabel = "START",
    endLabel = "END",
    is24HourView = false,
    onPickedTimeTime = object : TimeRangePickerDialog.OnPickedTimeRange {
        override fun onPickedTime(
            startHour: Int,
            startMinute: Int,
            endHour: Int,
            endMinute: Int
        ) {
            val str = "${startHour}:${startMinute} ${endHour}:${endMinute}"
            text_view.text = str
        }

    }
)
// now you can apply slight modifications to the dialog like you can do for any dialog e.g:
d.isCancelable = false
// finally just show the dialog when you want with
d.show(supportFragmentManager, "my-dialog-tag-string")

Contributing

  • Create an issue with appropriate description (explain which behaviour you want to change)
  • Add either one of the following labels: bug, enhancement, documentation, question
  • Prefix the branch name with the issue label and issue number like so: label/number-branchName e.g: bug/3-Hour24ViewNotVisible
  • send a PR