Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发现2.5.8 以下几个Bug 以及解决方案 #1496

Closed
PCopy opened this issue Jun 11, 2020 · 3 comments
Closed

发现2.5.8 以下几个Bug 以及解决方案 #1496

PCopy opened this issue Jun 11, 2020 · 3 comments

Comments

@PCopy
Copy link

PCopy commented Jun 11, 2020

picture_library\src\main\java\com\luck\picture\lib\adapter\PictureImageGridAdapter.java
混选模式下,判断图片选择长度不能够用 selectData.size() 例如我图片定义7张 视频定义3个 我选择了5张图片3个视频 在选择图片会提示我图片超过可选长度

新增方法如下

@PCopy
Copy link
Author

PCopy commented Jun 11, 2020

//原方法为

if (config.isWithVideoImage) {
            // isWithVideoImage mode
            int videoSize = 0;
            for (int i = 0; i < count; i++) {
                LocalMedia media = selectData.get(i);
                if (PictureMimeType.isHasVideo(media.getMimeType())) {
                    videoSize++;
                }
            }

            if (PictureMimeType.isHasVideo(image.getMimeType())) {
                if (config.maxVideoSelectNum <= 0) {
                    showPromptDialog(context.getString(R.string.picture_rule));
                    return;
                }

                if (getSelectedImageSize() >= config.maxSelectNum && !isChecked) {
                    showPromptDialog(context.getString(R.string.picture_message_max_num, config.maxSelectNum));
                    return;
                }

                if (videoSize >= config.maxVideoSelectNum && !isChecked) {
                    showPromptDialog(StringUtils.getMsg(context, image.getMimeType(), config.maxVideoSelectNum));
                    return;
                }

                if (!isChecked && config.videoMinSecond > 0 && image.getDuration() < config.videoMinSecond) {
                    showPromptDialog(context.getString(R.string.picture_choose_min_seconds, config.videoMinSecond / 1000));
                    return;
                }

                if (!isChecked && config.videoMaxSecond > 0 && image.getDuration() > config.videoMaxSecond) {
                    showPromptDialog(context.getString(R.string.picture_choose_max_seconds, config.videoMaxSecond / 1000));
                    return;
                }
            }

            if (PictureMimeType.isHasImage(image.getMimeType())) {
                if (getSelectedSize() >= config.maxSelectNum && !isChecked) {
                    showPromptDialog(context.getString(R.string.picture_message_max_num, config.maxSelectNum));
                    return;
                }
            }

        }

//修改方法为

if (config.isWithVideoImage) {
            // isWithVideoImage mode
            int videoSize = 0;
            int imageSize = 0;
            for (int i = 0; i < count; i++) {
                LocalMedia media = selectData.get(i);
                if (PictureMimeType.isHasVideo(media.getMimeType())) {
                    videoSize++;
                }
                if (PictureMimeType.isHasImage(media.getMimeType())) {
                    imageSize++;
                }
            }

            if (PictureMimeType.isHasVideo(image.getMimeType())) {
                if (config.maxVideoSelectNum <= 0) {
                    showPromptDialog(context.getString(R.string.picture_rule));
                    return;
                }

                if (imageSize >= config.maxSelectNum && !isChecked) {
                    showPromptDialog(context.getString(R.string.picture_message_max_num, config.maxSelectNum));
                    return;
                }

                if (videoSize >= config.maxVideoSelectNum && !isChecked) {
                    showPromptDialog(StringUtils.getMsg(context, image.getMimeType(), config.maxVideoSelectNum));
                    return;
                }

                if (!isChecked && config.videoMinSecond > 0 && image.getDuration() < config.videoMinSecond) {
                    showPromptDialog(context.getString(R.string.picture_choose_min_seconds, config.videoMinSecond / 1000));
                    return;
                }

                if (!isChecked && config.videoMaxSecond > 0 && image.getDuration() > config.videoMaxSecond) {
                    showPromptDialog(context.getString(R.string.picture_choose_max_seconds, config.videoMaxSecond / 1000));
                    return;
                }
            }

            if (PictureMimeType.isHasImage(image.getMimeType())) {
                if (imageSize >= config.maxSelectNum && !isChecked) {
                    showPromptDialog(context.getString(R.string.picture_message_max_num, config.maxSelectNum));
                    return;
                }
            }

        }

@PCopy
Copy link
Author

PCopy commented Jun 11, 2020

预览界面选择同理

@liudaohong
Copy link

直接 提交等修改吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants