mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-01 22:08:22 +03:00
Revert "cleanup SearchFragment: remove some not used parameters and method"
This reverts commit e84364ed38
.
This commit is contained in:
parent
50ddee767b
commit
16b1c53bd6
1 changed files with 32 additions and 11 deletions
|
@ -136,6 +136,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
@State
|
||||
boolean wasSearchFocused = false;
|
||||
|
||||
private StreamingService service;
|
||||
private Page nextPage;
|
||||
private boolean showLocalSuggestions = true;
|
||||
private boolean showRemoteSuggestions = true;
|
||||
|
@ -183,7 +184,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
searchFragment = new SearchFragment();
|
||||
}
|
||||
|
||||
searchFragment.setQuery(serviceId, searchString);
|
||||
searchFragment.setQuery(serviceId, searchString, null, null);
|
||||
|
||||
if (!TextUtils.isEmpty(searchString)) {
|
||||
searchFragment.setSearchOnResume();
|
||||
|
@ -228,6 +229,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
userSelectedSortFilterList = new ArrayList<>();
|
||||
}
|
||||
initializeFilterData();
|
||||
updateService();
|
||||
return inflater.inflate(R.layout.fragment_search, container, false);
|
||||
}
|
||||
|
||||
|
@ -261,12 +263,22 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
initSearchListeners();
|
||||
}
|
||||
|
||||
private void updateService() {
|
||||
try {
|
||||
service = NewPipe.getService(serviceId);
|
||||
} catch (final Exception e) {
|
||||
ErrorUtil.showUiErrorSnackbar(this, "Getting service for id " + serviceId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onStart() called");
|
||||
}
|
||||
super.onStart();
|
||||
|
||||
updateService();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -298,11 +310,11 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
|
||||
if (!TextUtils.isEmpty(searchString)) {
|
||||
if (wasLoading.getAndSet(false)) {
|
||||
search(searchString);
|
||||
search(searchString, selectedContentFilter, selectedSortFilter);
|
||||
return;
|
||||
} else if (infoListAdapter.getItemsList().isEmpty()) {
|
||||
if (savedState == null) {
|
||||
search(searchString);
|
||||
search(searchString, selectedContentFilter, selectedSortFilter);
|
||||
return;
|
||||
} else if (!isLoading.get() && !wasSearchFocused && lastPanelError == null) {
|
||||
infoListAdapter.clearStreamItemList();
|
||||
|
@ -355,7 +367,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
if (requestCode == ReCaptchaActivity.RECAPTCHA_REQUEST) {
|
||||
if (resultCode == Activity.RESULT_OK
|
||||
&& !TextUtils.isEmpty(searchString)) {
|
||||
search(searchString);
|
||||
search(searchString, selectedContentFilter, selectedSortFilter);
|
||||
} else {
|
||||
Log.e(TAG, "ReCaptcha failed");
|
||||
}
|
||||
|
@ -435,7 +447,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
|| (searchEditText != null && !TextUtils.isEmpty(searchEditText.getText()))) {
|
||||
search(!TextUtils.isEmpty(searchString)
|
||||
? searchString
|
||||
: searchEditText.getText().toString());
|
||||
: searchEditText.getText().toString(), this.selectedContentFilter, null);
|
||||
} else {
|
||||
if (searchEditText != null) {
|
||||
searchEditText.setText("");
|
||||
|
@ -460,6 +472,11 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
if (service == null) {
|
||||
Log.w(TAG, "onCreateOptionsMenu() called with null service");
|
||||
updateService();
|
||||
}
|
||||
|
||||
createMenu(menu, inflater);
|
||||
}
|
||||
|
||||
|
@ -555,7 +572,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
suggestionListAdapter.setListener(new SuggestionListAdapter.OnSuggestionItemSelected() {
|
||||
@Override
|
||||
public void onSuggestionItemSelected(final SuggestionItem item) {
|
||||
search(item.query);
|
||||
search(item.query, null, null);
|
||||
searchEditText.setText(item.query);
|
||||
}
|
||||
|
||||
|
@ -610,7 +627,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
} else if (event != null
|
||||
&& (event.getKeyCode() == KeyEvent.KEYCODE_ENTER
|
||||
|| event.getAction() == EditorInfo.IME_ACTION_SEARCH)) {
|
||||
search(searchEditText.getText().toString());
|
||||
search(searchEditText.getText().toString(), null, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -796,7 +813,9 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
// no-op
|
||||
}
|
||||
|
||||
private void search(final String theSearchString) {
|
||||
private void search(final String theSearchString,
|
||||
final List<FilterItem> theContentFilter,
|
||||
final List<FilterItem> theSortFilter) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "search() called with: query = [" + theSearchString + "]");
|
||||
}
|
||||
|
@ -913,12 +932,14 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
selectedSortFilter = theSelectedSortFilter;
|
||||
|
||||
if (!TextUtils.isEmpty(searchString)) {
|
||||
search(searchString);
|
||||
search(searchString, selectedContentFilter, selectedSortFilter);
|
||||
}
|
||||
}
|
||||
|
||||
private void setQuery(final int theServiceId,
|
||||
final String theSearchString) {
|
||||
final String theSearchString,
|
||||
final List<FilterItem> theContentFilter,
|
||||
final List<FilterItem> theSortFilter) {
|
||||
serviceId = theServiceId;
|
||||
searchString = theSearchString;
|
||||
}
|
||||
|
@ -1005,7 +1026,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
|
||||
searchBinding.correctSuggestion.setOnClickListener(v -> {
|
||||
searchBinding.correctSuggestion.setVisibility(View.GONE);
|
||||
search(searchSuggestion);
|
||||
search(searchSuggestion, selectedContentFilter, selectedSortFilter);
|
||||
searchEditText.setText(searchSuggestion);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue