Search in sources :

Example 1 with GpodnetServiceException

use of de.danoeh.antennapod.net.sync.gpoddernet.GpodnetServiceException 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());
}
Also used : GpodnetService(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService) List(java.util.List) SynchronizationCredentials(de.danoeh.antennapod.core.sync.SynchronizationCredentials) GpodnetPodcast(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast) Schedulers(io.reactivex.schedulers.Schedulers) AntennapodHttpClient(de.danoeh.antennapod.core.service.download.AntennapodHttpClient) GpodnetServiceException(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetServiceException) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) SingleOnSubscribe(io.reactivex.SingleOnSubscribe) ArrayList(java.util.ArrayList) GpodnetPodcast(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast) GpodnetServiceException(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetServiceException) GpodnetService(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

AntennapodHttpClient (de.danoeh.antennapod.core.service.download.AntennapodHttpClient)1 SynchronizationCredentials (de.danoeh.antennapod.core.sync.SynchronizationCredentials)1 GpodnetService (de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService)1 GpodnetServiceException (de.danoeh.antennapod.net.sync.gpoddernet.GpodnetServiceException)1 GpodnetPodcast (de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast)1 Single (io.reactivex.Single)1 SingleOnSubscribe (io.reactivex.SingleOnSubscribe)1 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)1 Schedulers (io.reactivex.schedulers.Schedulers)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1