Search in sources :

Example 1 with GpodnetPodcast

use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast in project AntennaPod by AntennaPod.

the class PodcastListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.gpodnet_podcast_list, container, false);
    gridView = root.findViewById(R.id.gridView);
    progressBar = root.findViewById(R.id.progressBar);
    txtvError = root.findViewById(R.id.txtvError);
    butRetry = root.findViewById(R.id.butRetry);
    gridView.setOnItemClickListener((parent, view, position, id) -> onPodcastSelected((GpodnetPodcast) gridView.getAdapter().getItem(position)));
    butRetry.setOnClickListener(v -> loadData());
    loadData();
    return root;
}
Also used : GpodnetPodcast(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast) GridView(android.widget.GridView) View(android.view.View) TextView(android.widget.TextView)

Example 2 with GpodnetPodcast

use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast 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 3 with GpodnetPodcast

use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast in project AntennaPod by AntennaPod.

the class PodcastListAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Holder holder;
    GpodnetPodcast podcast = getItem(position);
    // Inflate Layout
    if (convertView == null) {
        holder = new Holder();
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.gpodnet_podcast_listitem, parent, false);
        holder.image = convertView.findViewById(R.id.imgvCover);
        holder.title = convertView.findViewById(R.id.txtvTitle);
        holder.subscribers = convertView.findViewById(R.id.txtvSubscribers);
        holder.author = convertView.findViewById(R.id.txtvAuthor);
        convertView.setTag(holder);
    } else {
        holder = (Holder) convertView.getTag();
    }
    if (StringUtils.isNotBlank(podcast.getLogoUrl())) {
        Glide.with(convertView.getContext()).load(podcast.getLogoUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).transforms(new FitCenter(), new RoundedCorners((int) (4 * convertView.getContext().getResources().getDisplayMetrics().density))).dontAnimate()).into(holder.image);
    }
    holder.title.setText(podcast.getTitle());
    holder.subscribers.setText(String.valueOf(podcast.getSubscribers()));
    holder.author.setText(podcast.getAuthor());
    return convertView;
}
Also used : GpodnetPodcast(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast) RequestOptions(com.bumptech.glide.request.RequestOptions) LayoutInflater(android.view.LayoutInflater) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Example 4 with GpodnetPodcast

use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast in project AntennaPod by AntennaPod.

the class GpodnetService method readPodcastFromJsonObject.

private GpodnetPodcast readPodcastFromJsonObject(JSONObject object) throws JSONException {
    String url = object.getString("url");
    String title;
    Object titleObj = object.opt("title");
    if (titleObj instanceof String) {
        title = (String) titleObj;
    } else {
        title = url;
    }
    String description;
    Object descriptionObj = object.opt("description");
    if (descriptionObj instanceof String) {
        description = (String) descriptionObj;
    } else {
        description = "";
    }
    int subscribers = object.getInt("subscribers");
    Object logoUrlObj = object.opt("logo_url");
    String logoUrl = (logoUrlObj instanceof String) ? (String) logoUrlObj : null;
    if (logoUrl == null) {
        Object scaledLogoUrl = object.opt("scaled_logo_url");
        if (scaledLogoUrl instanceof String) {
            logoUrl = (String) scaledLogoUrl;
        }
    }
    String website = null;
    Object websiteObj = object.opt("website");
    if (websiteObj instanceof String) {
        website = (String) websiteObj;
    }
    String mygpoLink = object.getString("mygpo_link");
    String author = null;
    Object authorObj = object.opt("author");
    if (authorObj instanceof String) {
        author = (String) authorObj;
    }
    return new GpodnetPodcast(url, title, description, subscribers, logoUrl, website, mygpoLink, author);
}
Also used : GpodnetPodcast(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast) JSONObject(org.json.JSONObject)

Aggregations

GpodnetPodcast (de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast)4 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 GridView (android.widget.GridView)1 TextView (android.widget.TextView)1 FitCenter (com.bumptech.glide.load.resource.bitmap.FitCenter)1 RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1 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 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 JSONObject (org.json.JSONObject)1