use of org.schabi.newpipe.extractor.search.SearchResult in project NewPipe by TeamNewPipe.
the class SearchInfoItemFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
searchQuery = "";
if (savedInstanceState != null) {
searchQuery = savedInstanceState.getString(QUERY);
streamingServiceId = savedInstanceState.getInt(STREAMING_SERVICE);
} else {
try {
Bundle args = getArguments();
if (args != null) {
searchQuery = args.getString(QUERY);
streamingServiceId = args.getInt(STREAMING_SERVICE);
} else {
streamingServiceId = NewPipe.getIdOfService("Youtube");
}
} catch (Exception e) {
e.printStackTrace();
ErrorActivity.reportError(getActivity(), e, null, getActivity().findViewById(android.R.id.content), ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED, NewPipe.getNameOfService(streamingServiceId), "", R.string.general_error));
}
}
setHasOptionsMenu(true);
SearchWorker sw = SearchWorker.getInstance();
sw.setSearchWorkerResultListener(new SearchWorker.SearchWorkerResultListener() {
@Override
public void onResult(SearchResult result) {
infoListAdapter.addInfoItemList(result.resultList);
setDoneLoading();
}
@Override
public void onNothingFound(int stringResource) {
//setListShown(true);
Toast.makeText(getActivity(), getString(stringResource), Toast.LENGTH_SHORT).show();
setDoneLoading();
}
@Override
public void onError(String message) {
//setListShown(true);
Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
setDoneLoading();
}
@Override
public void onReCaptchaChallenge() {
Toast.makeText(getActivity(), "ReCaptcha Challenge requested", Toast.LENGTH_LONG).show();
// Starting ReCaptcha Challenge Activity
startActivityForResult(new Intent(getActivity(), ReCaptchaActivity.class), RECAPTCHA_REQUEST);
}
});
}
Aggregations