mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Can now clear shopping list (i.e. remove all items)
This commit is contained in:
parent
0562c66dbb
commit
049d95bb91
@ -247,19 +247,41 @@ public class ListPage extends AppCompatActivity {
|
|||||||
removeItem.setOnClickListener(new View.OnClickListener() {
|
removeItem.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
totalPriceByStore.put("Kroger", totalPriceByStore.get("Kroger") - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position))));
|
if(position == 0) {
|
||||||
pPrices.set(storeHeaderIndex.get(pStores.get(position)), totalPriceByStore.get(pStores.get(position)).toString());
|
pNames.clear();
|
||||||
|
pStores.clear();
|
||||||
|
pPrices.clear();
|
||||||
|
pQuantity.clear();
|
||||||
|
pImages.clear();
|
||||||
|
|
||||||
double newTotal = Double.parseDouble(pPrices.get(0)) - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position)));
|
pNames.add("Total Price");
|
||||||
pPrices.set(0, String.valueOf(newTotal));
|
pStores.add("");
|
||||||
|
pPrices.add("0.00");
|
||||||
|
pQuantity.add("-1");
|
||||||
|
pImages.add("-1");
|
||||||
|
|
||||||
pNames.remove(position);
|
while(pListItemPair.size() > 1) {
|
||||||
pStores.remove(position);
|
try {
|
||||||
pPrices.remove(position);
|
requestor.deleteObject(pListItemPair.remove(1));
|
||||||
pQuantity.remove(position);
|
}
|
||||||
pImages.remove(position);
|
catch(Exception e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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());
|
||||||
|
|
||||||
requestor.deleteObject(pListItemPair.remove(position));
|
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);
|
||||||
|
pStores.remove(position);
|
||||||
|
pPrices.remove(position);
|
||||||
|
pQuantity.remove(position);
|
||||||
|
pImages.remove(position);
|
||||||
|
|
||||||
|
requestor.deleteObject(pListItemPair.remove(position));
|
||||||
|
}
|
||||||
|
|
||||||
listView.setAdapter(myAdapter);
|
listView.setAdapter(myAdapter);
|
||||||
}
|
}
|
||||||
@ -280,7 +302,13 @@ public class ListPage extends AppCompatActivity {
|
|||||||
quantity.setVisibility(View.INVISIBLE);
|
quantity.setVisibility(View.INVISIBLE);
|
||||||
decrQuan.setVisibility(View.INVISIBLE);
|
decrQuan.setVisibility(View.INVISIBLE);
|
||||||
incrQuan.setVisibility(View.INVISIBLE);
|
incrQuan.setVisibility(View.INVISIBLE);
|
||||||
removeItem.setVisibility(View.INVISIBLE);
|
|
||||||
|
if(position == 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
removeItem.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
quantity.setText(pQuantity.get(position));
|
quantity.setText(pQuantity.get(position));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user