Fix search button to forward the search query (#4798)

This commit is contained in:
Herbert Reiter 2021-01-01 13:24:12 +01:00 committed by GitHub
parent 054a4f42a3
commit 8abec2c447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -51,6 +51,7 @@ public class AddFeedFragment extends Fragment {
private static final int REQUEST_CODE_CHOOSE_OPML_IMPORT_PATH = 1; private static final int REQUEST_CODE_CHOOSE_OPML_IMPORT_PATH = 1;
private static final int REQUEST_CODE_ADD_LOCAL_FOLDER = 2; private static final int REQUEST_CODE_ADD_LOCAL_FOLDER = 2;
private AddfeedBinding viewBinding;
private MainActivity activity; private MainActivity activity;
@Override @Override
@ -59,7 +60,7 @@ public class AddFeedFragment extends Fragment {
@Nullable ViewGroup container, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState); super.onCreateView(inflater, container, savedInstanceState);
AddfeedBinding viewBinding = AddfeedBinding.inflate(getLayoutInflater()); viewBinding = AddfeedBinding.inflate(getLayoutInflater());
activity = (MainActivity) getActivity(); activity = (MainActivity) getActivity();
Toolbar toolbar = viewBinding.toolbar; Toolbar toolbar = viewBinding.toolbar;
@ -75,8 +76,7 @@ public class AddFeedFragment extends Fragment {
-> activity.loadChildFragment(OnlineSearchFragment.newInstance(PodcastIndexPodcastSearcher.class))); -> activity.loadChildFragment(OnlineSearchFragment.newInstance(PodcastIndexPodcastSearcher.class)));
viewBinding.combinedFeedSearchEditText.setOnEditorActionListener((v, actionId, event) -> { viewBinding.combinedFeedSearchEditText.setOnEditorActionListener((v, actionId, event) -> {
String query = viewBinding.combinedFeedSearchEditText.getText().toString(); performSearch();
performSearch(query);
return true; return true;
}); });
@ -114,8 +114,7 @@ public class AddFeedFragment extends Fragment {
viewBinding.addLocalFolderButton.setVisibility(View.GONE); viewBinding.addLocalFolderButton.setVisibility(View.GONE);
} }
String query = viewBinding.combinedFeedSearchEditText.getText().toString(); viewBinding.searchButton.setOnClickListener(view -> performSearch());
viewBinding.searchButton.setOnClickListener(view -> performSearch(query));
return viewBinding.getRoot(); return viewBinding.getRoot();
} }
@ -145,8 +144,8 @@ public class AddFeedFragment extends Fragment {
startActivity(intent); startActivity(intent);
} }
private void performSearch(String query) { private void performSearch() {
String query = viewBinding.combinedFeedSearchEditText.getText().toString();
if (query.matches("http[s]?://.*")) { if (query.matches("http[s]?://.*")) {
addUrl(query); addUrl(query);
return; return;