Search in sources :

Example 1 with PostImage

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

the class PostDetailsPresenter method handleGetOriginalCommentSuccess.

private void handleGetOriginalCommentSuccess(EditablePost comment) {
    getOriginalCommentSubscription.unsubscribe();
    editComment = new EditPost();
    editComment.setId(comment.getId());
    newComment = new NewPost();
    newComment.setImages(new ArrayList<>());
    newComment.setText(comment.getTextOriginal());
    int i = 0;
    for (PostImage image : comment.getImages()) {
        NewPostImage newPostImage = new NewPostImage();
        newPostImage.setImage(image.getId());
        newPostImage.setPosition(i);
        newComment.getImages().add(newPostImage);
        getViewState().createNewImageView();
        getViewState().updateNewImageView(image.getId());
        i++;
    }
    updateImageCommentButtonEnabled();
    updateSendCommentButtonEnabled();
    getViewState().showEditComment(comment);
}
Also used : PostImage(io.swagger.client.model.PostImage) NewPostImage(io.swagger.client.model.NewPostImage) NewPostImage(io.swagger.client.model.NewPostImage) NewPost(io.swagger.client.model.NewPost) EditPost(io.swagger.client.model.EditPost)

Example 2 with PostImage

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

the class CreatePostPresenter method handleGetOriginalPostSuccess.

private void handleGetOriginalPostSuccess(EditablePost post) {
    getOriginalPostSubscription.unsubscribe();
    editPost = new EditPost();
    editPost.setId(post.getId());
    this.post.setImages(new ArrayList<>());
    this.post.setText(post.getTextOriginal());
    int i = 0;
    for (PostImage image : post.getImages()) {
        NewPostImage newPostImage = new NewPostImage();
        newPostImage.setImage(image.getId());
        newPostImage.setPosition(i);
        this.post.getImages().add(newPostImage);
        getViewState().createNewImageView();
        getViewState().updateNewImageView(image.getId());
        i++;
    }
    updatePublishButtonEnabled();
    getViewState().setText(this.post.getText(), this.post.getText().length());
    getViewState().showProgressBar(false);
}
Also used : PostImage(io.swagger.client.model.PostImage) NewPostImage(io.swagger.client.model.NewPostImage) NewPostImage(io.swagger.client.model.NewPostImage) EditPost(io.swagger.client.model.EditPost)

Example 3 with PostImage

use of io.swagger.client.model.PostImage 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 4 with PostImage

use of io.swagger.client.model.PostImage 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 5 with PostImage

use of io.swagger.client.model.PostImage 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)

Aggregations

PostImage (io.swagger.client.model.PostImage)6 SpannableString (android.text.SpannableString)4 PostImageResize (io.swagger.client.model.PostImageResize)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 EditPost (io.swagger.client.model.EditPost)2 ImageQuality (io.swagger.client.model.ImageQuality)2 NewPostImage (io.swagger.client.model.NewPostImage)2 ArrayList (java.util.ArrayList)2 NewPost (io.swagger.client.model.NewPost)1