Merge pull request #6558 from Douile/fix/searchfragment-null-service
Fix null pointer exception when displaying SearchFragment
This commit is contained in:
commit
0da8e28651
|
@ -227,6 +227,25 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
initSearchListeners();
|
initSearchListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateService() {
|
||||||
|
try {
|
||||||
|
service = NewPipe.getService(serviceId);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
ErrorActivity.reportUiErrorInSnackbar(this,
|
||||||
|
"Getting service for id " + serviceId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "onStart() called");
|
||||||
|
}
|
||||||
|
super.onStart();
|
||||||
|
|
||||||
|
updateService();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
@ -250,13 +269,6 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
}
|
}
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
try {
|
|
||||||
service = NewPipe.getService(serviceId);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
ErrorActivity.reportUiErrorInSnackbar(this,
|
|
||||||
"Getting service for id " + serviceId, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (suggestionDisposable == null || suggestionDisposable.isDisposed()) {
|
if (suggestionDisposable == null || suggestionDisposable.isDisposed()) {
|
||||||
initSuggestionObserver();
|
initSuggestionObserver();
|
||||||
}
|
}
|
||||||
|
@ -428,6 +440,12 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
int itemId = 0;
|
int itemId = 0;
|
||||||
boolean isFirstItem = true;
|
boolean isFirstItem = true;
|
||||||
final Context c = getContext();
|
final Context c = getContext();
|
||||||
|
|
||||||
|
if (service == null) {
|
||||||
|
Log.w(TAG, "onCreateOptionsMenu() called with null service");
|
||||||
|
updateService();
|
||||||
|
}
|
||||||
|
|
||||||
for (final String filter : service.getSearchQHFactory().getAvailableContentFilter()) {
|
for (final String filter : service.getSearchQHFactory().getAvailableContentFilter()) {
|
||||||
if (filter.equals(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS)) {
|
if (filter.equals(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS)) {
|
||||||
final MenuItem musicItem = menu.add(2,
|
final MenuItem musicItem = menu.add(2,
|
||||||
|
|
Loading…
Reference in New Issue