diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-08-21 22:53:01 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-08-21 22:53:01 +0000 |
commit | 7b9ece76fd7a5daf68a43b3aa05946e4d374ad5e (patch) | |
tree | 71f6de5f71f221d534a03303c10f7c61cfb4b6ce /app/src/main | |
parent | 8625b3bf1c0f2c215388116da3c91f182fce2937 (diff) | |
download | infinity-for-reddit-7b9ece76fd7a5daf68a43b3aa05946e4d374ad5e.tar infinity-for-reddit-7b9ece76fd7a5daf68a43b3aa05946e4d374ad5e.tar.gz infinity-for-reddit-7b9ece76fd7a5daf68a43b3aa05946e4d374ad5e.tar.bz2 infinity-for-reddit-7b9ece76fd7a5daf68a43b3aa05946e4d374ad5e.tar.lz infinity-for-reddit-7b9ece76fd7a5daf68a43b3aa05946e4d374ad5e.tar.xz infinity-for-reddit-7b9ece76fd7a5daf68a43b3aa05946e4d374ad5e.tar.zst infinity-for-reddit-7b9ece76fd7a5daf68a43b3aa05946e4d374ad5e.zip |
Pass multireddit data back to SearchActivity after selecting a multireddit in the original SearchActivity and opening SearchResultActivity.
Diffstat (limited to 'app/src/main')
2 files changed, 20 insertions, 30 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 df680b01..d88c75ce 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -309,6 +309,14 @@ public class SearchActivity extends BaseActivity { setSearchInThingText(); } else { query = getIntent().getStringExtra(EXTRA_QUERY); + searchInSubredditOrUserName = getIntent().getStringExtra(EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME); + searchInMultiReddit = getIntent().getParcelableExtra(EXTRA_SEARCH_IN_MULTIREDDIT); + searchInThingType = getIntent().getIntExtra(EXTRA_SEARCH_IN_THING_TYPE, SelectThingReturnKey.THING_TYPE.SUBREDDIT); + if (searchInSubredditOrUserName != null) { + binding.subredditNameTextViewSearchActivity.setText(searchInSubredditOrUserName); + } else if (searchInMultiReddit != null) { + binding.subredditNameTextViewSearchActivity.setText(searchInMultiReddit.getDisplayName()); + } } bindView(); @@ -339,16 +347,6 @@ public class SearchActivity extends BaseActivity { requestThingSelectionForCurrentActivityLauncher.launch(intent); }); } - - Intent intent = getIntent(); - searchInSubredditOrUserName = intent.getStringExtra(EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME); - searchInMultiReddit = intent.getParcelableExtra(EXTRA_SEARCH_IN_MULTIREDDIT); - searchInThingType = intent.getIntExtra(EXTRA_SEARCH_IN_THING_TYPE, SelectThingReturnKey.THING_TYPE.SUBREDDIT); - if (searchInSubredditOrUserName != null) { - binding.subredditNameTextViewSearchActivity.setText(searchInSubredditOrUserName); - } else if (searchInMultiReddit != null) { - binding.subredditNameTextViewSearchActivity.setText(searchInMultiReddit.getDisplayName()); - } } private void bindView() { @@ -450,11 +448,9 @@ public class SearchActivity extends BaseActivity { } else { Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class); intent.putExtra(SearchResultActivity.EXTRA_QUERY, query); - if (searchInSubredditOrUserName != null) { - intent.putExtra(SearchResultActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, searchInSubredditOrUserName); - intent.putExtra(SearchResultActivity.EXTRA_SEARCH_IN_MULTIREDDIT, searchInMultiReddit); - intent.putExtra(SearchResultActivity.EXTRA_SEARCH_IN_THING_TYPE, searchInThingType); - } + intent.putExtra(SearchResultActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, searchInSubredditOrUserName); + intent.putExtra(SearchResultActivity.EXTRA_SEARCH_IN_MULTIREDDIT, searchInMultiReddit); + intent.putExtra(SearchResultActivity.EXTRA_SEARCH_IN_THING_TYPE, searchInThingType); startActivity(intent); finish(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index c9eb510f..059bea5a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -345,11 +345,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect } case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: { Intent intent = new Intent(this, SearchActivity.class); - if (mSearchInSubredditOrUserName != null && !mSearchInSubredditOrUserName.equals("")) { - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName); - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_MULTIREDDIT, mSearchInMultiReddit); - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_THING_TYPE, mSearchInThingType); - } + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName); + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_MULTIREDDIT, mSearchInMultiReddit); + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_THING_TYPE, mSearchInThingType); startActivity(intent); break; } @@ -435,11 +433,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect return true; } else if (itemId == R.id.action_search_search_result_activity) { Intent intent = new Intent(this, SearchActivity.class); - if (mSearchInSubredditOrUserName != null && !mSearchInSubredditOrUserName.equals("")) { - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName); - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_MULTIREDDIT, mSearchInMultiReddit); - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_THING_TYPE, mSearchInThingType); - } + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName); + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_MULTIREDDIT, mSearchInMultiReddit); + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_THING_TYPE, mSearchInThingType); intent.putExtra(SearchActivity.EXTRA_QUERY, mQuery); finish(); startActivity(intent); @@ -549,11 +545,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect break; case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH: Intent intent = new Intent(this, SearchActivity.class); - if (mSearchInSubredditOrUserName != null && !mSearchInSubredditOrUserName.equals("")) { - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName); - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_MULTIREDDIT, mSearchInMultiReddit); - intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_THING_TYPE, mSearchInThingType); - } + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName); + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_MULTIREDDIT, mSearchInMultiReddit); + intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_THING_TYPE, mSearchInThingType); startActivity(intent); break; case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: { |