Commit fa3b6d1b authored by Varun Patil's avatar Varun Patil

Preserve Explore search results on going back

parent 7e2defa8
...@@ -84,6 +84,8 @@ public class ExploreFragment extends Fragment { ...@@ -84,6 +84,8 @@ public class ExploreFragment extends Fragment {
Toolbar toolbar = getActivity().findViewById(R.id.toolbar); Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Explore"); toolbar.setTitle("Explore");
final EditText searchEditText = getView().findViewById(R.id.explore_search);
// Get all bodies // Get all bodies
if (allBodies.size() == 0) { if (allBodies.size() == 0) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
...@@ -95,14 +97,16 @@ public class ExploreFragment extends Fragment { ...@@ -95,14 +97,16 @@ public class ExploreFragment extends Fragment {
updateAdapter(allBodies, new ArrayList<Event>(), new ArrayList<User>()); updateAdapter(allBodies, new ArrayList<Event>(), new ArrayList<User>());
} }
}); });
} else {
// Check if search box is not empty
if (searchEditText.getText() != null && !searchEditText.getText().toString().equals("")) {
updateAdapter(bodies, events, users);
} else { } else {
updateAdapter(allBodies, new ArrayList<Event>(), new ArrayList<User>()); updateAdapter(allBodies, new ArrayList<Event>(), new ArrayList<User>());
}
getView().findViewById(R.id.loadingPanel).setVisibility(View.GONE); getView().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
} }
// Search on text change in search
final EditText searchEditText = getView().findViewById(R.id.explore_search);
// Close keyboard on search click // Close keyboard on search click
searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override @Override
...@@ -115,6 +119,7 @@ public class ExploreFragment extends Fragment { ...@@ -115,6 +119,7 @@ public class ExploreFragment extends Fragment {
} }
}); });
// Search on text change in search
searchEditText.addTextChangedListener(new TextWatcher() { searchEditText.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment