• Stars
    star
    328
  • Rank 127,841 (Top 3 %)
  • Language
    Java
  • Created about 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Android library containing a shamsi (persian calendar) date picker and a time picker with Material Design style

PersianMaterialDateTimePicker

This library offers a hijri/shamsi (Iran Calendar) Date Picker and a normal time picker designed on Google's Material Design Principals For Pickers for Android 4.0.3 (API 15) +.

Date Picker Time Picker
Date Picker Time Picker

You can report any issue on issues page. Note: If you speak Persian, you can submit issues with Persian (Farsi) language and I will check them. :)

#Importing Please refer to the relative wiki page.

Usage

The library follows the same API as other pickers in the Android framework. After adding the library, for using a picker in your project you need to:

  1. Implement an OnTimeSetListener/OnDateSetListener
  2. Create a TimePickerDialog/DatePickerDialog using the supplied factory
  3. Theme the pickers

Implement an OnTimeSetListener/OnDateSetListener

In order to receive the date or time set in the picker, you will need to implement the OnTimeSetListener or OnDateSetListener interfaces. Typically this will be the Activity or Fragment that creates the Pickers. The callbacks use the same API as the standard Android pickers.

@Override
public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
  String time = "You picked the following time: "+hourOfDay+"h"+minute;
  timeTextView.setText(time);
}

@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
  String date = "You picked the following date: "+dayOfMonth+"/"+(monthOfYear+1)+"/"+year;
  dateTextView.setText(date);
}

Create a TimePickerDialog/DatePickerDialog using the supplied factory

You will need to create a new instance of TimePickerDialog or DatePickerDialog using the static newInstance() method, supplying proper default values and a callback. Once the dialogs are configured, you can call show().

PersianCalendar persianCalendar = new PersianCalendar();
DatePickerDialog datePickerDialog = DatePickerDialog.newInstance(
  MainActivity.this,
  persianCalendar.getPersianYear(),
  persianCalendar.getPersianMonth(),
  persianCalendar.getPersianDay()
);
datePickerDialog.show(getFragmentManager(), "Datepickerdialog");

Theme the pickers

You can theme the pickers by overwriting the color resources mdtp_accent_color and mdtp_accent_color_dark in your project.

<color name="mdtp_accent_color">#009688</color>
<color name="mdtp_accent_color_dark">#00796b</color>

#Additional Options

  • TimePickerDialog dark theme
    The TimePickerDialog has a dark theme that can be set by calling
timePickerDialog.setThemeDark(true);
  • DatePickerDialog dark theme The DatePickerDialog has a dark theme that can be set by calling
datePickerDialog.setThemeDark(true);
  • TimePickerDialog setTitle(String title) Shows a title at the top of the TimePickerDialog

  • setSelectableDays(PersianCalendar[] days) You can pass a PersianCalendar[] to the DatePickerDialog. This values in this list are the only acceptable dates for the picker. It takes precedence over setMinDate(PersianCalendar day) and setMaxDate(PersianCalendar day)

  • setHighlightedDays(PersianCalendar[] days) You can pass a PersianCalendar[] of days to highlight. They will be rendered in bold. You can tweak the color of the highlighted days by overwriting mdtp_date_picker_text_highlighted

  • OnDismissListener and OnCancelListener
    Both pickers can be passed a DialogInterface.OnDismissLisener or DialogInterface.OnCancelListener which allows you to run code when either of these events occur.

timePickerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
    @Override
    public void onCancel(DialogInterface dialogInterface) {
      Log.d("TimePicker", "Dialog was cancelled");
    }
});
  • vibrate(boolean vibrate) Set whether the dialogs should vibrate the device when a selection is made. This defaults to true.

#Credits This libary is completely based on MaterialDateTimePicker Library and Persian Calendar.

More Repositories

1

KPreferences

A Kotlin library for reactive and boilerplate-free SharedPreferences in Android
Kotlin
19
star
2

UnconstrainedOptimization

Unconstrained optimization algorithms in python, line search and trust region methods
Jupyter Notebook
18
star
3

RxActivityResults

Android onActivityResult wrapper powered by RxJava
Java
14
star
4

WhatILearntFromAUTOptimizationCourse

What I learnt from the optimization course, under supervision of Dr. Maryam Amirmazlaghani at AUT.
14
star
5

Android-FastSearch

An Android application which searchs all of the content on the device in a quick way.
Java
13
star
6

CleanTvMaze

A modern android sample application built with Kotlin to show clean architecture usage in Android
Kotlin
8
star
7

WhyHowMvpOnAndroid

Why and how to implement MVP on Android
7
star
8

FileGrabberBot

Telegram File Grabber Bot
PHP
4
star
9

ConstrainedOptimization-QP

Constrained optimization algorithms (log barrier and interior point methods) for a Quadratic Program
Jupyter Notebook
4
star
10

MohandesplusBot

A Telegram bot for managing telegram channels.
PHP
4
star
11

AI-DefiniteSearchAlgs

Implementation of definite search algorithms in my AI course at Amirkabir University
Java
3
star
12

ntk-lookahead-active-learning

[NeurIPS'22] Making Look-Ahead Active Learning strategies feasible with Neural Tangent Kernels
Python
3
star
13

DataMining-HomeWork

My homeworks for data mining course in AUT under supervision of Dr Amir Mazlaghani (Fall - Winter 2018)
Jupyter Notebook
2
star
14

NUMEX-Interpreter

My Final Project for Programming Languages course in AUT under supervision of Dr. Mehran S. Fallah.
Racket
2
star
15

SayehComputer

SAYEH Implementation in VHDL - one of our computer architecture course projects
2
star
16

SayehCompiler

Kotlin
1
star
17

JoocheAndroid

Java
1
star
18

ML-AndrewNG

My implementation of programming exercises for machine learning course from Andrew NG through Coursera.
MATLAB
1
star
19

TvMaze-CleanArchitecture

A Clean Architecture sample for EasyMVP android library
Java
1
star
20

EM-FaceDetection

My engineering mathematics final project
Jupyter Notebook
1
star
21

WP-Reyhoon

My Web Programming course (at AUT) assignments and final project
JavaScript
1
star
22

AveragingGPSSegments

A novel solution for the "Averaging GPS Segments" problem using linear splines model.
R
1
star
23

ClassicalModernSearchAlgorithms

Classical and modern search algorithms (Artificial Intelligence Course AUT)
Java
1
star
24

LR0AutomataGenerator

AUT compiler course's final project (Fall 2017), professor: Saeedeh Momtazi
Kotlin
1
star
25

CUDA-Shazam

Matching songs using Fourier transform and cosine similarity. Massively parallel using CUDA
Cuda
1
star