diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-11-09 04:17:32 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-11-09 04:17:32 +0000 |
commit | 252412d8ce5cd87e94bceaf30b5108eec63aadb7 (patch) | |
tree | 8d23e2a4ea229185221205fff3ef81a98b868018 /app/src/main | |
parent | b39f90e2756c12e92dd50eb1dccea142b5e57d9d (diff) | |
download | infinity-for-reddit-252412d8ce5cd87e94bceaf30b5108eec63aadb7.tar infinity-for-reddit-252412d8ce5cd87e94bceaf30b5108eec63aadb7.tar.gz infinity-for-reddit-252412d8ce5cd87e94bceaf30b5108eec63aadb7.tar.bz2 infinity-for-reddit-252412d8ce5cd87e94bceaf30b5108eec63aadb7.tar.lz infinity-for-reddit-252412d8ce5cd87e94bceaf30b5108eec63aadb7.tar.xz infinity-for-reddit-252412d8ce5cd87e94bceaf30b5108eec63aadb7.tar.zst infinity-for-reddit-252412d8ce5cd87e94bceaf30b5108eec63aadb7.zip |
Searching subreddits in SubredditFilterPopularAndAllActivity is available.
Diffstat (limited to '')
3 files changed, 24 insertions, 8 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java index 3c488a5c..3fff7dae 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java @@ -86,6 +86,9 @@ public class CreateMultiRedditActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); + + setImmersiveModeNotApplicable(); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_multi_reddit); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditFilterPopularAndAllActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditFilterPopularAndAllActivity.java index 88618b5e..55a62e7f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditFilterPopularAndAllActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditFilterPopularAndAllActivity.java @@ -1,7 +1,7 @@ package ml.docilealligator.infinityforreddit.Activity; import android.content.Context; -import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.MenuItem; @@ -9,6 +9,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.lifecycle.ViewModelProvider; @@ -36,6 +37,7 @@ import ml.docilealligator.infinityforreddit.SubredditFilter.SubredditFilterViewM public class SubredditFilterPopularAndAllActivity extends BaseActivity { + private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 1; @BindView(R.id.coordinator_layout_subreddit_filter_popular_and_all_activity) CoordinatorLayout coordinatorLayout; @BindView(R.id.appbar_layout_subreddit_filter_popular_and_all_activity) @@ -111,13 +113,14 @@ public class SubredditFilterPopularAndAllActivity extends BaseActivity { () -> {}); }) .setNegativeButton(R.string.cancel, null) - .setNeutralButton(R.string.search, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (imm != null) { - imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0); - } + .setNeutralButton(R.string.search, (dialogInterface, i) -> { + if (imm != null) { + imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0); } + + Intent intent = new Intent(this, SearchActivity.class); + intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_SUBREDDITS, true); + startActivityForResult(intent, SUBREDDIT_SEARCH_REQUEST_CODE); }) .setOnDismissListener(dialogInterface -> { if (imm != null) { @@ -139,6 +142,16 @@ public class SubredditFilterPopularAndAllActivity extends BaseActivity { } @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE && resultCode == RESULT_OK && data != null) { + SubredditFilter subredditFilter = new SubredditFilter(data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME), SubredditFilter.TYPE_POPULAR_AND_ALL); + InsertSubredditFilter.insertSubredditFilter(redditDataRoomDatabase, subredditFilter, + () -> {}); + } + } + + @Override protected SharedPreferences getDefaultSharedPreferences() { return sharedPreferences; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java index 1afa6e4b..bf7a739b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java @@ -222,7 +222,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); - if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE && resultCode == RESULT_OK && data != null) { + if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE && resultCode == RESULT_OK && data != null && mAdapter != null) { Intent returnIntent = new Intent(); ArrayList<String> selectedSubreddits = mAdapter.getAllSelectedSubreddits(); selectedSubreddits.add(data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME)); |