Skip to content

Commit

Permalink
Fix uncorrect month value
Browse files Browse the repository at this point in the history
  • Loading branch information
aalhazmy committed Feb 18, 2016
1 parent 6cc17c3 commit 66a9f56
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 78 deletions.
16 changes: 0 additions & 16 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) +.

Expand All @@ -21,14 +21,14 @@ You can report any issue on issues page. **Note: If you speak Arabic, you can su
<dependency>
<groupId>net.alhazmy13.hijridatepicker</groupId>
<artifactId>libary</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
</dependency>
```
**Gradle**
```gradle
dependencies {
compile 'net.alhazmy13.hijridatepicker:libary:1.3.1'
compile 'net.alhazmy13.hijridatepicker:libary:1.3.2'
}
```

Expand Down
3 changes: 0 additions & 3 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
Expand All @@ -87,7 +85,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
2 changes: 1 addition & 1 deletion libary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
19 changes: 8 additions & 11 deletions libary/libary.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":libary" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="net.alhazmy13.hijridatepicker" external.system.module.version="1.3.1" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":libary" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="net.alhazmy13.hijridatepicker" external.system.module.version="1.3.2" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -62,21 +62,20 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
Expand All @@ -93,9 +92,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
Expand Down
32 changes: 0 additions & 32 deletions libary/src/main/java/net/alhazmy13/hijridatepicker/EnumConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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("");
Expand Down Expand Up @@ -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();
Expand All @@ -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() + "");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 66a9f56

Please sign in to comment.