mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 18:48:48 +00:00
Can now display the grand total of items in shopping list
This commit is contained in:
parent
a3e72d3699
commit
0562c66dbb
@ -53,6 +53,13 @@ public class ListPage extends AppCompatActivity {
|
|||||||
// Read list ID from caller
|
// Read list ID from caller
|
||||||
final int listID = (int) getIntent().getSerializableExtra("listID");
|
final int listID = (int) getIntent().getSerializableExtra("listID");
|
||||||
|
|
||||||
|
pNames.add("Total Price");
|
||||||
|
pStores.add("");
|
||||||
|
pPrices.add("0.00");
|
||||||
|
pQuantity.add("-1");
|
||||||
|
pImages.add("-1");
|
||||||
|
pListItemPair.add(null);
|
||||||
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||||
@ -89,6 +96,9 @@ public class ListPage extends AppCompatActivity {
|
|||||||
totalPriceByStore.put("Kroger", item.getPrice().doubleValue() * entry.getQuantity());
|
totalPriceByStore.put("Kroger", item.getPrice().doubleValue() * entry.getQuantity());
|
||||||
storeHeaderIndex.put("Kroger", pNames.size());
|
storeHeaderIndex.put("Kroger", pNames.size());
|
||||||
|
|
||||||
|
double newTotal = Double.parseDouble(pPrices.get(0)) + (item.getPrice().doubleValue() * entry.getQuantity());
|
||||||
|
pPrices.set(0, String.valueOf(newTotal));
|
||||||
|
|
||||||
pNames.add("Kroger");
|
pNames.add("Kroger");
|
||||||
pStores.add("");
|
pStores.add("");
|
||||||
pPrices.add(totalPriceByStore.get("Kroger").toString());
|
pPrices.add(totalPriceByStore.get("Kroger").toString());
|
||||||
@ -109,6 +119,9 @@ public class ListPage extends AppCompatActivity {
|
|||||||
totalPriceByStore.put("Kroger", totalPriceByStore.get("Kroger") + (item.getPrice().doubleValue() * entry.getQuantity()));
|
totalPriceByStore.put("Kroger", totalPriceByStore.get("Kroger") + (item.getPrice().doubleValue() * entry.getQuantity()));
|
||||||
pPrices.set(index, totalPriceByStore.get("Kroger").toString());
|
pPrices.set(index, totalPriceByStore.get("Kroger").toString());
|
||||||
|
|
||||||
|
double newTotal = Double.parseDouble(pPrices.get(0)) + (item.getPrice().doubleValue() * entry.getQuantity());
|
||||||
|
pPrices.set(0, String.valueOf(newTotal));
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
pNames.add(index, item.getDescription());
|
pNames.add(index, item.getDescription());
|
||||||
@ -172,6 +185,8 @@ public class ListPage extends AppCompatActivity {
|
|||||||
pQuantity.set(position, Integer.toString(q));
|
pQuantity.set(position, Integer.toString(q));
|
||||||
totalPriceByStore.put(pStores.get(position), totalPriceByStore.get(pStores.get(position)) - Double.parseDouble(pPrices.get(position)));
|
totalPriceByStore.put(pStores.get(position), totalPriceByStore.get(pStores.get(position)) - Double.parseDouble(pPrices.get(position)));
|
||||||
pPrices.set(storeHeaderIndex.get(pStores.get(position)), totalPriceByStore.get(pStores.get(position)).toString());
|
pPrices.set(storeHeaderIndex.get(pStores.get(position)), totalPriceByStore.get(pStores.get(position)).toString());
|
||||||
|
double newTotal = Double.parseDouble(pPrices.get(0)) - Double.parseDouble(pPrices.get(position));
|
||||||
|
pPrices.set(0, String.valueOf(newTotal));
|
||||||
ListEntry le = pListItemPair.remove(position);
|
ListEntry le = pListItemPair.remove(position);
|
||||||
le.setQuantity(le.getQuantity() - 1);
|
le.setQuantity(le.getQuantity() - 1);
|
||||||
pListItemPair.add(position, le);
|
pListItemPair.add(position, le);
|
||||||
@ -203,6 +218,8 @@ public class ListPage extends AppCompatActivity {
|
|||||||
pQuantity.set(position, Integer.toString(q));
|
pQuantity.set(position, Integer.toString(q));
|
||||||
totalPriceByStore.put(pStores.get(position), totalPriceByStore.get(pStores.get(position)) + Double.parseDouble(pPrices.get(position)));
|
totalPriceByStore.put(pStores.get(position), totalPriceByStore.get(pStores.get(position)) + Double.parseDouble(pPrices.get(position)));
|
||||||
pPrices.set(storeHeaderIndex.get(pStores.get(position)), totalPriceByStore.get(pStores.get(position)).toString());
|
pPrices.set(storeHeaderIndex.get(pStores.get(position)), totalPriceByStore.get(pStores.get(position)).toString());
|
||||||
|
double newTotal = Double.parseDouble(pPrices.get(0)) + Double.parseDouble(pPrices.get(position));
|
||||||
|
pPrices.set(0, String.valueOf(newTotal));
|
||||||
ListEntry le = pListItemPair.remove(position);
|
ListEntry le = pListItemPair.remove(position);
|
||||||
le.setQuantity(le.getQuantity() + 1);
|
le.setQuantity(le.getQuantity() + 1);
|
||||||
pListItemPair.add(position, le);
|
pListItemPair.add(position, le);
|
||||||
@ -233,6 +250,9 @@ public class ListPage extends AppCompatActivity {
|
|||||||
totalPriceByStore.put("Kroger", totalPriceByStore.get("Kroger") - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position))));
|
totalPriceByStore.put("Kroger", totalPriceByStore.get("Kroger") - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position))));
|
||||||
pPrices.set(storeHeaderIndex.get(pStores.get(position)), totalPriceByStore.get(pStores.get(position)).toString());
|
pPrices.set(storeHeaderIndex.get(pStores.get(position)), totalPriceByStore.get(pStores.get(position)).toString());
|
||||||
|
|
||||||
|
double newTotal = Double.parseDouble(pPrices.get(0)) - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position)));
|
||||||
|
pPrices.set(0, String.valueOf(newTotal));
|
||||||
|
|
||||||
pNames.remove(position);
|
pNames.remove(position);
|
||||||
pStores.remove(position);
|
pStores.remove(position);
|
||||||
pPrices.remove(position);
|
pPrices.remove(position);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user