Search in sources :

Example 1 with PostImageResize

use of io.swagger.client.model.PostImageResize 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);
    }
}
Also used : ImageQuality(io.swagger.client.model.ImageQuality) PostImage(io.swagger.client.model.PostImage) Point(android.graphics.Point) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint) Point(android.graphics.Point) PostImageResize(io.swagger.client.model.PostImageResize) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 2 with PostImageResize

use of io.swagger.client.model.PostImageResize in project android-client by GenesisVision.

the class SocialPostView method onPostImageClicked.

@Override
public void onPostImageClicked(ImageView imageView, String imageUrl, int position, UUID postId) {
    if (post != null && post.getId().equals(postId)) {
        ArrayList<String> images = new ArrayList<>();
        for (PostImage image : post.getImages()) {
            for (PostImageResize resize : image.getResizes()) {
                if (resize.getQuality().equals(ImageQuality.ORIGINAL)) {
                    images.add(resize.getLogoUrl());
                    break;
                }
            }
        }
        ImageViewerOverlayView overlayView = new ImageViewerOverlayView(getContext());
        overlayView.setImagesCount(images.size());
        StfalconImageViewer imageViewer = new StfalconImageViewer.Builder<>(getContext(), images, (loadingImageView, image) -> Glide.with(getContext()).load(image).into(loadingImageView)).withStartPosition(position).withHiddenStatusBar(false).withTransitionFrom(imageView).withOverlayView(overlayView).withImageChangeListener(overlayView).show();
        overlayView.setImageViewer(imageViewer);
    }
}
Also used : PostImage(io.swagger.client.model.PostImage) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) StfalconImageViewer(com.stfalcon.imageviewer.StfalconImageViewer) PostImageResize(io.swagger.client.model.PostImageResize)

Example 3 with PostImageResize

use of io.swagger.client.model.PostImageResize 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);
    }
}
Also used : ImageQuality(io.swagger.client.model.ImageQuality) PostImage(io.swagger.client.model.PostImage) Point(android.graphics.Point) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint) Point(android.graphics.Point) PostImageResize(io.swagger.client.model.PostImageResize) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 4 with PostImageResize

use of io.swagger.client.model.PostImageResize in project android-client by GenesisVision.

the class MediaPostDetailsActivity method setImage.

private void setImage(MediaPost post) {
    String logoUrl = post.getImage().getResizes().get(post.getImage().getResizes().size() - 1).getLogoUrl();
    for (PostImageResize resize : post.getImage().getResizes()) {
        if (resize.getQuality().equals(ImageQuality.HIGH)) {
            logoUrl = resize.getLogoUrl();
        }
    }
    this.image.setImageURI(ImageUtils.getImageUri(logoUrl));
    this.image.setVisibility(logoUrl == null || logoUrl.isEmpty() ? View.GONE : View.VISIBLE);
}
Also used : PostImageResize(io.swagger.client.model.PostImageResize)

Example 5 with PostImageResize

use of io.swagger.client.model.PostImageResize in project android-client by GenesisVision.

the class SocialCommentView method onPostImageClicked.

@Override
public void onPostImageClicked(ImageView imageView, String imageUrl, int position, UUID postId) {
    if (comment != null && comment.getId().equals(postId)) {
        ArrayList<String> images = new ArrayList<>();
        for (PostImage image : comment.getImages()) {
            for (PostImageResize resize : image.getResizes()) {
                if (resize.getQuality().equals(ImageQuality.ORIGINAL)) {
                    images.add(resize.getLogoUrl());
                    break;
                }
            }
        }
        ImageViewerOverlayView overlayView = new ImageViewerOverlayView(getContext());
        overlayView.setImagesCount(images.size());
        StfalconImageViewer imageViewer = new StfalconImageViewer.Builder<>(getContext(), images, (loadingImageView, image) -> Glide.with(getContext()).load(image).into(loadingImageView)).withStartPosition(position).withHiddenStatusBar(false).withTransitionFrom(imageView).withOverlayView(overlayView).withImageChangeListener(overlayView).show();
        overlayView.setImageViewer(imageViewer);
    }
}
Also used : PostImage(io.swagger.client.model.PostImage) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) StfalconImageViewer(com.stfalcon.imageviewer.StfalconImageViewer) PostImageResize(io.swagger.client.model.PostImageResize)

Aggregations

PostImageResize (io.swagger.client.model.PostImageResize)6 SpannableString (android.text.SpannableString)4 PostImage (io.swagger.client.model.PostImage)4 Point (android.graphics.Point)2 TextPaint (android.text.TextPaint)2 Display (android.view.Display)2 WindowManager (android.view.WindowManager)2 StfalconImageViewer (com.stfalcon.imageviewer.StfalconImageViewer)2 ImageQuality (io.swagger.client.model.ImageQuality)2 ArrayList (java.util.ArrayList)2