use of com.battlelancer.seriesguide.tmdbapi.TmdbTools2 in project SeriesGuide by UweTrottmann.
the class SgPicassoRequestHandler method load.
@Override
public Result load(Request request, int networkPolicy) throws IOException {
String scheme = request.uri.getScheme();
String host = request.uri.getHost();
if (host == null)
return null;
if (SCHEME_SHOW_TMDB.equals(scheme)) {
int showTmdbId = Integer.parseInt(host);
String language = request.uri.getQueryParameter(QUERY_LANGUAGE);
if (language == null || language.length() == 0) {
language = DisplaySettings.LANGUAGE_EN;
}
TvShow showDetails = new TmdbTools2().getShowDetails(showTmdbId, language, context);
if (showDetails != null) {
String url = ImageTools.tmdbOrTvdbPosterUrl(showDetails.poster_path, context, false);
if (url != null) {
return loadFromNetwork(Uri.parse(url), networkPolicy);
}
}
}
if (SCHEME_MOVIE_TMDB.equals(scheme)) {
int movieTmdbId = Integer.valueOf(host);
MovieTools movieTools = SgApp.getServicesComponent(context).movieTools();
Movie movieSummary = movieTools.getMovieSummary(movieTmdbId);
if (movieSummary != null && movieSummary.poster_path != null) {
final String imageUrl = TmdbSettings.getImageBaseUrl(context) + TmdbSettings.POSTER_SIZE_SPEC_W342 + movieSummary.poster_path;
return loadFromNetwork(Uri.parse(imageUrl), networkPolicy);
}
}
return null;
}
use of com.battlelancer.seriesguide.tmdbapi.TmdbTools2 in project SeriesGuide by UweTrottmann.
the class HexagonShowSync method mapLegacyShows.
/**
* Returns null on network error while looking up TMDB ID.
*/
@Nullable
private List<SgCloudShow> mapLegacyShows(List<Show> legacyShows) {
List<SgCloudShow> shows = new ArrayList<>();
for (Show legacyShow : legacyShows) {
Integer showTvdbId = legacyShow.getTvdbId();
if (showTvdbId == null || showTvdbId <= 0) {
continue;
}
Integer showTmdbIdOrNull = new TmdbTools2().findShowTmdbId(context, showTvdbId);
if (showTmdbIdOrNull == null) {
// Network error, abort.
return null;
}
// Only add if TMDB id found
if (showTmdbIdOrNull != -1) {
SgCloudShow show = new SgCloudShow();
show.setTmdbId(showTmdbIdOrNull);
show.setIsRemoved(legacyShow.getIsRemoved());
show.setIsFavorite(legacyShow.getIsFavorite());
show.setNotify(legacyShow.getNotify());
show.setIsHidden(legacyShow.getIsHidden());
show.setLanguage(legacyShow.getLanguage());
shows.add(show);
}
}
return shows;
}
Aggregations