use of de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService in project AntennaPod by AntennaPod.
the class GpodderAuthenticationFragment method setupHostView.
private void setupHostView(View view) {
final Button selectHost = view.findViewById(R.id.chooseHostButton);
final RadioGroup serverRadioGroup = view.findViewById(R.id.serverRadioGroup);
final EditText serverUrlText = view.findViewById(R.id.serverUrlText);
if (!GpodnetService.DEFAULT_BASE_HOST.equals(SynchronizationCredentials.getHosturl())) {
serverUrlText.setText(SynchronizationCredentials.getHosturl());
}
final TextInputLayout serverUrlTextInput = view.findViewById(R.id.serverUrlTextInput);
serverRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {
serverUrlTextInput.setVisibility(checkedId == R.id.customServerRadio ? View.VISIBLE : View.GONE);
});
selectHost.setOnClickListener(v -> {
SynchronizationCredentials.clear(getContext());
if (serverRadioGroup.getCheckedRadioButtonId() == R.id.customServerRadio) {
SynchronizationCredentials.setHosturl(serverUrlText.getText().toString());
} else {
SynchronizationCredentials.setHosturl(GpodnetService.DEFAULT_BASE_HOST);
}
service = new GpodnetService(AntennapodHttpClient.getHttpClient(), SynchronizationCredentials.getHosturl(), SynchronizationCredentials.getDeviceID(), SynchronizationCredentials.getUsername(), SynchronizationCredentials.getPassword());
getDialog().setTitle(SynchronizationCredentials.getHosturl());
advance();
});
}
use of de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService in project AntennaPod by AntennaPod.
the class PodcastListFragment method loadData.
final void loadData() {
if (disposable != null) {
disposable.dispose();
}
gridView.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
txtvError.setVisibility(View.GONE);
butRetry.setVisibility(View.GONE);
disposable = Observable.fromCallable(() -> {
GpodnetService service = new GpodnetService(AntennapodHttpClient.getHttpClient(), SynchronizationCredentials.getHosturl(), SynchronizationCredentials.getDeviceID(), SynchronizationCredentials.getUsername(), SynchronizationCredentials.getPassword());
return loadPodcastData(service);
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(podcasts -> {
progressBar.setVisibility(View.GONE);
butRetry.setVisibility(View.GONE);
if (podcasts.size() > 0) {
PodcastListAdapter listAdapter = new PodcastListAdapter(getContext(), 0, podcasts);
gridView.setAdapter(listAdapter);
listAdapter.notifyDataSetChanged();
gridView.setVisibility(View.VISIBLE);
txtvError.setVisibility(View.GONE);
} else {
gridView.setVisibility(View.GONE);
txtvError.setText(getString(R.string.search_status_no_results));
txtvError.setVisibility(View.VISIBLE);
}
}, error -> {
gridView.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
txtvError.setText(error.getMessage());
txtvError.setVisibility(View.VISIBLE);
butRetry.setVisibility(View.VISIBLE);
Log.e(TAG, Log.getStackTraceString(error));
});
}
use of de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService in project AntennaPod by AntennaPod.
the class GpodnetPodcastSearcher method search.
public Single<List<PodcastSearchResult>> search(String query) {
return Single.create((SingleOnSubscribe<List<PodcastSearchResult>>) subscriber -> {
try {
GpodnetService service = new GpodnetService(AntennapodHttpClient.getHttpClient(), SynchronizationCredentials.getHosturl(), SynchronizationCredentials.getDeviceID(), SynchronizationCredentials.getUsername(), SynchronizationCredentials.getPassword());
List<GpodnetPodcast> gpodnetPodcasts = service.searchPodcasts(query, 0);
List<PodcastSearchResult> results = new ArrayList<>();
for (GpodnetPodcast podcast : gpodnetPodcasts) {
results.add(PodcastSearchResult.fromGpodder(podcast));
}
subscriber.onSuccess(results);
} catch (GpodnetServiceException e) {
e.printStackTrace();
subscriber.onError(e);
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}
use of de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService in project AntennaPod by AntennaPod.
the class TagListFragment method startLoadTask.
private void startLoadTask() {
if (disposable != null) {
disposable.dispose();
}
setListShown(false);
disposable = Observable.fromCallable(() -> {
GpodnetService service = new GpodnetService(AntennapodHttpClient.getHttpClient(), SynchronizationCredentials.getHosturl(), SynchronizationCredentials.getDeviceID(), SynchronizationCredentials.getUsername(), SynchronizationCredentials.getPassword());
return service.getTopTags(COUNT);
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(tags -> {
setListAdapter(new TagListAdapter(getContext(), android.R.layout.simple_list_item_1, tags));
setListShown(true);
}, error -> {
TextView txtvError = new TextView(getActivity());
txtvError.setText(error.getMessage());
getListView().setEmptyView(txtvError);
setListShown(true);
Log.e(TAG, Log.getStackTraceString(error));
});
}
Aggregations