Search in sources :

Example 16 with Nullable

use of android.support.annotation.Nullable 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)

Example 17 with Nullable

use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.

the class ShowTools method getShowTvdbIdsAsSet.

/**
     * Returns a set of the TVDb ids of all shows in the local database.
     *
     * @return null if there was an error, empty list if there are no shows.
     */
@Nullable
public static HashSet<Integer> getShowTvdbIdsAsSet(Context context) {
    HashSet<Integer> existingShows = new HashSet<>();
    Cursor shows = context.getContentResolver().query(SeriesGuideContract.Shows.CONTENT_URI, new String[] { SeriesGuideContract.Shows._ID }, null, null, null);
    if (shows == null) {
        return null;
    }
    while (shows.moveToNext()) {
        existingShows.add(shows.getInt(0));
    }
    shows.close();
    return existingShows;
}
Also used : Cursor(android.database.Cursor) HashSet(java.util.HashSet) Nullable(android.support.annotation.Nullable)

Example 18 with Nullable

use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.

the class ListsTools method getListItems.

@Nullable
private static List<SgListItem> getListItems(Context context, String listId) {
    SELECTION_ARG[0] = listId;
    Cursor query = context.getContentResolver().query(SeriesGuideContract.ListItems.CONTENT_URI, Query.PROJECTION_LIST_ITEMS, SeriesGuideContract.ListItems.SELECTION_LIST, SELECTION_ARG, null);
    if (query == null) {
        // query failed
        return null;
    }
    int itemCount = query.getCount();
    if (itemCount == 0) {
        query.close();
        Timber.d("getListItems: no lists to upload.");
        // no items in this list
        return null;
    }
    List<SgListItem> items = new ArrayList<>(itemCount);
    while (query.moveToNext()) {
        SgListItem item = new SgListItem();
        item.setListItemId(query.getString(Query.LIST_ITEM_ID));
        items.add(item);
    }
    query.close();
    return items;
}
Also used : SgListItem(com.uwetrottmann.seriesguide.backend.lists.model.SgListItem) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) SuppressLint(android.annotation.SuppressLint) Nullable(android.support.annotation.Nullable)

Example 19 with Nullable

use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.

the class RateEpisodeTask method buildTraktSyncItems.

@Nullable
@Override
protected SyncItems buildTraktSyncItems() {
    int season = -1;
    int episode = -1;
    int showTvdbId = -1;
    Cursor query = getContext().getContentResolver().query(SeriesGuideContract.Episodes.buildEpisodeUri(episodeTvdbId), new String[] { SeriesGuideContract.Episodes.SEASON, SeriesGuideContract.Episodes.NUMBER, SeriesGuideContract.Shows.REF_SHOW_ID }, null, null, null);
    if (query != null) {
        if (query.moveToFirst()) {
            season = query.getInt(0);
            episode = query.getInt(1);
            showTvdbId = query.getInt(2);
        }
        query.close();
    }
    if (season == -1 || episode == -1 || showTvdbId == -1) {
        return null;
    }
    return new SyncItems().shows(new SyncShow().id(ShowIds.tvdb(showTvdbId)).seasons(new SyncSeason().number(season).episodes(new SyncEpisode().number(episode).rating(getRating()))));
}
Also used : SyncEpisode(com.uwetrottmann.trakt5.entities.SyncEpisode) SyncItems(com.uwetrottmann.trakt5.entities.SyncItems) SyncShow(com.uwetrottmann.trakt5.entities.SyncShow) Cursor(android.database.Cursor) SyncSeason(com.uwetrottmann.trakt5.entities.SyncSeason) Nullable(android.support.annotation.Nullable)

Example 20 with Nullable

use of android.support.annotation.Nullable in project walle by Meituan-Dianping.

the class WalleChannelReader method getApkPath.

@Nullable
private static String getApkPath(@NonNull final Context context) {
    String apkPath = null;
    try {
        final ApplicationInfo applicationInfo = context.getApplicationInfo();
        if (applicationInfo == null) {
            return null;
        }
        apkPath = applicationInfo.sourceDir;
    } catch (Throwable e) {
    }
    return apkPath;
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)477 View (android.view.View)266 TextView (android.widget.TextView)131 RecyclerView (android.support.v7.widget.RecyclerView)70 ImageView (android.widget.ImageView)41 IOException (java.io.IOException)32 Intent (android.content.Intent)30 Bundle (android.os.Bundle)30 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)28 ViewGroup (android.view.ViewGroup)27 Uri (android.net.Uri)25 BindView (butterknife.BindView)25 ArrayList (java.util.ArrayList)25 Cursor (android.database.Cursor)23 File (java.io.File)22 AdapterView (android.widget.AdapterView)16 Bitmap (android.graphics.Bitmap)15 Context (android.content.Context)14 Drawable (android.graphics.drawable.Drawable)13 EditText (android.widget.EditText)13