Package org.brickred.socialauth

Examples of org.brickred.socialauth.Photo


    if (root != null) {
      NodeList photoList = root.getElementsByTagName("entry");
      if (photoList != null && photoList.getLength() > 0) {
        LOG.info("Found photos : " + photoList.getLength());
        for (int i = 0; i < photoList.getLength(); i++) {
          Photo photo = new Photo();
          Element pl = (Element) photoList.item(i);

          NodeList pid = pl.getElementsByTagNameNS(ALBUM_NAMESPACE,
              "id");
          String photoId = XMLParseUtil.getElementData(pid.item(0));
          photo.setId(photoId);

          photo.setTitle(XMLParseUtil.getElementData(pl, "title"));

          NodeList mediaGroup = pl.getElementsByTagNameNS(
              MEDIA_NAMESPACE, "group");
          String urlLarge = null;
          String urlMedium = null;
          String urlSmall = null;
          String urlThumb = null;
          int width = 0;

          if (mediaGroup != null && mediaGroup.getLength() > 0) {
            Element el = (Element) mediaGroup.item(0);
            if (el != null) {
              NodeList content = el.getElementsByTagNameNS(
                  MEDIA_NAMESPACE, "content");
              if (content != null) {
                Element cl = (Element) content.item(0);
                if (cl != null) {
                  urlLarge = cl.getAttribute("url");
                }
              }

              NodeList thumbnail = el.getElementsByTagNameNS(
                  MEDIA_NAMESPACE, "thumbnail");
              if (thumbnail != null && thumbnail.getLength() > 0) {
                for (int k = 0; k < thumbnail.getLength(); k++) {
                  Element thumb = (Element) thumbnail.item(k);
                  if (thumb != null) {
                    width = Integer.parseInt(thumb
                        .getAttribute("width"));
                    if (width == 288) {
                      urlMedium = thumb
                          .getAttribute("url");
                    } else if (width == 144) {
                      urlSmall = thumb
                          .getAttribute("url");
                    } else if (width == 72) {
                      urlThumb = thumb
                          .getAttribute("url");
                    }
                  }
                }
              }
            }
          }
          photo.setLargeImage(urlLarge);
          photo.setMediumImage(urlMedium);
          photo.setSmallImage(urlSmall);
          photo.setThumbImage(urlThumb);

          photos.add(photo);
        }
      } else {
        LOG.info("No photos were obtained from : " + PHOTOS_URL);
View Full Code Here


    JSONObject resp = new JSONObject(respStr);
    JSONArray data = resp.getJSONArray("data");
    LOG.debug("Photos count : " + data.length());
    List<Photo> photos = new ArrayList<Photo>();
    for (int i = 0; i < data.length(); i++) {
      Photo photo = new Photo();
      JSONObject obj = data.getJSONObject(i);
      photo.setId(obj.getString("id"));
      if (obj.has("name")) {
        photo.setTitle(obj.getString("name"));
      }
      if (obj.has("link")) {
        photo.setLink(obj.getString("link"));
      }
      if (obj.has("picture")) {
        photo.setThumbImage(obj.getString("picture"));
      }
      JSONArray images = obj.getJSONArray("images");
      for (int k = 0; k < images.length(); k++) {
        JSONObject img = images.getJSONObject(k);
        int ht = 0;
        int wt = 0;
        if (img.has("height")) {
          ht = img.getInt("height");
        }
        if (img.has("width")) {
          wt = img.getInt("width");
        }
        if (ht == 600 || wt == 600) {
          photo.setLargeImage(img.getString("source"));
        } else if (ht == 480 || wt == 480) {
          photo.setMediumImage(img.getString("source"));
        } else if (ht == 320 || wt == 320) {
          photo.setSmallImage(img.getString("source"));
        }
      }
      photos.add(photo);
    }
    return photos;
View Full Code Here

                  album.setCoverPhoto(userObj.getString(
                      "profile_image_url").replaceAll(
                      "_normal", "_reasonably_small"));
                  albums.add(album);
                }
                Photo photo = new Photo();
                String photoURL = mediaObj
                    .getString("media_url");
                photo.setThumbImage(photoURL + ":thumb");
                photo.setSmallImage(photoURL + ":small");
                photo.setMediumImage(photoURL);
                photo.setLargeImage(photoURL + ":large");
                if (jobj.has("text")) {
                  photo.setTitle(jobj.getString("text"));
                }
                if (mediaObj.has("id_str")) {
                  photo.setId(mediaObj.getString("id_str"));
                }
                if (mediaObj.has("expanded_url")) {
                  photo.setLink(mediaObj
                      .getString("expanded_url"));
                }
                if (jobj.has("retweet_count")) {
                  Map<String, String> map = new HashMap<String, String>();
                  map.put("retweet_count", String
                      .valueOf(jobj
                          .getInt("retweet_count")));
                  photo.setMetaData(map);
                }
                photos.add(photo);
              }
            }
          }
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.Photo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.