use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.
the class PurchaseDataSource method getLatestEntitlementRecordBySku.
/**
* Return the entitlement for given user and sku.
*/
@Nullable
public PurchaseRecord getLatestEntitlementRecordBySku(String userId, String sku) {
Timber.d("getEntitlementRecordBySku: userId (%s), sku (%s)", userId, sku);
final String where = AmazonBillingSQLiteHelper.COLUMN_USER_ID + " = ? and " + AmazonBillingSQLiteHelper.COLUMN_SKU + " = ?";
final Cursor cursor = database.query(AmazonBillingSQLiteHelper.TABLE_PURCHASES, allColumns, where, new String[] { userId, sku }, null, null, AmazonBillingSQLiteHelper.COLUMN_DATE_FROM + " desc ");
final PurchaseRecord result;
cursor.moveToFirst();
if (cursor.isAfterLast()) {
result = null;
Timber.d("getEntitlementRecordBySku: no record found ");
} else {
result = cursorToPurchaseRecord(cursor);
Timber.d("getEntitlementRecordBySku: found ");
}
cursor.close();
return result;
}
use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.
the class HexagonTools method buildAccountService.
/**
* Creates and returns a new instance for this hexagon service or null if not signed in.
*/
@Nullable
public synchronized Account buildAccountService() {
GoogleAccountCredential credential = getAccountCredential(true);
if (credential.getSelectedAccount() == null) {
return null;
}
Account.Builder builder = new Account.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential);
return CloudEndpointUtils.updateBuilder(app, builder).build();
}
use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.
the class TvdbTools method searchSeries.
@Nullable
public List<SearchResult> searchSeries(@NonNull String query, @Nullable final String language) throws TvdbException {
retrofit2.Response<SeriesResultsResponse> response;
try {
response = tvdbSearch.get().series(query, null, null, language).execute();
} catch (IOException e) {
throw new TvdbException("searchSeries: " + e.getMessage(), e);
}
if (response.code() == 404) {
// API returns 404 if there are no search results
return null;
}
ensureSuccessfulResponse(response.raw(), "searchSeries: ");
List<Series> tvdbResults = response.body().data;
if (tvdbResults == null || tvdbResults.size() == 0) {
// no results from tvdb
return null;
}
// parse into our data format
List<SearchResult> results = new ArrayList<>(tvdbResults.size());
for (Series tvdbResult : tvdbResults) {
SearchResult result = new SearchResult();
result.tvdbid = tvdbResult.id;
result.title = tvdbResult.seriesName;
result.overview = tvdbResult.overview;
result.language = language;
results.add(result);
}
return results;
}
use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.
the class AboutSettingsFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_about, container, false);
unbinder = ButterKnife.bind(this, v);
// display version number and database version
textVersion.setText(Utils.getVersionString(getActivity()));
buttonWebsite.setOnClickListener(urlButtonClickListener);
buttonTvdbTerms.setOnClickListener(urlButtonClickListener);
buttonCreativeCommons.setOnClickListener(urlButtonClickListener);
buttonTmdbTerms.setOnClickListener(urlButtonClickListener);
buttonTmdbApiTerms.setOnClickListener(urlButtonClickListener);
buttonTraktTerms.setOnClickListener(urlButtonClickListener);
buttonCredits.setOnClickListener(urlButtonClickListener);
return v;
}
use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.
the class LanguageTools method getMovieLanguageData.
/**
* Returns the string representation and index of the given two letter ISO 639-1 language code
* plus an extra ISO-3166-1 region tag used by TMDB currently set by {@link
* DisplaySettings#getMoviesLanguage(Context)}.
*/
@Nullable
public static LanguageData getMovieLanguageData(Context context) {
String languageCodeCurrent = DisplaySettings.getMoviesLanguage(context);
String[] languageCodes = context.getResources().getStringArray(R.array.languageCodesMovies);
for (int i = 0; i < languageCodes.length; i++) {
String languageCode = languageCodes[i];
if (languageCode.equals(languageCodeCurrent)) {
String languageDisplayName = new Locale(languageCode.substring(0, 2), languageCode.substring(3)).getDisplayName();
return new LanguageData(i, languageCode, languageDisplayName);
}
}
return null;
}
Aggregations