Search in sources :

Example 1 with SparseArrayCompat

use of android.support.v4.util.SparseArrayCompat in project SeriesGuide by UweTrottmann.

the class ShowTools method getShowTvdbIdsAndPosters.

/**
     * Returns a set of the TVDb ids of all shows in the local database mapped to their poster path
     * (null if there is no poster).
     *
     * @return null if there was an error, empty list if there are no shows.
     */
@Nullable
public static SparseArrayCompat<String> getShowTvdbIdsAndPosters(Context context) {
    SparseArrayCompat<String> existingShows = new SparseArrayCompat<>();
    Cursor shows = context.getContentResolver().query(SeriesGuideContract.Shows.CONTENT_URI, new String[] { SeriesGuideContract.Shows._ID, SeriesGuideContract.Shows.POSTER }, null, null, null);
    if (shows == null) {
        return null;
    }
    while (shows.moveToNext()) {
        existingShows.put(shows.getInt(0), shows.getString(1));
    }
    shows.close();
    return existingShows;
}
Also used : Cursor(android.database.Cursor) SparseArrayCompat(android.support.v4.util.SparseArrayCompat) Nullable(android.support.annotation.Nullable)

Aggregations

Cursor (android.database.Cursor)1 Nullable (android.support.annotation.Nullable)1 SparseArrayCompat (android.support.v4.util.SparseArrayCompat)1