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