Skip to content

Commit ea5c050

Browse files
Merge pull request #31 from MATDEV-Technologies/working
Bugfix for update 1.1 MERGED
2 parents d5e06c8 + 0a034fa commit ea5c050

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

app/build.gradle

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 30
5-
//noinspection GradleDependency
6-
buildToolsVersion "30.0.0"
5+
buildToolsVersion "30.0.1"
76

87
defaultConfig {
98
applicationId "com.matdevtech.multility"
109
minSdkVersion 29
1110
targetSdkVersion 30
12-
versionCode 1
13-
versionName "1.0"
11+
versionCode 2
12+
versionName "1.1"
1413

1514
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1615
}
@@ -31,32 +30,27 @@ dependencies {
3130
implementation 'androidx.cardview:cardview:1.0.0'
3231
//noinspection GradleDependency
3332
implementation 'com.ismaeldivita.chipnavigation:chip-navigation-bar:1.2.0'
34-
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.72'
33+
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.4.0'
3534
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
3635
implementation 'androidx.gridlayout:gridlayout:1.0.0'
3736
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
3837
testImplementation 'junit:junit:4.13'
3938
implementation 'org.apache.commons:commons-lang3:3.11'
4039
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
4140
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
42-
43-
4441
implementation 'androidx.recyclerview:recyclerview:1.1.0'
45-
4642
//Image
4743
//noinspection GradleDependency
4844
implementation 'com.github.bumptech.glide:glide:4.7.1'
4945
//noinspection GradleDependency
5046
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
51-
5247
//Network
5348
//noinspection GradleDependency
5449
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
5550
//noinspection GradleDependency
5651
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
5752
//noinspection GradleDependency
5853
implementation 'com.google.code.gson:gson:2.8.6'
59-
6054
//Times Formatter
6155
implementation 'org.ocpsoft.prettytime:prettytime:4.0.5.Final'
6256
}

app/src/main/java/com/matdevtech/multility/TipCalculator.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import android.widget.Button;
1212
import android.widget.EditText;
1313
import android.widget.TextView;
14+
import android.widget.Toast;
15+
1416
import androidx.annotation.Nullable;
1517
import androidx.fragment.app.Fragment;
1618
import java.util.Objects;
@@ -100,14 +102,22 @@ public void onClick(View view) {
100102
percentage_tip.setText("");
101103
}
102104

103-
float total_price_int = Float.parseFloat(total_price.getText().toString());
104-
float percentage_tip_int = Float.parseFloat(percentage_tip.getText().toString());
105+
float total_price_int;
106+
float percentage_tip_int;
107+
float calculated_tip;
108+
double rounded_tip;
109+
110+
try{
111+
total_price_int = Float.parseFloat(total_price.getText().toString());
112+
percentage_tip_int = Float.parseFloat(percentage_tip.getText().toString());
105113

106-
float calculated_tip = (total_price_int * (percentage_tip_int / 100));
107-
double rounded_tip = Math.round(calculated_tip * 100.0) / 100.0;
114+
calculated_tip = (total_price_int * (percentage_tip_int / 100));
115+
rounded_tip = Math.round(calculated_tip * 100.0) / 100.0;
108116

109-
// String formatting for displaying a trailing zero if there is only a value in the tenths
110-
tip_result.setText("TIP: $" + String.format("%.2f", rounded_tip));
117+
tip_result.setText("TIP: $" + String.format("%.2f", rounded_tip));
118+
}catch(Exception e){
119+
Toast.makeText(getActivity(), "Enter Price/Percentage Info!", Toast.LENGTH_SHORT).show();
120+
}
111121
}
112122
});
113123
}

0 commit comments

Comments
 (0)