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