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