Searching subreddits in SubredditFilterPopularAndAllActivity is available.

This commit is contained in:
Alex Ning 2020-11-09 12:17:32 +08:00
parent b39f90e275
commit 252412d8ce
3 changed files with 24 additions and 8 deletions

View File

@ -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);

View File

@ -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) {
@ -138,6 +141,16 @@ public class SubredditFilterPopularAndAllActivity extends BaseActivity {
return false;
}
@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;

View File

@ -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));