summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-09-19 00:28:58 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-09-19 00:28:58 +0000
commit479382a2203d7e26b53e0d2e19f936ec6432d586 (patch)
tree0aacd85dd55bd03870f54e2f14911338f3883c1b /java
parentb615f7b460de730094af948e9827a9a1017ce1fd (diff)
parentdf06af5411002174c6aeb653ca7790f202284de6 (diff)
Merge "Now persist state through configuration changes in Search."
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/searchfragment/list/NewSearchFragment.java18
-rw-r--r--java/com/android/dialer/searchfragment/list/SearchAdapter.java7
2 files changed, 22 insertions, 3 deletions
diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
index 2527b87ee..036d53fb5 100644
--- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
+++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
@@ -80,6 +80,9 @@ public final class NewSearchFragment extends Fragment
private static final int REMOTE_DIRECTORIES_LOADER_ID = 2;
private static final int REMOTE_CONTACTS_LOADER_ID = 3;
+ private static final String KEY_QUERY = "key_query";
+ private static final String KEY_CALL_INITIATION_TYPE = "key_call_initiation_type";
+
private EmptyContentView emptyContentView;
private RecyclerView recyclerView;
private SearchAdapter adapter;
@@ -99,7 +102,7 @@ public final class NewSearchFragment extends Fragment
@Nullable
@Override
public View onCreateView(
- LayoutInflater inflater, @Nullable ViewGroup parent, @Nullable Bundle bundle) {
+ LayoutInflater inflater, @Nullable ViewGroup parent, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_search, parent, false);
adapter = new SearchAdapter(getActivity(), new SearchCursorManager());
adapter.setCallInitiationType(callInitiationType);
@@ -119,12 +122,25 @@ public final class NewSearchFragment extends Fragment
initLoaders();
}
+ if (savedInstanceState != null) {
+ setQuery(
+ savedInstanceState.getString(KEY_QUERY),
+ CallInitiationType.Type.forNumber(savedInstanceState.getInt(KEY_CALL_INITIATION_TYPE)));
+ }
+
if (updatePositionRunnable != null) {
ViewUtil.doOnPreDraw(view, false, updatePositionRunnable);
}
return view;
}
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt(KEY_CALL_INITIATION_TYPE, callInitiationType.getNumber());
+ outState.putString(KEY_QUERY, query);
+ }
+
private void initLoaders() {
getLoaderManager().initLoader(CONTACTS_LOADER_ID, null, this);
loadRemoteDirectoriesCursor();
diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java
index 61055a0c1..3bfdd98f3 100644
--- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java
+++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java
@@ -111,8 +111,11 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder>
}
public void setContactsCursor(SearchCursor cursor) {
- searchCursorManager.setContactsCursor(cursor);
- notifyDataSetChanged();
+ if (searchCursorManager.setContactsCursor(cursor)) {
+ // Since this is a new contacts cursor, we need to reapply the filter.
+ searchCursorManager.setQuery(query);
+ notifyDataSetChanged();
+ }
}
void clear() {