Range Time Picker Dialog

A custom dialog that allow you to set a start time and end time.
Alternatives To Range Time Picker Dialog
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Singledateandtimepicker1,015
9 days ago4October 05, 2020158apache-2.0Java
You can now select a date and a time with only one widget !
Vue Ctk Date Time Picker7962916a year ago82March 10, 2022121mitVue
VueJS component to select dates & time, including a range mode
Linear Time Picker605
5 years ago2otherJava
Gorgeous Android Time and Date picker library inspired by the Timely app
Compose Material Dialogs461
21 days ago17October 16, 202218otherKotlin
A Material Dialog Builder for Jetpack Compose
Md Date Time Picker2761582 months ago11May 12, 201746otherJavaScript
An implementation of Material Design Picker components in vanilla CSS, JS, and HTML
Hijridatepicker130
4 months ago7apache-2.0Java
Material (Gregorian - Hijri) Date & Time Picker
Range Time Picker Dialog69
2 years ago1May 09, 20186apache-2.0Java
A custom dialog that allow you to set a start time and end time.
Classicmaterialtimepicker56
2 years ago1June 10, 20193Kotlin
Classic Material Time Picker
Date_time_picker33
2 years ago7July 08, 202119otherDart
A Flutter widget to show a text form field to display a date or clock dialog. This widget extend TextField and has a similar behavior as TextFormField.
Androideasyutils23
5 years agomitJava
AndroidEasyUtils is a simple android library that contains some utils method which is much more needed when working in any android project. Categories are - Validators, Dialog, Progress Dialog, Connectivity, Date Time, Bitmaps, HashMap and Others.
Alternatives To Range Time Picker Dialog
Select To Compare


Alternative Project Comparisons
Readme

Range-Time-Picker-Dialog

API

Simple Android Library that provide you a custom dialog that allow you to set a start time and end time.

Screenshot

Install

Add this to your project build.gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Add this to your module build.gradle

   dependencies {
        implementation 'com.github.PuffoCyano:Range-Time-Picker-Dialog:v1.8'
    }

Usage

In your activity (Default method "newInstance()"):

    // Create an instance of the dialog fragment and show it
    RangeTimePickerDialog dialog = new RangeTimePickerDialog();
    dialog.newInstance();
    dialog.setRadiusDialog(20); // Set radius of dialog (default is 50)
    dialog.setIs24HourView(true); // Indicates if the format should be 24 hours
    dialog.setColorBackgroundHeader(R.color.colorPrimary); // Set Color of Background header dialog
    dialog.setColorTextButton(R.color.colorPrimaryDark); // Set Text color of button
    FragmentManager fragmentManager = getFragmentManager();
    dialog.show(fragmentManager, "");

You can instantiate the dialog with more parameters:

     // Create an instance of the dialog fragment and show it
     RangeTimePickerDialog dialog = new RangeTimePickerDialog();
     dialog.newInstance(R.color.CyanWater, R.color.White, R.color.Yellow, R.color.colorPrimary, true);
     FragmentManager fragmentManager = getFragmentManager();
     dialog.show(fragmentManager, "");

To read parameter from Dialog your activity have to implements the interface ISelectedTime:

public class MainActivity extends AppCompatActivity implements RangeTimePickerDialog.ISelectedTime

Then you have to override the method "onSelectedTime":

@Override
public void onSelectedTime(int hourStart, int minuteStart, int hourEnd, int minuteEnd)
{
  // Use parameters provided by Dialog
  Toast.makeText(this, "Start: "+hourStart+":"+minuteStart+"\nEnd: "+hourEnd+":"+minuteEnd, Toast.LENGTH_SHORT).show();
}

In your fragment:

   // Create an instance of the dialog fragment and show it
   RangeTimePickerDialog dialog = new RangeTimePickerDialog();
   dialog.newInstance(R.color.CyanWater, R.color.White, R.color.Yellow, R.color.colorPrimary, true);
   FragmentManager fragmentManager = getFragmentManager();
   dialog.setTargetFragment(this, MY_FRAGMENT_ID); // MY_FRAGMENT_ID is a personal identifier that allow you to get parameter from dialog into onActivityResult
   dialog.show(fragmentManager, "");

When you have to read parameter provided by Dialog you have to override onResultActivity in your fragment:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == MY_FRAGMENT_ID)
   {
      if (resultCode == Activity.RESULT_OK)
      {
         if (data.getExtras().containsKey(RangeTimePickerDialog.HOUR_START))
         {
            int hourStart = data.getExtras().getInt(RangeTimePickerDialog.HOUR_START);
            int hourEnd = data.getExtras().getInt(RangeTimePickerDialog.HOUR_END);
            int minuteStart = data.getExtras().getInt(RangeTimePickerDialog.MINUTE_START);
            int minuteEnd = data.getExtras().getInt(RangeTimePickerDialog.MINUTE_END);
            // Use the returned value
            Toast.makeText(getActivity(), "Time start:"+hourStart+":"+minuteStart+"\nUntil: "+hourEnd+":"+minuteEnd, Toast.LENGTH_SHORT).show();
         }
      }
   }
}

Methods

  • setColorTabUnselected(int colorTabUnselected): Set color of tab item when it is unselected
  • setColorTabSelected(int colorTabSelected): Set color of tab item when it is selected
  • setColorTextButton(int colorTextButton): Set button text color
  • setColorBackgroundHeader(int colorBackgroundHeader): Set background color of header dialog
  • setIs24HourView(boolean is24HourView): Set true if you want see time into 24 hour format
  • setMessageErrorRangeTime(String messageErrorRangeTime): Set message error that appears when you select a end time greater than start time (only if "validateRange" is true)
  • setTextBtnPositive(String textBtnPositive): Set positive button text
  • setTextBtnNegative(String textBtnNegative): Set negative button text
  • setRadiusDialog(int radiusDialog): Set dialog radius (default is 50)
  • setTextTabStart(String textTabStart): Set tab start text
  • setTextTabEnd(String textTabEnd): Set tab end text
  • setValidateRange(boolean validateRange):Set true if you want validate the range time (start time < end time). Set false if you want select any time
  • setColorBackgroundTimePickerHeader(int colorBackgroundTimePickerHeader): Set background color of header timePicker
  • enableMinutes(boolean value): Enable or disable minutes clock
  • setInitialStartClock(int hour, int minute): Method to set initial start clock
  • setInitialEndClock(int hour, int minute): Method to set initial end clock
  • setStartTabIcon(int startTabIcon): Method to change start tab icon
  • setEndTabIcon(int endTabIcon): Method to change end tab icon
  • setInitialOpenedTab(InitialOpenedTab initialOpenedTab): Method to select which tab are selected on open (START_CLOCK_TAB or END_CLOCK_TAB)
  • setInputKeyboardAsDefault(boolean inputKeyboardAsDefault): Method to set keyboard input as default (Only on Oreo device)

License

Copyright 2018 Alessandro Marino

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless 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.
Popular Time Projects
Popular Dialog Projects
Popular Libraries Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Java
Time
Tabs
Dialog
Clock
Picker