public static void showPicasaGallery(Long id, String name) {
    notFoundIfNull(id);
    PicasaGallery gallery = PicasaGallery.findById(id);
    notFoundIfNull(gallery);

    PicasawebService service = new PicasawebService("portfolio");
    List<PhotoEntry> photoEntries = Collections.emptyList();
    try {
      java.net.URL feedUrl = new java.net.URL(gallery.getFeedUrl());

      AlbumFeed feed = service.getFeed(feedUrl, AlbumFeed.class);
      photoEntries = feed.getPhotoEntries();
    } catch (MalformedURLException e) {
      Logger.error("Service URL for Picasa is not well formed");
      e.printStackTrace();
    } catch (IOException e) {
      Logger.error("Error I/O while communicating with Picasa Service");
      e.printStackTrace();
    } catch (ServiceException e) {
      Logger.error("Picasa service error");
      e.printStackTrace();
    }

    List<ImageView> images = new ArrayList<ImageView>();
    for (PhotoEntry entry : photoEntries) {
      ImageView image = new ImageView();
      // We take the largest
      image.thumbnail =
          entry.getMediaThumbnails().get(entry.getMediaThumbnails().size() - 1).getUrl();
      image.url = entry.getMediaContents().get(0).getUrl();
      images.add(image);
    }

    render("Application/gallery.html", images, gallery);
  }
示例#2
0
文件: UserApp.java 项目: bluemir/hive
  private static void sortByLastPushedDateAndName(List<Project> projects) {
    Collections.sort(
        projects,
        new Comparator<Project>() {
          @Override
          public int compare(Project p1, Project p2) {
            int compareLastPushedDate;
            if (p1.lastPushedDate == null && p2.lastPushedDate == null) {
              return p1.name.compareTo(p2.name);
            }

            if (p1.lastPushedDate == null) {
              return 1;
            } else if (p2.lastPushedDate == null) {
              return -1;
            }

            compareLastPushedDate = p2.lastPushedDate.compareTo(p1.lastPushedDate);
            if (compareLastPushedDate == 0) {
              return p1.name.compareTo(p2.name);
            }
            return compareLastPushedDate;
          }
        });
  }
示例#3
0
  public static List sortByValue(Map map) {
    List list = new LinkedList(map.entrySet());
    Collections.sort(
        list,
        new Comparator() {
          public int compare(Object o1, Object o2) {
            return ((Comparable) ((Map.Entry) (o1)).getValue())
                .compareTo(((Map.Entry) (o2)).getValue());
          }
        });

    Map result = new LinkedHashMap();
    for (Iterator it = list.iterator(); it.hasNext(); ) {
      Map.Entry entry = (Map.Entry) it.next();
      result.put(entry.getKey(), entry.getValue());
    }
    Collections.reverse(list);
    return list;
  }
示例#4
0
文件: UserApp.java 项目: bluemir/hive
  private static void sortDatum(
      List<Posting> postings,
      List<Issue> issues,
      List<PullRequest> pullRequests,
      List<Milestone> milestones) {

    Collections.sort(
        issues,
        new Comparator<Issue>() {
          @Override
          public int compare(Issue i1, Issue i2) {
            return i2.createdDate.compareTo(i1.createdDate);
          }
        });

    Collections.sort(
        postings,
        new Comparator<Posting>() {
          @Override
          public int compare(Posting p1, Posting p2) {
            return p2.createdDate.compareTo(p1.createdDate);
          }
        });

    Collections.sort(
        pullRequests,
        new Comparator<PullRequest>() {
          @Override
          public int compare(PullRequest p1, PullRequest p2) {
            return p2.created.compareTo(p1.created);
          }
        });

    Collections.sort(
        milestones,
        new Comparator<Milestone>() {
          @Override
          public int compare(Milestone m1, Milestone m2) {
            return m2.title.compareTo(m1.title);
          }
        });
  }