Search in sources :

Example 1 with GpodnetService

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();
    });
}
Also used : EditText(android.widget.EditText) GpodnetService(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService) RadioGroup(android.widget.RadioGroup) MaterialButton(com.google.android.material.button.MaterialButton) Button(android.widget.Button) TextInputLayout(com.google.android.material.textfield.TextInputLayout)

Example 2 with GpodnetService

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));
    });
}
Also used : Bundle(android.os.Bundle) GridView(android.widget.GridView) ProgressBar(android.widget.ProgressBar) GpodnetPodcast(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast) Intent(android.content.Intent) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) PodcastListAdapter(de.danoeh.antennapod.adapter.gpodnet.PodcastListAdapter) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Button(android.widget.Button) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) AntennapodHttpClient(de.danoeh.antennapod.core.service.download.AntennapodHttpClient) GpodnetServiceException(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetServiceException) Log(android.util.Log) GpodnetService(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService) LayoutInflater(android.view.LayoutInflater) R(de.danoeh.antennapod.R) ViewGroup(android.view.ViewGroup) MainActivity(de.danoeh.antennapod.activity.MainActivity) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) TextView(android.widget.TextView) SynchronizationCredentials(de.danoeh.antennapod.core.sync.SynchronizationCredentials) OnlineFeedViewActivity(de.danoeh.antennapod.activity.OnlineFeedViewActivity) GpodnetService(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService) PodcastListAdapter(de.danoeh.antennapod.adapter.gpodnet.PodcastListAdapter)

Example 3 with GpodnetService

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());
}
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)

Example 4 with GpodnetService

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));
    });
}
Also used : GpodnetService(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) TagListAdapter(de.danoeh.antennapod.adapter.gpodnet.TagListAdapter) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MainActivity(de.danoeh.antennapod.activity.MainActivity) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) SynchronizationCredentials(de.danoeh.antennapod.core.sync.SynchronizationCredentials) View(android.view.View) ListFragment(androidx.fragment.app.ListFragment) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) GpodnetTag(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetTag) AntennapodHttpClient(de.danoeh.antennapod.core.service.download.AntennapodHttpClient) Log(android.util.Log) TagListAdapter(de.danoeh.antennapod.adapter.gpodnet.TagListAdapter) GpodnetService(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService) TextView(android.widget.TextView)

Aggregations

GpodnetService (de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService)4 AntennapodHttpClient (de.danoeh.antennapod.core.service.download.AntennapodHttpClient)3 SynchronizationCredentials (de.danoeh.antennapod.core.sync.SynchronizationCredentials)3 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)3 Schedulers (io.reactivex.schedulers.Schedulers)3 Bundle (android.os.Bundle)2 Log (android.util.Log)2 View (android.view.View)2 Button (android.widget.Button)2 TextView (android.widget.TextView)2 MainActivity (de.danoeh.antennapod.activity.MainActivity)2 GpodnetServiceException (de.danoeh.antennapod.net.sync.gpoddernet.GpodnetServiceException)2 GpodnetPodcast (de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast)2 Observable (io.reactivex.Observable)2 Disposable (io.reactivex.disposables.Disposable)2 List (java.util.List)2 Intent (android.content.Intent)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 EditText (android.widget.EditText)1