{"id":13798812,"url":"https://github.com/akexorcist/SnapTimePicker","last_synced_at":"2025-05-13T06:31:38.345Z","repository":{"id":53727465,"uuid":"168870732","full_name":"akexorcist/SnapTimePicker","owner":"akexorcist","description":"[Android] Another Material Time Picker","archived":false,"fork":false,"pushed_at":"2021-04-13T17:45:11.000Z","size":703,"stargazers_count":128,"open_issues_count":3,"forks_count":25,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T20:07:19.447Z","etag":null,"topics":["android","android-library","java","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akexorcist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-02T19:45:41.000Z","updated_at":"2025-04-01T09:15:45.000Z","dependencies_parsed_at":"2022-08-23T22:00:40.829Z","dependency_job_id":null,"html_url":"https://github.com/akexorcist/SnapTimePicker","commit_stats":null,"previous_names":["akexorcist/android-snaptimepicker"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akexorcist%2FSnapTimePicker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akexorcist%2FSnapTimePicker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akexorcist%2FSnapTimePicker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akexorcist%2FSnapTimePicker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akexorcist","download_url":"https://codeload.github.com/akexorcist/SnapTimePicker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253888886,"owners_count":21979522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","java","kotlin"],"created_at":"2024-08-04T00:00:54.409Z","updated_at":"2025-05-13T06:31:37.979Z","avatar_url":"https://github.com/akexorcist.png","language":"Kotlin","readme":"[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SnapTimePicker-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/8107)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.akexorcist/snap-time-picker/badge.svg)](https://search.maven.org/artifact/com.akexorcist/snap-time-picker)\n![Minimum SDK Version](https://img.shields.io/badge/minSdkVersion-18-brightgreen) \n[![Workflow Status](https://github.com/akexorcist/SnapTimePicker/actions/workflows/android.yml/badge.svg)](https://github.com/akexorcist/SnapTimePicker/actions)\n\nSnap Time Picker\n==============================\nAnother Material Time Picker for developer who do not like default Material Time Picker that difficult to use for most users\n\n![Snap Time Picker Sample](https://raw.githubusercontent.com/akexorcist/Android-SnapTimePicker/master/image/00_header.gif)\n\nDownload\n===============================\nSince version 1.0.3 will [move from JCenter to MavenCentral](https://developer.android.com/studio/build/jcenter-migration)\n```groovy\n// build.gradle (project)\nallprojects {\n    repositories {\n        mavenCentral()\n        /* ... */\n    }\n}\n```\n\n**Gradle**\n```\nimplementation 'com.akexorcist:snap-time-picker:1.0.3'\n```\n\nFeature\n===========================\n* iOS Time Picker with Material Design style \n* Some text \u0026 color customization\n* Selectable time range support\n* ViewModel support for event callback with LiveData (See example)\n\n![Snap Time Picker Sample](https://raw.githubusercontent.com/akexorcist/Android-SnapTimePicker/master/image/01_default.jpg)\n\nUsage\n===========================\nRelevant class in SnapTimePicker\n* SnapTimePickerDialog - Main Class \n* TimeValue - Time data holder that contain hour and minute\n* TimeRange - Time range data holder that contain the range of time with start (TimeValue) and end (TimeValue)\n\nTo use the SnapTimePicker you have to create the SnapTimePickerDialog from builder\n```kotlin\nval dialog = SnapTimePickerDialog.Builder().build()\n//\ndialog.show(supportFragmentManager, tag)\n```\n\nSnapTimePickerDialog made from DialogFragment (AndroidX) so it need SupportFragmentManager from Activity/Fragment and any string tag. If you have no idea for the dialog tag. You can use `SnapTimePickerDialog.TAG`\n\nNote - Cannot reuse the SnapTimePickerDialog instance. Please create new instance every time \n\nTo custom some text and color in TimePickerDialog. \n```kotlin\nSnapTimePickerDialog.Builder().apply {\n    setTitle(R.string.title)\n    setPrefix(R.string.time_suffix)\n    setSuffix(R.string.time_prefix)\n    setThemeColor(R.color.colorAccent)\n    setTitleColor(R.color.colorWhite)\n}.build().show(supportFragmentManager, tag)\n```\n\n`Title`, `Prefix` and `Suffix` must be define with string resource. `ThemeColor` and `TitleColor` must be color resource\n\n![Text Customization](https://raw.githubusercontent.com/akexorcist/Android-SnapTimePicker/master/image/02_text.jpg)\n\n![Color Customization](https://raw.githubusercontent.com/akexorcist/Android-SnapTimePicker/master/image/03_color.jpg)\n\nTo custom the positive and negative button.\n```kotlin\nSnapTimePickerDialog.Builder().apply {\n    setPositiveButtonText(R.string.accept)\n    setNegativeButtonText(R.string.reject)\n    setPositiveButtonColor(R.color.white)\n    setNegativeButtonColor(R.color.white)\n    setButtonTextAllCaps(false)\n}.build().show(supportFragmentManager, tag)\n```\nPositive and negative button text will be all-capitalized by default.\n\nTo set pre-selected time and time range in TimePickerDialog. \n```kotlin\nSnapTimePickerDialog.Builder().apply {\n    setPreselectedTime(TimeValue(2, 34))\n    setSelectableTimeRange(TimeRange(TimeValue(2, 15), TimeValue(14, 30)))\n}.build().show(supportFragmentManager, tag)\n```\n\n![Color Customization](https://raw.githubusercontent.com/akexorcist/Android-SnapTimePicker/master/image/04_time_range.jpg)\n\nFor event callback from SnapTimePicker, you have assign the listener after build the SnapTimePickerDialog from builder.\n```kotlin\nSnapTimePickerDialog.Builder().apply {\n    // \n}.build().apply{\n    setListener { hour, minute -\u003e \n        // Do something when user selected the time \n    }\n}.show(supportFragmentManager, tag)\n```\n\nBut use listener does not good enough if the app can work in portrait and landscape. To support screen orientation, call `useViewModel()` in SnapTimePickerDialog then observe the event callback from SnapTimePicker's ViewModel from `SnapTimePickerUtil` \n\n```kotlin\nSnapTimePickerDialog.Builder().apply {\n    useViewModel()\n}.build().show(supportFragmentManager, SnapTimePickerDialog.TAG)\n\nSnapTimePickerUtil.observe(this) { selectedHour: Int, selectedMinute: Int -\u003e\n    onTimePicked(selectedHour, selectedMinute)\n}\n```\n\nSnapTimePickerDialog can be called from anywhere in your code but `SnapTimePickerUtil.observe(...)` must called in `onCreate()` only (That's how ViewModel and LiveData works).\n\n\nLicence\n===========================\nCopyright 2021 Akexorcist\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Kotlin"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakexorcist%2FSnapTimePicker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakexorcist%2FSnapTimePicker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakexorcist%2FSnapTimePicker/lists"}