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,6 +247,27 @@ public class ListPage extends AppCompatActivity {
|
||||
removeItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(position == 0) {
|
||||
pNames.clear();
|
||||
pStores.clear();
|
||||
pPrices.clear();
|
||||
pQuantity.clear();
|
||||
pImages.clear();
|
||||
|
||||
pNames.add("Total Price");
|
||||
pStores.add("");
|
||||
pPrices.add("0.00");
|
||||
pQuantity.add("-1");
|
||||
pImages.add("-1");
|
||||
|
||||
while(pListItemPair.size() > 1) {
|
||||
try {
|
||||
requestor.deleteObject(pListItemPair.remove(1));
|
||||
}
|
||||
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());
|
||||
|
||||
@ -260,6 +281,7 @@ public class ListPage extends AppCompatActivity {
|
||||
pImages.remove(position);
|
||||
|
||||
requestor.deleteObject(pListItemPair.remove(position));
|
||||
}
|
||||
|
||||
listView.setAdapter(myAdapter);
|
||||
}
|
||||
@ -280,8 +302,14 @@ public class ListPage extends AppCompatActivity {
|
||||
quantity.setVisibility(View.INVISIBLE);
|
||||
decrQuan.setVisibility(View.INVISIBLE);
|
||||
incrQuan.setVisibility(View.INVISIBLE);
|
||||
|
||||
if(position == 0) {
|
||||
|
||||
}
|
||||
else {
|
||||
removeItem.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
quantity.setText(pQuantity.get(position));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user