Skip to content

Commit

Permalink
Merge pull request #577 from opensrp/567-numericdatepicker-bug-fix
Browse files Browse the repository at this point in the history
Fix NumericDatePicker Crash When Out-of-range Date is Selected
  • Loading branch information
qiarie authored May 13, 2021
2 parents bb846c0 + 3e5a441 commit 1231902
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
9 changes: 7 additions & 2 deletions android-json-form-wizard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'org.apache.commons:commons-lang3:3.7'
}
}
Expand Down Expand Up @@ -61,6 +61,10 @@ android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}

configurations.all {
resolutionStrategy.force 'com.android.support:design:28.0.0'
}
}


Expand All @@ -74,9 +78,10 @@ repositories {
}

dependencies {
api('org.smartregister:opensrp-client-simprints:1.0.3-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-simprints:1.0.6-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'design'
}
implementation 'com.github.bmelnychuk:atv:1.2.9'
implementation('com.android.support:design:28.0.0') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ protected void resetDatePicker() {

switch (violation) {
case MALFORMED_DATE:
// Only Day can malform since different months have different days in the Gregorian calendar
resetPicker(dayPicker, previousDay > 0 ? previousDay : minDay);
resetPicker(dayPicker, getPreviousDay(previousDay, minDay));

break;

Expand Down Expand Up @@ -588,7 +587,6 @@ private void resetPicker(NumberPicker numberPicker, int value) {
numberPicker.setDisplayedValues(null);

//set new value

if (value != 0)
numberPicker.setValue(value);

Expand Down Expand Up @@ -656,4 +654,12 @@ private boolean isMaxDayEdge() {
private int getMaxDayForSelectedDate() {
return NumericDatePickerHelper.getDaysInMonth(getMonth(), NumericDatePickerHelper.isLeapYear(getYear()));
}

private int getPreviousDay(int prevDay, int minDay) {
if (prevDay > 0) {
return getMonth() + 1 == 2 ? Math.min(prevDay, (NumericDatePickerHelper.isLeapYear(getYear()) ? 29 : 28)) : prevDay;
} else {
return minDay;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public static long getDurationTimeDifference(String date, String endDate) {
}

public static String getDuration(long timeDiff, Locale locale, Context context) {


String duration = "";
if (timeDiff >= 0
&& timeDiff <= TimeUnit.MILLISECONDS.convert(13, TimeUnit.DAYS)) {
Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ subprojects {
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "http://nexus.motechproject.org/content/repositories/drishti" }
maven { url "http://nexus.motechproject.org/content/repositories/snapshots" }
maven { url "http://acra.googlecode.com/svn/repository/releases" }
maven { url "https://repo.maven.apache.org/maven2" }
maven { url "http://cloudant.github.io/cloudant-sync-eap/repository" }
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.0.10-SNAPSHOT
VERSION_NAME=2.0.11-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard
Expand Down

0 comments on commit 1231902

Please sign in to comment.