diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-08-21 16:50:24 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-08-21 16:50:24 +0000 |
commit | 4c40d645ab99a28fc32b0273c74d087c994d6649 (patch) | |
tree | 03a1d96edfcaf2795ed1e0eac94b539fed3068a3 | |
parent | 6fd0b836a732c529420f0008c381bad40255c6d7 (diff) | |
download | infinity-for-reddit-4c40d645ab99a28fc32b0273c74d087c994d6649.tar infinity-for-reddit-4c40d645ab99a28fc32b0273c74d087c994d6649.tar.gz infinity-for-reddit-4c40d645ab99a28fc32b0273c74d087c994d6649.tar.bz2 infinity-for-reddit-4c40d645ab99a28fc32b0273c74d087c994d6649.tar.lz infinity-for-reddit-4c40d645ab99a28fc32b0273c74d087c994d6649.tar.xz infinity-for-reddit-4c40d645ab99a28fc32b0273c74d087c994d6649.tar.zst infinity-for-reddit-4c40d645ab99a28fc32b0273c74d087c994d6649.zip |
Pass data back to the original SearchActivity after selecting a subreddit or user in SearchResultActivity.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java index ec18a167..d9c02988 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -116,7 +116,8 @@ public class SearchActivity extends BaseActivity { private Runnable autoCompleteRunnable; private Call<String> subredditAutocompleteCall; RecentSearchQueryViewModel mRecentSearchQueryViewModel; - private ActivityResultLauncher<Intent> requestThingSelectionLauncher; + private ActivityResultLauncher<Intent> requestThingSelectionForCurrentActivityLauncher; + private ActivityResultLauncher<Intent> requestThingSelectionForOtherActivityLauncher; private ActivitySearchBinding binding; @Override @@ -151,7 +152,7 @@ public class SearchActivity extends BaseActivity { binding.searchEditTextSearchActivity.setHint(R.string.search_only_subreddits_hint); } else if (searchOnlyUsers) { binding.searchEditTextSearchActivity.setHint(R.string.search_only_users_hint); - } else { + } else if (searchSubredditsAndUsers) { binding.searchEditTextSearchActivity.setHint(R.string.search_subreddits_and_users_hint); } @@ -309,7 +310,7 @@ public class SearchActivity extends BaseActivity { } bindView(); - requestThingSelectionLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { + requestThingSelectionForCurrentActivityLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { Intent returnIntent = result.getData(); if (returnIntent == null) { return; @@ -325,13 +326,18 @@ public class SearchActivity extends BaseActivity { } }); + requestThingSelectionForOtherActivityLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { + setResult(RESULT_OK, result.getData()); + finish(); + }); + if (searchOnlySubreddits || searchOnlyUsers || searchSubredditsAndUsers) { binding.subredditNameRelativeLayoutSearchActivity.setVisibility(View.GONE); } else { binding.subredditNameRelativeLayoutSearchActivity.setOnClickListener(view -> { Intent intent = new Intent(this, SubscribedThingListingActivity.class); intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); - requestThingSelectionLauncher.launch(intent); + requestThingSelectionForCurrentActivityLauncher.launch(intent); }); } @@ -438,7 +444,7 @@ public class SearchActivity extends BaseActivity { Intent intent = new Intent(this, SearchResultActivity.class); intent.putExtra(SearchResultActivity.EXTRA_QUERY, query); intent.putExtra(SearchResultActivity.EXTRA_SHOULD_RETURN_SUBREDDIT_AND_USER_NAME, true); - startActivity(intent); + requestThingSelectionForOtherActivityLauncher.launch(intent); } else { Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class); intent.putExtra(SearchResultActivity.EXTRA_QUERY, query); |