use of com.abewy.android.apps.klyph.core.fql.Media.Image in project Klyph by jonathangerbaud.
the class PhotoAlbumAdapter method mergeViewWithData.
@Override
protected void mergeViewWithData(View view, GraphObject data) {
super.mergeViewWithData(view, data);
final RatioImageView rImageView = (RatioImageView) view;
Photo photo = (Photo) data;
Collections.sort(photo.getImages(), new Comparator<Image>() {
@Override
public int compare(Image lhs, Image rhs) {
if (lhs.getWidth() > rhs.getWidth())
return 1;
else if (lhs.getWidth() < rhs.getWidth())
return -1;
return 0;
}
});
Image selectedImage = photo.getImages().get(0);
rImageView.setImageSize(selectedImage.getWidth(), selectedImage.getHeight());
if (placeHolder == -1)
placeHolder = AttrUtil.getResourceId(getContext(view), R.attr.squarePlaceHolderIcon);
loadImage(rImageView, selectedImage.getSrc(), placeHolder, data);
}
use of com.abewy.android.apps.klyph.core.fql.Media.Image in project Klyph by jonathangerbaud.
the class StreamMedia method loadMedia.
protected void loadMedia(ImageView imageView, Media media, Stream stream, boolean setDimensions) {
int width = 0;
int height = 0;
String source = "";
if (media.isVideo()) {
if (media.isFacebookVideo()) {
Format selectedFormat = null;
for (Format format : media.getVideo().getFormat()) {
if (format.getWidth() > getMaxWidth()) {
selectedFormat = format;
break;
}
}
if (selectedFormat == null) {
selectedFormat = media.getVideo().getFormat().get(media.getVideo().getFormat().size() - 1);
}
width = selectedFormat.getWidth();
height = selectedFormat.getHeight();
source = selectedFormat.getPicture();
} else // Youtube video
if (media.isYoutubeVideo()) {
width = 480;
height = 360;
source = media.getYoutubeThumbnail();
} else // Dailymotion video
if (media.isDailymotionVideo()) {
width = 427;
height = 240;
source = media.getDailymotionThumbnail();
} else if (media.isVimeoVideo()) {
width = 640;
height = 476;
source = media.getVimeoThumbnail();
} else {
width = -1;
height = -1;
source = media.getHref();
Log.d("StreamMedia", "unknownType " + media.getHref());
}
} else {
if (media.getPhoto().getImages().size() > 0) {
/*List<Image> images = media.getPhoto().getImages();
Image selectedImage = images.get(0);
for (int i = 1, n = images.size(); i < n; i++)
{
Image image = images.get(i);
if (image.getWidth() < getMaxWidth())
{
break;
}
selectedImage = image;
}*/
Image selectedImage = null;
for (Image image : media.getPhoto().getImages()) {
if (image.getWidth() > getMaxWidth()) {
selectedImage = image;
break;
}
}
if (selectedImage == null) {
selectedImage = media.getPhoto().getImages().get(media.getPhoto().getImages().size() - 1);
if (media.getPhoto().getWidth() > getMaxWidth()) {
/*
* int imageDifference = maxWidth -
* selectedImage.getWidth();
* int mediaDifference = media.getPhoto().getWidth() -
* maxWidth;
*
* if (imageDifference < mediaDifference)
* {
* width = selectedImage.getWidth();
* height = selectedImage.getHeight();
* source = selectedImage.getSrc();
* }
* else
* {
*/
width = media.getPhoto().getWidth();
height = media.getPhoto().getHeight();
source = getSource(media.getSrc());
// }
} else {
if (media.getPhoto().getWidth() > selectedImage.getWidth()) {
width = media.getPhoto().getWidth();
height = media.getPhoto().getHeight();
source = getSource(media.getSrc());
} else {
width = selectedImage.getWidth();
height = selectedImage.getHeight();
source = selectedImage.getSrc();
}
}
} else {
width = selectedImage.getWidth();
height = selectedImage.getHeight();
source = selectedImage.getSrc();
}
} else {
width = media.getPhoto().getWidth();
height = media.getPhoto().getHeight();
source = getSource(media.getSrc());
}
}
if (setDimensions == true) {
RatioImageView ratioImageView = (RatioImageView) imageView;
ratioImageView.setImageSize(width, height);
}
loadImage(imageView, source, stream);
}
Aggregations