Search in sources :

Example 6 with ArrayMap

use of androidx.collection.ArrayMap in project AntennaPod by AntennaPod.

the class PlaybackPreferencesFragment method buildEnqueueLocationPreference.

private void buildEnqueueLocationPreference() {
    final Resources res = requireActivity().getResources();
    final Map<String, String> options = new ArrayMap<>();
    {
        String[] keys = res.getStringArray(R.array.enqueue_location_values);
        String[] values = res.getStringArray(R.array.enqueue_location_options);
        for (int i = 0; i < keys.length; i++) {
            options.put(keys[i], values[i]);
        }
    }
    ListPreference pref = requirePreference(UserPreferences.PREF_ENQUEUE_LOCATION);
    pref.setSummary(res.getString(R.string.pref_enqueue_location_sum, options.get(pref.getValue())));
    pref.setOnPreferenceChangeListener((preference, newValue) -> {
        if (!(newValue instanceof String)) {
            return false;
        }
        String newValStr = (String) newValue;
        pref.setSummary(res.getString(R.string.pref_enqueue_location_sum, options.get(newValStr)));
        return true;
    });
}
Also used : ArrayMap(androidx.collection.ArrayMap) Resources(android.content.res.Resources) ListPreference(androidx.preference.ListPreference)

Example 7 with ArrayMap

use of androidx.collection.ArrayMap in project AntennaPod by AntennaPod.

the class FeedDiscoverer method findLinks.

private Map<String, String> findLinks(Document document, String baseUrl) {
    Map<String, String> res = new ArrayMap<>();
    Elements links = document.head().getElementsByTag("link");
    for (Element link : links) {
        String rel = link.attr("rel");
        String href = link.attr("href");
        if (!TextUtils.isEmpty(href) && (rel.equals("alternate") || rel.equals("feed"))) {
            String type = link.attr("type");
            if (type.equals(MIME_RSS) || type.equals(MIME_ATOM)) {
                String title = link.attr("title");
                String processedUrl = processURL(baseUrl, href);
                if (processedUrl != null) {
                    res.put(processedUrl, (TextUtils.isEmpty(title)) ? href : title);
                }
            }
        }
    }
    return res;
}
Also used : Element(org.jsoup.nodes.Element) ArrayMap(androidx.collection.ArrayMap) Elements(org.jsoup.select.Elements)

Aggregations

ArrayMap (androidx.collection.ArrayMap)7 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Pair (androidx.core.util.Pair)1 ListPreference (androidx.preference.ListPreference)1 PocketHub (com.github.pockethub.android.PocketHub)1 GistFile (com.meisolsson.githubsdk.model.GistFile)1 Feed (de.danoeh.antennapod.model.feed.Feed)1 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)1 EpisodeAction (de.danoeh.antennapod.net.sync.model.EpisodeAction)1 Element (org.jsoup.nodes.Element)1 Elements (org.jsoup.select.Elements)1 Before (org.junit.Before)1