mardi 15 septembre 2015

Filtered all checked checkboxes

Im having a problem on how to filter all of my checked checkboxes. The output that I want is when I choose "Pool" and filter it, the result is all the schools that has a Pool inside its Facilities will only show. The problem is when I choose "Pool", even the school that dont have a Pool in their facilities is also showing. Can someone help me? here's my code:

Calling the checkboxes and add its value

                List<String> rg5 = new ArrayList<>();
                rg5.add("*");



                if (chkFaci.isChecked()) {

                    if (chkToy.isChecked()) {

                        rg5.add("Toy Room");

                    } else if (!chkToy.isChecked()) {
                        rg5.removeAll(Collections.singleton(null));
                    }
                    if (chkVisual.isChecked()) {

                        rg5.add("Visual Room");
                    } else if (!chkVisual.isChecked()) {
                        rg5.removeAll(Collections.singleton(null));
                    }
                    if (chkParent.isChecked()) {

                        rg5.add("Parent's Lounge");
                    } else if (!chkParent.isChecked()) {
                        rg5.removeAll(Collections.singleton(null));
                    }
                    if (chkPlay.isChecked()) {

                        rg5.add("Playground");
                    } else if (!chkPlay.isChecked()) {
                        rg5.removeAll(Collections.singleton(null));
                    }
                    if (chkCanteen.isChecked()) {

                        rg5.add("Canteen");
                    } else if (!chkCanteen.isChecked()) {
                        rg5.removeAll(Collections.singleton(null));
                    }
                    if (chkPool.isChecked()) {

                        rg5.add("Pool");
                    } else if (!chkPool.isChecked()) {
                        rg5.removeAll(Collections.singleton(null));
                    }

                }

                theFilter[6] = rg5;

Here's the filtering method:

        // ALL filter selected
        if (theTuitionFee >= amountTF && theTuitionFee <= amountTF2
                && sType[loop].equalsIgnoreCase((String) thisFilter[0])
                && filtermatch
                && sClassi[loop].equalsIgnoreCase((String) thisFilter[4])
                && filtermatch2 
                && filteredAll(sFac[loop][subloop], (List<String>)thisFilter[6])) {
            list.add(sName[loop]);

The filteredAll method:

private boolean filteredAll(String val, List<String> values) {
      boolean b = false;
      for(String s:values) {
        b |= s.equalsIgnoreCase(val);
      }
      return b;// true if one is equal
    }




Aucun commentaire:

Enregistrer un commentaire