From 66a9f56ae5da94ca9ffb5c9eb9a93ec9972b6878 Mon Sep 17 00:00:00 2001 From: aalhazmy Date: Thu, 18 Feb 2016 11:59:33 +0300 Subject: [PATCH] Fix uncorrect month value --- .idea/misc.xml | 16 ---------- README.md | 6 ++-- app/app.iml | 3 -- libary/build.gradle | 2 +- libary/libary.iml | 19 +++++------ .../alhazmy13/hijridatepicker/EnumConfig.java | 32 ------------------- .../hijridatepicker/GeneralAttribute.java | 2 +- .../hijridatepicker/HijriCalendarDialog.java | 28 +++++++++++++++- .../hijridatepicker/HijriCalendarView.java | 12 +++---- .../hijridatepicker/MonthDialog.java | 2 +- .../alhazmy13/hijridatepicker/YearDialog.java | 2 +- .../calendar/HijriCalendar.java | 4 +-- 12 files changed, 50 insertions(+), 78 deletions(-) delete mode 100644 libary/src/main/java/net/alhazmy13/hijridatepicker/EnumConfig.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 7158618..5d19981 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -43,20 +43,4 @@ - - - - - 1.8 - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 073edd9..0f7b081 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![](https://img.shields.io/badge/Platform-Android-brightgreen.svg) ![](https://img.shields.io/badge/Android-CustomView-blue.svg) ![](https://img.shields.io/crates/l/rustc-serialize.svg) -![](https://img.shields.io/badge/version-1.3.0-blue.svg) +![](https://img.shields.io/badge/version-1.3.2-blue.svg) This library offers a hijri (Islamic Calendar) Date Picker designed on [Google's Material Design Principals For Pickers](http://www.google.com/design/spec/components/pickers.html) for Android 4.1 (API 16) +. @@ -21,14 +21,14 @@ You can report any issue on issues page. **Note: If you speak Arabic, you can su net.alhazmy13.hijridatepicker libary -1.3.1 +1.3.2 ``` **Gradle** ```gradle dependencies { - compile 'net.alhazmy13.hijridatepicker:libary:1.3.1' + compile 'net.alhazmy13.hijridatepicker:libary:1.3.2' } ``` diff --git a/app/app.iml b/app/app.iml index e16b15d..7aabb22 100644 --- a/app/app.iml +++ b/app/app.iml @@ -76,8 +76,6 @@ - - @@ -87,7 +85,6 @@ - diff --git a/libary/build.gradle b/libary/build.gradle index c05ca47..a63b0b1 100644 --- a/libary/build.gradle +++ b/libary/build.gradle @@ -15,7 +15,7 @@ ext { siteUrl = 'https://github.com/alhzmy13/HijriDatePicker' gitUrl = 'https://github.com/alhzmy13/HijriDatePicker.git' - libraryVersion = '1.3.1' + libraryVersion = '1.3.2' developerId = 'alhazmy13' developerName = 'Abdullah Alhazmy' diff --git a/libary/libary.iml b/libary/libary.iml index 0f6d07a..137cf60 100644 --- a/libary/libary.iml +++ b/libary/libary.iml @@ -1,5 +1,5 @@ - + @@ -62,13 +62,6 @@ - - - - - - - @@ -76,7 +69,13 @@ - + + + + + + + @@ -93,9 +92,7 @@ - - diff --git a/libary/src/main/java/net/alhazmy13/hijridatepicker/EnumConfig.java b/libary/src/main/java/net/alhazmy13/hijridatepicker/EnumConfig.java deleted file mode 100644 index e5dbe8b..0000000 --- a/libary/src/main/java/net/alhazmy13/hijridatepicker/EnumConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.alhazmy13.hijridatepicker; - -/** - * Created by Alhazmy13 on 2/3/16. - */ -interface EnumConfig { - enum Mode{ - Hijri(1), - Gregorian(2); - private int mode; - Mode(int mode) { - this.mode = mode; - } - public int getModeValue() { - return mode; - } - - } - - enum Language{ - Arabic(1), - English(2); - private int language; - Language(int language) { - this.language = language; - } - public int getLanguageValue() { - return language; - } - - } -} diff --git a/libary/src/main/java/net/alhazmy13/hijridatepicker/GeneralAttribute.java b/libary/src/main/java/net/alhazmy13/hijridatepicker/GeneralAttribute.java index 0c82ae0..11d558b 100644 --- a/libary/src/main/java/net/alhazmy13/hijridatepicker/GeneralAttribute.java +++ b/libary/src/main/java/net/alhazmy13/hijridatepicker/GeneralAttribute.java @@ -16,7 +16,7 @@ class GeneralAttribute { public static String title; public static int language; public static HijriCalendarView.OnDateSetListener onDateSetListener; - public static int mode = EnumConfig.Mode.Hijri.getModeValue(); + public static int mode = HijriCalendarDialog.Mode.Hijri.getModeValue(); public static int hijri_min; public static int hijri_max; public static int gregorian_min; diff --git a/libary/src/main/java/net/alhazmy13/hijridatepicker/HijriCalendarDialog.java b/libary/src/main/java/net/alhazmy13/hijridatepicker/HijriCalendarDialog.java index 3be83b3..b851462 100644 --- a/libary/src/main/java/net/alhazmy13/hijridatepicker/HijriCalendarDialog.java +++ b/libary/src/main/java/net/alhazmy13/hijridatepicker/HijriCalendarDialog.java @@ -10,11 +10,37 @@ /** * Created by Alhazmy13 on 1/6/16. + * HijriDatePicker */ -public class HijriCalendarDialog implements EnumConfig{ +public class HijriCalendarDialog { public HijriCalendarDialog(){ + } + public enum Mode{ + Hijri(1), + Gregorian(2); + private int mode; + Mode(int mode) { + this.mode = mode; + } + public int getModeValue() { + return mode; + } + + } + + public enum Language{ + Arabic(1), + English(2); + private int language; + Language(int language) { + this.language = language; + } + public int getLanguageValue() { + return language; + } + } public static class Builder{ public Builder(Context context) { diff --git a/libary/src/main/java/net/alhazmy13/hijridatepicker/HijriCalendarView.java b/libary/src/main/java/net/alhazmy13/hijridatepicker/HijriCalendarView.java index f6bc49f..305565d 100644 --- a/libary/src/main/java/net/alhazmy13/hijridatepicker/HijriCalendarView.java +++ b/libary/src/main/java/net/alhazmy13/hijridatepicker/HijriCalendarView.java @@ -119,7 +119,7 @@ private void initViews() { cancelButton =(Button)findViewById(R.id.closeButton); days=context.getResources().getStringArray(R.array.hijri_date_picker_days); textViewList = new ArrayList<>(); - if(GeneralAttribute.language == EnumConfig.Language.Arabic.getLanguageValue())callSwitchLang("ar"); else callSwitchLang("en"); + if(GeneralAttribute.language == HijriCalendarDialog.Language.Arabic.getLanguageValue())callSwitchLang("ar"); else callSwitchLang("en"); calendarInstance = new CalendarInstance(context,GeneralAttribute.mode); } @@ -161,11 +161,11 @@ private void initDays() { textView.setTextColor(context.getResources().getColor(android.R.color.darker_gray)); if (count <= calendarInstance.lengthOfMonth()) { if (firstTime && j == calendarInstance.getWeekStartFrom()) { - textView.setText(GeneralAttribute.language == EnumConfig.Language.Arabic.getLanguageValue()?Utility.toArabicNumbers(count+""):count+""); + textView.setText(GeneralAttribute.language == HijriCalendarDialog.Language.Arabic.getLanguageValue()?Utility.toArabicNumbers(count+""):count+""); firstTime = false; count++; } else if (!firstTime) { - textView.setText(GeneralAttribute.language == EnumConfig.Language.Arabic.getLanguageValue()?Utility.toArabicNumbers(count+""):count+""); + textView.setText(GeneralAttribute.language == HijriCalendarDialog.Language.Arabic.getLanguageValue()?Utility.toArabicNumbers(count+""):count+""); count++; } else { textView.setText(""); @@ -215,7 +215,7 @@ public boolean onTouch(View view, MotionEvent motionEvent) { @Override public void onClick(View view) { if (GeneralAttribute.onDateSetListener != null) { - GeneralAttribute.onDateSetListener.onDateSet(calendarInstance.getYear(), calendarInstance.getMonth(), calendarInstance.getDayOfMonth()); + GeneralAttribute.onDateSetListener.onDateSet(calendarInstance.getYear(), calendarInstance.getMonth()+1, calendarInstance.getDayOfMonth()); } dismiss(); @@ -230,9 +230,9 @@ public void onClick(View view) { } private void updateCalenderInformation(){ - dayTextView.setText(GeneralAttribute.language == EnumConfig.Language.Arabic.getLanguageValue() ? Utility.toArabicNumbers(calendarInstance.getDayOfMonth() + "") : calendarInstance.getDayOfMonth() + ""); + dayTextView.setText(GeneralAttribute.language == HijriCalendarDialog.Language.Arabic.getLanguageValue() ? Utility.toArabicNumbers(calendarInstance.getDayOfMonth() + "") : calendarInstance.getDayOfMonth() + ""); monthTextView.setText(calendarInstance.getMonthName()); - yearTextView.setText(GeneralAttribute.language == EnumConfig.Language.Arabic.getLanguageValue() ? Utility.toArabicNumbers(calendarInstance.getYear() + "") : calendarInstance.getYear() + ""); + yearTextView.setText(GeneralAttribute.language == HijriCalendarDialog.Language.Arabic.getLanguageValue() ? Utility.toArabicNumbers(calendarInstance.getYear() + "") : calendarInstance.getYear() + ""); } diff --git a/libary/src/main/java/net/alhazmy13/hijridatepicker/MonthDialog.java b/libary/src/main/java/net/alhazmy13/hijridatepicker/MonthDialog.java index 5ca8ba5..3a550c5 100644 --- a/libary/src/main/java/net/alhazmy13/hijridatepicker/MonthDialog.java +++ b/libary/src/main/java/net/alhazmy13/hijridatepicker/MonthDialog.java @@ -84,7 +84,7 @@ public MonthDialog(Context context) { public boolean onTouch(View view, MotionEvent motionEvent) { TextView temp=(TextView)view; if (onMonthChanged != null) { - onMonthChanged.onMonthChanged(textViews.indexOf(temp)); + onMonthChanged.onMonthChanged(textViews.indexOf(temp)-1); } dismiss(); return false; diff --git a/libary/src/main/java/net/alhazmy13/hijridatepicker/YearDialog.java b/libary/src/main/java/net/alhazmy13/hijridatepicker/YearDialog.java index ef07636..ef24349 100644 --- a/libary/src/main/java/net/alhazmy13/hijridatepicker/YearDialog.java +++ b/libary/src/main/java/net/alhazmy13/hijridatepicker/YearDialog.java @@ -45,7 +45,7 @@ public YearDialog(Context context) { this.mContext=context; this.setOnDismissListener(this); initViews(); - if(GeneralAttribute.mode == EnumConfig.Mode.Hijri.getModeValue()) { + if(GeneralAttribute.mode == HijriCalendarDialog.Mode.Hijri.getModeValue()) { numberPicker.setMaxValue(GeneralAttribute.hijri_max); numberPicker.setMinValue(GeneralAttribute.hijri_min); }else{ diff --git a/libary/src/main/java/net/alhazmy13/hijridatepicker/calendar/HijriCalendar.java b/libary/src/main/java/net/alhazmy13/hijridatepicker/calendar/HijriCalendar.java index 90fa641..6974990 100644 --- a/libary/src/main/java/net/alhazmy13/hijridatepicker/calendar/HijriCalendar.java +++ b/libary/src/main/java/net/alhazmy13/hijridatepicker/calendar/HijriCalendar.java @@ -122,10 +122,10 @@ public int getCurrentMonth() { } @Override public int getOffsetMonthCount() { - int temp = countMonth-1; + int temp = countMonth; if(temp == -1) temp = 11; - else if(temp== 12) + else if(temp>= 12) temp = 0; return temp; }