From bb7fca73829d472ac5ff74497e8b134de5e3d2e7 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Wed, 22 Mar 2017 14:03:53 +1100 Subject: [PATCH] Remember search input after hitting "Back" from app details. Move logic which parses intent and forceably sets the text of our search input to onCreate(), not onResume(). onCreate() is invoked each time a new intent is sent to open up this activity. That is, each time a new category is opened or a new search request is received. onResume() is called much more often than this, including when the user is directed to a new activity and then returns to the search screen after hitting back. In this case we don't want to remove the search query the user had and replace it with the data in the original intent. --- .../org/fdroid/fdroid/views/apps/AppListActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/apps/AppListActivity.java b/app/src/main/java/org/fdroid/fdroid/views/apps/AppListActivity.java index c8c3e777b..2da8b69ce 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/apps/AppListActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/apps/AppListActivity.java @@ -26,6 +26,7 @@ public class AppListActivity extends AppCompatActivity implements LoaderManager. public static final String EXTRA_CATEGORY = "org.fdroid.fdroid.views.apps.AppListActivity.EXTRA_CATEGORY"; public static final String EXTRA_SEARCH_TERMS = "org.fdroid.fdroid.views.apps.AppListActivity.EXTRA_SEARCH_TERMS"; + private RecyclerView appView; private AppListAdapter appAdapter; private String category; @@ -78,12 +79,11 @@ public class AppListActivity extends AppCompatActivity implements LoaderManager. appView.setHasFixedSize(true); appView.setLayoutManager(new LinearLayoutManager(this)); appView.setAdapter(appAdapter); + + parseIntentForSearchQuery(); } - @Override - protected void onResume() { - super.onResume(); - + private void parseIntentForSearchQuery() { Intent intent = getIntent(); category = intent.hasExtra(EXTRA_CATEGORY) ? intent.getStringExtra(EXTRA_CATEGORY) : null; searchTerms = intent.hasExtra(EXTRA_SEARCH_TERMS) ? intent.getStringExtra(EXTRA_SEARCH_TERMS) : null;