Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit 1745889

Browse files
committed
Fixed crash on Device with Local fa
1 parent 2d00008 commit 1745889

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/src/main/java/com/shalchian/sarrafi/activity/CalculatorActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
import java.text.NumberFormat;
5656
import java.util.ArrayList;
57+
import java.util.Locale;
5758

5859
import io.github.inflationx.calligraphy3.CalligraphyConfig;
5960
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
@@ -231,10 +232,10 @@ public void onError(ANError error) {
231232
}
232233

233234
private void calculate() {
234-
if (editTextFirst.length() !=0 ) {
235+
if (editTextFirst.length() !=0 && editTextFirst.getText() != null) {
235236
Double value = (Double.parseDouble(editTextFirst.getText().toString()) * firstValue) / secondValue;
236237

237-
NumberFormat numberFormat = NumberFormat.getInstance();
238+
NumberFormat numberFormat = NumberFormat.getInstance(new Locale("en","US"));
238239
numberFormat.setGroupingUsed(false);
239240
editTextSecond.setText(JSONParser.addComma(numberFormat.format(value)));
240241
}

app/src/main/java/com/shalchian/sarrafi/utils/JSONParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.text.NumberFormat;
3737
import java.util.ArrayList;
3838
import java.util.List;
39+
import java.util.Locale;
3940

4041
public class JSONParser {
4142
public static ArrayList<PriceModel> priceList(JSONObject response, String checkedFilter, Context context) throws JSONException {
@@ -366,7 +367,7 @@ public static String changeToToman(String price, boolean commaNeeded) {
366367
price = price.replace(",", "");
367368
double priceValue = Double.parseDouble(price) / 10;
368369

369-
NumberFormat numberFormat = NumberFormat.getInstance();
370+
NumberFormat numberFormat = NumberFormat.getInstance(new Locale("en","US"));
370371
numberFormat.setGroupingUsed(false);
371372
price = numberFormat.format(priceValue);
372373

0 commit comments

Comments
 (0)