private void loadYouTubeThumbnails(Viewpoint viewpoint, ExternalAccountView accountView) { ExternalAccount account = accountView.getExternalAccount(); if (account.getAccountType() != ExternalAccountType.YOUTUBE) throw new IllegalArgumentException("should be a YouTube account here"); if (account.getSentiment() != Sentiment.LOVE) throw new IllegalArgumentException("YouTube account is unloved =("); if (account.getHandle() == null) return; try { youTubeUpdater.getCachedStatus(account); } catch (NotFoundException e) { logger.debug("No cached YouTube status for {}", account); return; } List<? extends YouTubeVideo> videos = youTubeVideosCache.getSync(account.getHandle()); if (videos.isEmpty()) { logger.debug("Empty list of videos for {}", account); return; } accountView.setThumbnailsData( TypeUtils.castList(Thumbnail.class, videos), videos.size(), videos.get(0).getThumbnailWidth(), videos.get(0).getThumbnailHeight()); }
private void loadFlickrThumbnails(Viewpoint viewpoint, ExternalAccountView accountView) { ExternalAccount account = accountView.getExternalAccount(); if (account.getAccountType() != ExternalAccountType.FLICKR) throw new IllegalArgumentException("should be a flickr account here"); if (account.getSentiment() != Sentiment.LOVE) throw new IllegalArgumentException("Flickr account is unloved"); if (account.getHandle() == null) return; FlickrPhotosView photos = flickrUserPhotosCache.getSync(account.getHandle()); if (photos == null) { logger.debug("No public photos for {}", account); return; } accountView.setThumbnailsData( TypeUtils.castList(Thumbnail.class, photos.getPhotos()), photos.getTotal(), FlickrPhotoSize.SMALL_SQUARE.getPixels(), FlickrPhotoSize.SMALL_SQUARE.getPixels()); }