If (searchView != null) {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.d(TAG, "search changed to: " + newText.toString());
Query query;
if (newText.toString().isEmpty()) {
query = db.collection("milk");
} else {
String newText1 = newText.substring(0,1).toUpperCase();
newText=newText1+newText.substring(1);
Log.d("query",newText);
I am using if statements to pass on or check in other queries as well but these conditions aren't working as per log statements.
if (newText != "") {
query = db.collection("vegetables").whereEqualTo("productName", newText.toString());
FirestoreRecyclerOptions<horizontalProductModel> options = new FirestoreRecyclerOptions.Builder<horizontalProductModel>()
.setQuery(query, horizontalProductModel.class)
.build();
adapter.updateOptions(options);
Log.d("vg", String.valueOf(query.get()));
Log.d("vg", String.valueOf(options.getSnapshots().isEmpty()));
Log doesn't proceed as options is always not null but it returns a recyclier view so how can I check for other conditions.
if (options == null) {
query = db.collection("dailyNeeds").whereEqualTo("productName", newText.toString());
FirestoreRecyclerOptions<horizontalProductModel> options1 = new FirestoreRecyclerOptions.Builder<horizontalProductModel>()
.setQuery(query, horizontalProductModel.class)
.build();
adapter.updateOptions(options1);
Log.d("dN", String.valueOf(options));
if (options1 == null) {
query = db.collection("milk").whereEqualTo("productName", newText.toString());
FirestoreRecyclerOptions<horizontalProductModel> options2 = new FirestoreRecyclerOptions.Builder<horizontalProductModel>()
.setQuery(query, horizontalProductModel.class)
.build();
adapter.updateOptions(options2);
Log.d("mk", String.valueOf(options));
}
}
}
}
return false;
}
});
}
}
is there any other way other than this or merge two or more query results and pass it to Firebase UI.