项目作者: alhazmy13

项目描述 :
Material (Gregorian - Hijri) Date & Time Picker
高级语言: Java
项目地址: git://github.com/alhazmy13/HijriDatePicker.git
创建时间: 2015-10-17T11:25:38Z
项目社区:https://github.com/alhazmy13/HijriDatePicker

开源协议:Apache License 2.0

下载




Hijri Date Picker (UmAlQuraCalendar)




This library offers a hijri (Islamic Calendar) Date Picker designed on Google’s Material Design Principals For Pickers for Android 5.0 (API 21) +.

Demo Hijri
Time Gregorian

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

Installation

Maven

  1. <dependency>
  2. <groupId>net.alhazmy13.hijridatepicker</groupId>
  3. <artifactId>library</artifactId>
  4. <version>3.0.0</version>
  5. </dependency>

Gradle

  1. dependencies {
  2. compile 'net.alhazmy13.hijridatepicker:library:3.0.0'
  3. }

Usage

The library follows the same API as other pickers in the Android framework.
After adding the library, you need to:

  1. Implement an onDateSet
  2. Create a HijriCalendarDialog using the supplied factory
  3. Theme the pickers

Implement an OnTimeSetListener/OnDateSetListener

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

Note: Months start from 0.

  1. // TimePickerDialog
  2. @Override
  3. public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
  4. // YOUR CODE
  5. }
  6. // GregorianDatePickerDialog
  7. @Override
  8. public void onDateSet(GregorianDatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
  9. //YOUR CODE
  10. }
  11. // HijriDatePickerDialog
  12. @Override
  13. public void onDateSet(HijriDatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
  14. //YOUR CODE
  15. }

Create a GregorianDatePickerDialog

You will need to create a new instance of GregorianDatePickerDialog. Once the dialogs are configured, you can call show().

  1. Calendar now = Calendar.getInstance();
  2. GregorianDatePickerDialog dpd = GregorianDatePickerDialog.newInstance(
  3. this,
  4. now.get(Calendar.YEAR),
  5. now.get(Calendar.MONTH),
  6. now.get(Calendar.DAY_OF_MONTH));
  7. dpd.show(getFragmentManager(), "GregorianDatePickerDialog");

Create a HijriDatePickerDialog

Same as GregorianDatePickerDialog but you need to use UmmalquraCalendar insted of Calendar class.

  1. UmmalquraCalendar now = new UmmalquraCalendar();
  2. HijriDatePickerDialog dpd = HijriDatePickerDialog.newInstance(
  3. this,
  4. now.get(UmmalquraCalendar.YEAR),
  5. now.get(UmmalquraCalendar.MONTH),
  6. now.get(UmmalquraCalendar.DAY_OF_MONTH));
  7. dpd.show(getFragmentManager(), "HijriDatePickerDialog");

TimePickerDialog

  1. Calendar now = Calendar.getInstance();
  2. TimePickerDialog tpd = TimePickerDialog.newInstance(
  3. this,
  4. now.get(Calendar.HOUR_OF_DAY),
  5. now.get(Calendar.MINUTE),
  6. mode24Hours.isChecked()
  7. );

Credits

License

  1. Copyright 2015 alhazmy
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.