コード例 #1
0
  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());
  }
コード例 #2
0
  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());
  }
コード例 #3
0
  private void loadThumbnails(Viewpoint viewpoint, ExternalAccountView externalAccountView) {
    ExternalAccount externalAccount = externalAccountView.getExternalAccount();
    ExternalAccountType type = externalAccount.getAccountType();
    // you only have thumbnails for accounts you like
    if (externalAccount.getSentiment() != Sentiment.LOVE) return;

    switch (type) {
      case FLICKR:
        loadFlickrThumbnails(viewpoint, externalAccountView);
        break;
      case YOUTUBE:
        loadYouTubeThumbnails(viewpoint, externalAccountView);
        break;
      default:
        // most accounts lack thumbnails
        break;
    }
  }