private void createBinTypeList(List<BinType> binTypeEntities) { if (binTypeEntities != null && binTypeEntities.size() > 0) { for (BinType binTypeEntity : binTypeEntities) { LocalEntity binType = new LocalEntity(binTypeEntity.getName()); if (binTypeEntity.getSearchTerms() != null) { binType.setSearchTerms((ArrayList<String>) binTypeEntity.getSearchTerms()); } mBinTypes.add(binType); Log.d(TAG, binType.getName()); } } }
private void createBrandList(List<Brand> brandEntities) { if (brandEntities != null && brandEntities.size() > 0) { for (Brand brandEntity : brandEntities) { LocalEntity brand = new LocalEntity(brandEntity.getName()); if (brandEntity.getSearchTerms() != null) { brand.setSearchTerms((ArrayList<String>) brandEntity.getSearchTerms()); } mBrands.add(brand); Log.d(TAG, brand.getName()); } } }
private void createLitterTypeList(List<LitterType> litterTypeEntities) { if (litterTypeEntities != null && litterTypeEntities.size() > 0) { for (LitterType litterTypeEntity : litterTypeEntities) { LocalEntity litterType = new LocalEntity(litterTypeEntity.getName()); if (litterTypeEntity.getSearchTerms() != null) { litterType.setSearchTerms((ArrayList<String>) litterTypeEntity.getSearchTerms()); } mLitterTypes.add(litterType); Log.d(TAG, litterType.getName()); } } }
// Deal with unexpected results private String processUnexpectedResult(String result) { String toastText = ""; // Cancel item and start again if needed if (result.equals("cancel") || result.equals("council") || result.equals("Council") || result.equals("cancer") || result.equals("pencil")) { mOutingManager.speak("item cancelled"); setCurrentSearch(brandSearch, result); mBin = null; mLitter = null; return null; } for (LocalEntity menuItem : menuSearch.getSearchObjects()) { if (menuItem.getSearchTerms().contains(result)) { setCurrentSearchByString(menuItem.getName()); return null; } } if (!Search.getCurrentSearch().getName().equals("menu")) { toastText = "I haven't heard of " + result + ". Should I log it as other?"; // log current item as 'other' and record the result yesNoSearch.setActive(true); yesNoSearch.setResponse(toastText); yesNoSearch.setPotentialOtherField(result); if (Search.getCurrentSearch().equals(brandSearch)) { mActionHandler.getCurrentAction().setActionType(Action.Type.LOG_OTHER_BRAND); } if (Search.getCurrentSearch().equals(typeSearch)) { mActionHandler.getCurrentAction().setActionType(Action.Type.LOG_OTHER_LITTER_TYPE); } if (Search.getCurrentSearch().equals(binSearch)) { mActionHandler.getCurrentAction().setActionType(Action.Type.LOG_OTHER_BIN_TYPE); } Log.d(TAG, "result at other: " + result); Log.d(TAG, "yesnosearch potentialotherfield set to " + yesNoSearch.getPotentialOtherField()); Log.d(TAG, "currentSearch at unexpected result = " + Search.getCurrentSearch().getName()); setCurrentSearch(yesNoSearch, ""); return toastText; } else { setCurrentSearch(brandSearch, result); return null; } }