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

Commit 27313ba

Browse files
author
dubovska.alla
committed
#53[30m]. Fix precision issue.
1 parent 6b07e9f commit 27313ba

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/record/AddRecordActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected void initViews() {
106106
if (mode == Mode.MODE_EDIT) {
107107
etTitle.setText(record.getTitle());
108108
if (record.getCategory() != null) etCategory.setText(record.getCategory().getName());
109-
etPrice.setText(Integer.toString(record.getPrice()));
109+
etPrice.setText(Integer.toString((int) record.getPrice()));
110110
}
111111

112112
presentSpinnerAccount();

app/src/main/java/com/blogspot/e_kanivets/moneytracker/adapter/RecordAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @author Evgenii Kanivets
2626
*/
27-
public class RecordAdapter extends BaseAdapter{
27+
public class RecordAdapter extends BaseAdapter {
2828
private Context context;
2929
private List<Record> records;
3030

@@ -83,7 +83,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {
8383
viewHolder.tvDateAndTime.setText(dateFormat.format(new Date(record.getTime())));
8484

8585
viewHolder.tvPrice.setText((record.isIncome() ? "+ " : "- ")
86-
+ Integer.toString(record.getPrice()));
86+
+ Integer.toString((int) record.getPrice()));
8787
viewHolder.tvTitle.setText(record.getTitle());
8888
viewHolder.tvCategory.setText(record.getCategory().getName());
8989
viewHolder.tvCurrency.setText(record.getCurrency());

app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/AccountController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public boolean recordAdded(@Nullable Record record) {
3333

3434
switch (record.getType()) {
3535
case Record.TYPE_EXPENSE:
36-
account.take(record.getPrice());
36+
account.take((int) record.getPrice());
3737
break;
3838

3939
case Record.TYPE_INCOME:
40-
account.put(record.getPrice());
40+
account.put((int) record.getPrice());
4141
break;
4242

4343
default:
@@ -57,11 +57,11 @@ public boolean recordDeleted(@Nullable Record record) {
5757

5858
switch (record.getType()) {
5959
case Record.TYPE_EXPENSE:
60-
account.put(record.getPrice());
60+
account.put((int) record.getPrice());
6161
break;
6262

6363
case Record.TYPE_INCOME:
64-
account.take(record.getPrice());
64+
account.take((int) record.getPrice());
6565
break;
6666

6767
default:

app/src/main/java/com/blogspot/e_kanivets/moneytracker/entity/Record.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public class Record extends BaseEntity implements Parcelable {
1919
private final int type;
2020
private final String title;
2121
private final Category category;
22-
private final int price;
22+
private final double price;
2323
private final Account account;
2424
private final String currency;
2525

26-
public Record(long id, long time, int type, String title, long categoryId, int price, long accountId, String currency) {
26+
public Record(long id, long time, int type, String title, long categoryId, double price, long accountId, String currency) {
2727
this.id = id;
2828
this.time = time;
2929
this.type = type;
@@ -34,7 +34,7 @@ public Record(long id, long time, int type, String title, long categoryId, int p
3434
this.currency = currency;
3535
}
3636

37-
public Record(long id, long time, int type, String title, Category category, int price, Account account, String currency) {
37+
public Record(long id, long time, int type, String title, Category category, double price, Account account, String currency) {
3838
this.id = id;
3939
this.time = time;
4040
this.type = type;
@@ -45,7 +45,7 @@ public Record(long id, long time, int type, String title, Category category, int
4545
this.currency = currency;
4646
}
4747

48-
public Record(long time, int type, String title, Category category, int price, Account account, String currency) {
48+
public Record(long time, int type, String title, Category category, double price, Account account, String currency) {
4949
this.id = -1;
5050
this.time = time;
5151
this.type = type;
@@ -62,7 +62,7 @@ protected Record(Parcel in) {
6262
type = in.readInt();
6363
title = in.readString();
6464
category = in.readParcelable(Category.class.getClassLoader());
65-
price = in.readInt();
65+
price = in.readDouble();
6666
account = in.readParcelable(Account.class.getClassLoader());
6767
currency = in.readString();
6868
}
@@ -97,7 +97,7 @@ public Category getCategory() {
9797
return category;
9898
}
9999

100-
public int getPrice() {
100+
public double getPrice() {
101101
return price;
102102
}
103103

@@ -179,7 +179,7 @@ public void writeToParcel(Parcel dest, int flags) {
179179
dest.writeInt(type);
180180
dest.writeString(title);
181181
dest.writeParcelable(category, 0);
182-
dest.writeInt(price);
182+
dest.writeDouble(price);
183183
dest.writeParcelable(account, 0);
184184
dest.writeString(currency);
185185
}

app/src/main/java/com/blogspot/e_kanivets/moneytracker/report/Report.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private List<Record> convertRecordList(List<Record> recordList) {
128128
List<Record> convertedRecordList = new ArrayList<>();
129129

130130
for (Record record : recordList) {
131-
int convertedPrice = record.getPrice();
131+
double convertedPrice = record.getPrice();
132132

133133
if (!currency.equals(record.getCurrency())) {
134134
ExchangeRate exchangeRate = rateProvider.getRate(record);

0 commit comments

Comments
 (0)