Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 16b0251

Browse files
author
Evgenii
authored
Merge pull request #120 from evgenii-kanivets/dev
Fix NFE. Update Gradle version.
2 parents 5aac364 + 250be02 commit 16b0251

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId 'com.blogspot.e_kanivets.moneytracker'
99
minSdkVersion 17
1010
targetSdkVersion 23
11-
versionCode 15
12-
versionName '1.7.8'
11+
versionCode 16
12+
versionName '1.7.9'
1313
}
1414
signingConfigs {
1515
releaseConfig {
@@ -64,4 +64,4 @@ dependencies {
6464
androidTestCompile 'com.crittercism.dexmaker:dexmaker:1.4'
6565
androidTestCompile 'com.crittercism.dexmaker:dexmaker-dx:1.4'
6666
androidTestCompile 'com.crittercism.dexmaker:dexmaker-mockito:1.4'
67-
}
67+
}

app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/account/AddAccountActivity.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,31 @@ public boolean onCreateOptionsMenu(Menu menu) {
6565
public boolean onOptionsItemSelected(MenuItem item) {
6666
switch (item.getItemId()) {
6767
case R.id.action_done:
68-
addAccount();
69-
70-
setResult(RESULT_OK);
71-
finish();
68+
if (addAccount()) {
69+
setResult(RESULT_OK);
70+
finish();
71+
} else showToast(R.string.wrong_number_text);
7272
return true;
7373

7474
default:
7575
return super.onOptionsItemSelected(item);
7676
}
7777
}
7878

79-
private void addAccount() {
79+
private boolean addAccount() {
8080
String title = etTitle.getText().toString().trim();
81-
double initSum = Double.parseDouble(etInitSum.getText().toString().trim());
81+
82+
double initSum;
83+
try {
84+
initSum = Double.parseDouble(etInitSum.getText().toString().trim());
85+
} catch (NumberFormatException e) {
86+
e.printStackTrace();
87+
return false;
88+
}
89+
8290
String currency = (String) spinner.getSelectedItem();
8391

8492
Account account = new Account(title, initSum, currency);
85-
accountController.create(account);
93+
return accountController.create(account) != null;
8694
}
87-
}
95+
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
jcenter()
44
}
55
dependencies {
6-
classpath 'com.android.tools.build:gradle:2.1.2'
6+
classpath 'com.android.tools.build:gradle:2.1.3'
77
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
88
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.2'
99
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Apr 19 13:31:21 GMT+02:00 2016
1+
#Wed Aug 24 14:58:14 GMT+02:00 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

0 commit comments

Comments
 (0)