From 9edab80c2f52909d46392e3ecb6d460242b79c6d Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Thu, 5 Nov 2020 00:01:20 -0500 Subject: [PATCH] Store-filtering-related bugs fixed --- .../com/example/listify/SearchResults.java | 1 + .../adapter/CheckBoxListViewAdapter.java | 21 ++++++++++++++----- .../app/src/main/res/layout/dialog_sort.xml | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Listify/app/src/main/java/com/example/listify/SearchResults.java b/Listify/app/src/main/java/com/example/listify/SearchResults.java index 12deb42..06ff3f3 100644 --- a/Listify/app/src/main/java/com/example/listify/SearchResults.java +++ b/Listify/app/src/main/java/com/example/listify/SearchResults.java @@ -352,6 +352,7 @@ public class SearchResults extends AppCompatActivity implements FilterDialogFrag } // Create a list of all stores in the results so the user can filter by store name + stores.clear(); for (int i = 0; i < resultsProductList.size(); i++) { if (!stores.contains(resultsProductList.get(i).getChainName())) { stores.add(resultsProductList.get(i).getChainName()); diff --git a/Listify/app/src/main/java/com/example/listify/adapter/CheckBoxListViewAdapter.java b/Listify/app/src/main/java/com/example/listify/adapter/CheckBoxListViewAdapter.java index 5951d79..df7ea8f 100644 --- a/Listify/app/src/main/java/com/example/listify/adapter/CheckBoxListViewAdapter.java +++ b/Listify/app/src/main/java/com/example/listify/adapter/CheckBoxListViewAdapter.java @@ -55,19 +55,30 @@ public class CheckBoxListViewAdapter extends BaseAdapter { holder = new ViewHolder(); holder.label = (TextView) convertView.findViewById(R.id.store_name); holder.checkBox = (CheckBox)convertView.findViewById(R.id.store_check_box); - - holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + holder.checkBox.setOnClickListener(new View.OnClickListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - int getPosition = (Integer) buttonView.getTag(); + public void onClick(View v) { + int getPosition = (Integer) ((CompoundButton)(v)).getTag(); - if (isChecked) { + if (((CompoundButton) v).isChecked()) { checkedList.add(list.get(getPosition)); } else { checkedList.remove(list.get(getPosition)); } } }); +// holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { +// @Override +// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { +// int getPosition = (Integer) buttonView.getTag(); +// +// if (isChecked) { +// checkedList.add(list.get(getPosition)); +// } else { +// checkedList.remove(list.get(getPosition)); +// } +// } +// }); convertView.setOnClickListener(new View.OnClickListener() { @Override diff --git a/Listify/app/src/main/res/layout/dialog_sort.xml b/Listify/app/src/main/res/layout/dialog_sort.xml index af88f7d..d01f288 100644 --- a/Listify/app/src/main/res/layout/dialog_sort.xml +++ b/Listify/app/src/main/res/layout/dialog_sort.xml @@ -90,7 +90,7 @@