mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Fix total price being incorrect
This commit is contained in:
parent
1f2ea26efe
commit
d9ea934021
@ -47,7 +47,6 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
|
|
||||||
ArrayList<ListEntry> pListItemPair = new ArrayList<>();
|
ArrayList<ListEntry> pListItemPair = new ArrayList<>();
|
||||||
|
|
||||||
Requestor requestor;
|
|
||||||
double totalPrice = 0;
|
double totalPrice = 0;
|
||||||
|
|
||||||
Map<String, Double> totalPriceByStore = new HashMap<>();
|
Map<String, Double> totalPriceByStore = new HashMap<>();
|
||||||
@ -164,23 +163,27 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
pImages.add(index, item.getImageURL());
|
pImages.add(index, item.getImageURL());
|
||||||
pListItemPair.add(index, entry);
|
pListItemPair.add(index, entry);
|
||||||
|
|
||||||
// Increment total price
|
|
||||||
totalPrice += (item.getPrice().doubleValue() * entry.getQuantity());
|
|
||||||
|
|
||||||
for(String store : storeHeaderIndex.keySet()) {
|
for(String store : storeHeaderIndex.keySet()) {
|
||||||
if(storeHeaderIndex.get(store) > index) {
|
if(storeHeaderIndex.get(store) > index) {
|
||||||
storeHeaderIndex.put(store, storeHeaderIndex.get(store) + 1);
|
storeHeaderIndex.put(store, storeHeaderIndex.get(store) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Increment total price
|
||||||
|
System.out.println(totalPrice);
|
||||||
|
System.out.println(item.getPrice().doubleValue());
|
||||||
|
System.out.println(entry.getQuantity());
|
||||||
|
totalPrice += (item.getPrice().doubleValue() * entry.getQuantity());
|
||||||
|
System.out.println(totalPrice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tvTotalPrice = (TextView) findViewById(R.id.total_price);
|
tvTotalPrice = (TextView) findViewById(R.id.total_price);
|
||||||
tvTotalPrice.setText(String.format("$%.2f", totalPrice));
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
tvTotalPrice.setText(String.format("$%.2f", totalPrice));
|
||||||
loadingListItems.setVisibility(View.GONE);
|
loadingListItems.setVisibility(View.GONE);
|
||||||
myAdapter.notifyDataSetChanged();
|
myAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user