Restrict quantities when adding item to a list

This commit is contained in:
Clayton Wilson 2020-11-14 22:51:02 -05:00
parent 757ac20fe6
commit 0934965306
3 changed files with 13 additions and 2 deletions

View File

@ -90,8 +90,13 @@ public class ListPickerDialogFragment extends DialogFragment {
btnMinus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Set to 1 if it is empty
if (etQuantity.getText().toString().equals("")) {
etQuantity.setText("1");
}
int curQauntity = Integer.parseInt(etQuantity.getText().toString());
if (curQauntity > 0) {
if (curQauntity > 1) {
curQauntity--;
etQuantity.setText(String.format("%d", curQauntity));
}
@ -102,6 +107,11 @@ public class ListPickerDialogFragment extends DialogFragment {
btnPlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Set to 1 if it is empty
if (etQuantity.getText().toString().equals("")) {
etQuantity.setText("1");
}
int curQauntity = Integer.parseInt(etQuantity.getText().toString());
curQauntity++;
etQuantity.setText(String.format("%d", curQauntity));

View File

@ -56,7 +56,7 @@ public class SearchResultsListAdapter extends BaseAdapter {
TextView itemStore = (TextView) convertView.findViewById(R.id.item_store);
Product product = productList.get(position);
// TODO: If image url is broken, display @drawable/ic_baseline_broken_image_600.xml
Glide.with(activity)
.applyDefaultRequestOptions(new RequestOptions().placeholder(R.drawable.ic_baseline_image_600).error(R.drawable.ic_baseline_broken_image_600))
.load(product.getImageUrl())

View File

@ -38,6 +38,7 @@
android:layout_width="60dp"
android:layout_height="50dp"
android:text="@string/_1"
android:digits="0123456789"
android:inputType="number"/>
<Button