use of io.swagger.client.model.ImageQuality in project android-client by GenesisVision.
the class SocialPostView method setImages.
private void setImages(Post post) {
if (post != null && post.getImages() != null && !post.getImages().isEmpty()) {
int pos = 0;
int col = 1;
int row = 1;
int newWidth;
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = 0;
if (isRepostMode) {
width = this.getWidth();
}
if (width == 0) {
width = size.x;
}
flexbox.removeAllViews();
ImageQuality requiredQuality = post.getImages().size() <= 3 ? ImageQuality.ORIGINAL : ImageQuality.LOW;
for (PostImage image : post.getImages()) {
String logoUrl = image.getResizes().get(image.getResizes().size() - 1).getLogoUrl();
for (PostImageResize resize : image.getResizes()) {
if (resize.getQuality().equals(requiredQuality)) {
logoUrl = resize.getLogoUrl();
break;
}
}
int maxImagesToAdd = post.getImages().size() < MAX_IMAGES ? post.getImages().size() : MAX_IMAGES;
if (post.getImages().size() > 1 && pos == Math.round(maxImagesToAdd / 2)) {
newWidth = (width - 10 * (Math.round(maxImagesToAdd / 2) - 1)) / pos;
setNewSize(row, newWidth);
col = 1;
row++;
}
if (pos == maxImagesToAdd - 1) {
int count = post.getImages().size() - pos;
if (count == 1) {
count = 0;
}
addNewPostImageView(logoUrl, pos, count, col, row, post.getId());
newWidth = (width - 10 * (maxImagesToAdd - Math.round(maxImagesToAdd / 2) - 1)) / (maxImagesToAdd - Math.round(maxImagesToAdd / 2));
setNewSize(row, newWidth);
break;
}
addNewPostImageView(logoUrl, pos, 0, col, row, post.getId());
col++;
pos++;
}
this.flexbox.setVisibility(View.VISIBLE);
} else {
this.flexbox.setVisibility(View.GONE);
}
}
use of io.swagger.client.model.ImageQuality in project android-client by GenesisVision.
the class SocialCommentView method setImages.
private void setImages(Post comment) {
if (comment.getImages() != null && !comment.getImages().isEmpty()) {
int pos = 0;
int col = 1;
int row = 1;
int newWidth = 100;
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
flexbox.removeAllViews();
ImageQuality requiredQuality = comment.getImages().size() <= 3 ? ImageQuality.ORIGINAL : ImageQuality.LOW;
for (PostImage image : comment.getImages()) {
String logoUrl = image.getResizes().get(image.getResizes().size() - 1).getLogoUrl();
for (PostImageResize resize : image.getResizes()) {
if (resize.getQuality().equals(requiredQuality)) {
logoUrl = resize.getLogoUrl();
break;
}
}
int maxImagesToAdd = comment.getImages().size() < MAX_IMAGES ? comment.getImages().size() : MAX_IMAGES;
if (comment.getImages().size() > 1 && pos == Math.round(maxImagesToAdd / 2)) {
newWidth = (int) ((size.x - 10 * (Math.round(maxImagesToAdd / 2) - 1)) / pos);
setNewSize(row, newWidth);
col = 1;
row++;
}
if (pos == maxImagesToAdd - 1) {
int count = comment.getImages().size() - pos;
if (count == 1) {
count = 0;
}
addNewPostImageView(logoUrl, pos, count, col, row, comment.getId());
newWidth = (int) ((size.x - 10 * (maxImagesToAdd - Math.round(maxImagesToAdd / 2) - 1)) / (maxImagesToAdd - Math.round(maxImagesToAdd / 2)));
setNewSize(row, newWidth);
break;
}
addNewPostImageView(logoUrl, pos, 0, col, row, comment.getId());
col++;
pos++;
}
this.flexbox.setVisibility(View.VISIBLE);
} else {
this.flexbox.setVisibility(View.GONE);
}
}
Aggregations