aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-08-21 21:45:29 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-08-21 21:45:29 +0000
commit5663d33ed3da5c43424774e9ec5700465c49eece (patch)
tree73aa0bd102ae4139be53de063cfefbaa65ea81b5 /app/src/main
parente42a1ed9d3cb9b62f1b15cda9797ed69a2f7b066 (diff)
downloadinfinity-for-reddit-5663d33ed3da5c43424774e9ec5700465c49eece.tar
infinity-for-reddit-5663d33ed3da5c43424774e9ec5700465c49eece.tar.gz
infinity-for-reddit-5663d33ed3da5c43424774e9ec5700465c49eece.tar.bz2
infinity-for-reddit-5663d33ed3da5c43424774e9ec5700465c49eece.tar.lz
infinity-for-reddit-5663d33ed3da5c43424774e9ec5700465c49eece.tar.xz
infinity-for-reddit-5663d33ed3da5c43424774e9ec5700465c49eece.tar.zst
infinity-for-reddit-5663d33ed3da5c43424774e9ec5700465c49eece.zip
Select multireddit in SearchActivity.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java25
1 files changed, 17 insertions, 8 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 de0b643f..87c791fd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -120,7 +120,7 @@ public class SearchActivity extends BaseActivity {
private Call<String> subredditAutocompleteCall;
RecentSearchQueryViewModel mRecentSearchQueryViewModel;
private ActivityResultLauncher<Intent> requestThingSelectionForCurrentActivityLauncher;
- private ActivityResultLauncher<Intent> requestThingSelectionForOtherActivityLauncher;
+ private ActivityResultLauncher<Intent> requestThingSelectionForAnotherActivityLauncher;
private ActivitySearchBinding binding;
@Override
@@ -315,21 +315,30 @@ public class SearchActivity extends BaseActivity {
requestThingSelectionForCurrentActivityLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
Intent returnIntent = result.getData();
- if (returnIntent == null) {
+ if (returnIntent == null || returnIntent.getExtras() == null) {
return;
}
searchInSubredditOrUserName = returnIntent.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME);
searchInThingType = returnIntent.getIntExtra(SelectThingReturnKey.RETURN_EXTRA_THING_TYPE, SelectThingReturnKey.THING_TYPE.SUBREDDIT);
+ searchInMultiReddit = returnIntent.getExtras().getParcelable(SelectThingReturnKey.RETRUN_EXTRA_MULTIREDDIT);
+
+ switch (searchInThingType) {
+ case SelectThingReturnKey.THING_TYPE.SUBREDDIT:
+ case SelectThingReturnKey.THING_TYPE.USER:
+ if (searchInSubredditOrUserName == null) {
+ binding.subredditNameTextViewSearchActivity.setText(R.string.all_subreddits);
+ } else {
+ binding.subredditNameTextViewSearchActivity.setText(searchInSubredditOrUserName);
+ }
+ break;
+ case SelectThingReturnKey.THING_TYPE.MULTIREDDIT:
+ binding.subredditNameTextViewSearchActivity.setText(searchInMultiReddit.getDisplayName());
- if (searchInSubredditOrUserName == null) {
- binding.subredditNameTextViewSearchActivity.setText(R.string.all_subreddits);
- } else {
- binding.subredditNameTextViewSearchActivity.setText(searchInSubredditOrUserName);
}
});
- requestThingSelectionForOtherActivityLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
+ requestThingSelectionForAnotherActivityLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
setResult(RESULT_OK, result.getData());
finish();
});
@@ -447,7 +456,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);
- requestThingSelectionForOtherActivityLauncher.launch(intent);
+ requestThingSelectionForAnotherActivityLauncher.launch(intent);
} else {
Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
intent.putExtra(SearchResultActivity.EXTRA_QUERY, query);