aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-08-25 12:34:08 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-08-25 12:34:08 +0000
commitfffc5b9eb4679f08bc6e01aaff75de7ca7afb877 (patch)
treed9785f961c3ad5e37230328c494b9a4806faa83f
parentde8df061ed760a9390d991a3b3b01c23a5fd4352 (diff)
downloadinfinity-for-reddit-fffc5b9eb4679f08bc6e01aaff75de7ca7afb877.tar
infinity-for-reddit-fffc5b9eb4679f08bc6e01aaff75de7ca7afb877.tar.gz
infinity-for-reddit-fffc5b9eb4679f08bc6e01aaff75de7ca7afb877.tar.bz2
infinity-for-reddit-fffc5b9eb4679f08bc6e01aaff75de7ca7afb877.tar.lz
infinity-for-reddit-fffc5b9eb4679f08bc6e01aaff75de7ca7afb877.tar.xz
infinity-for-reddit-fffc5b9eb4679f08bc6e01aaff75de7ca7afb877.tar.zst
infinity-for-reddit-fffc5b9eb4679f08bc6e01aaff75de7ca7afb877.zip
Fix clicking a subreddit in subreddit suggestions goes to the subreddit page instead of returning the subreddit name in several activities.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java25
-rw-r--r--app/src/main/res/layout/activity_search.xml3
2 files changed, 20 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 34d57efc..66369953 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -41,7 +41,6 @@ import ml.docilealligator.infinityforreddit.adapters.SearchActivityRecyclerViewA
import ml.docilealligator.infinityforreddit.adapters.SubredditAutocompleteRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
-import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.recentsearchquery.DeleteRecentSearchQuery;
import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQuery;
@@ -183,11 +182,24 @@ public class SearchActivity extends BaseActivity {
subredditAutocompleteRecyclerViewAdapter = new SubredditAutocompleteRecyclerViewAdapter(this,
mCustomThemeWrapper, subredditData -> {
- Intent intent = new Intent(SearchActivity.this, ViewSubredditDetailActivity.class);
- intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditData.getName());
- startActivity(intent);
- finish();
- });
+ if (searchOnlySubreddits) {
+ Intent returnIntent = new Intent();
+ if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) {
+ ArrayList<String> subredditNameList = new ArrayList<>();
+ subredditNameList.add(subredditData.getName());
+ returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, subredditNameList);
+ } else {
+ returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, subredditData.getName());
+ returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, subredditData.getIconUrl());
+ }
+ setResult(Activity.RESULT_OK, returnIntent);
+ } else {
+ Intent intent = new Intent(SearchActivity.this, ViewSubredditDetailActivity.class);
+ intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditData.getName());
+ startActivity(intent);
+ }
+ finish();
+ });
simpleSearchView.setOnQueryTextListener(new SimpleSearchView.OnQueryTextListener() {
@Override
@@ -287,7 +299,6 @@ public class SearchActivity extends BaseActivity {
});
recyclerView.setVisibility(View.VISIBLE);
recyclerView.setNestedScrollingEnabled(false);
- recyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
recyclerView.setAdapter(adapter);
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true)) {
diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml
index 7de8bd69..29b5b94f 100644
--- a/app/src/main/res/layout/activity_search.xml
+++ b/app/src/main/res/layout/activity_search.xml
@@ -95,7 +95,8 @@
android:id="@+id/recycler_view_search_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:visibility="gone" />
+ android:visibility="gone"
+ app:layoutManager=".customviews.LinearLayoutManagerBugFixed" />
</LinearLayout>