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

选中 单选,且 设置 单选时,点击item直接回调 出现问题 #132

Open
smileToWxm opened this issue Nov 4, 2021 · 0 comments

Comments

@smileToWxm
Copy link

smileToWxm commented Nov 4, 2021

在 setSelectMode 为 SelectMode.MODE_SINGLE,且 setSinglePickWithAutoComplete 为true的情况下, 在图片选择完跳转到自定义页面时,此时点击 返回 再点击其他列表的item 会提示 只能选一个视频。
查看了下源码 发现在 PickerItemDisableCode的 getItemDisableCode() 里面 PickerItemDisableCode.DISABLE_VIDEO_ONLY_SINGLE_PICK 这个参数 判断有漏洞,缺少了 !selectConfig.isSinglePickAutoComplete()这个判断,我加上就可以了 !

这里 贴出修改后的代码

public static int getItemDisableCode(ImageItem imageItem, BaseSelectConfig selectConfig,
ArrayList selectList,
boolean isContainsThisItem) {
boolean isItemEnable = true;
int disableCode = PickerItemDisableCode.NORMAL;

    //如果在屏蔽列表中,代表不可选择
    if (selectConfig.isShieldItem(imageItem)) {
        isItemEnable = false;
        disableCode = PickerItemDisableCode.DISABLE_IN_SHIELD;
    }

    //如果是视频item
    if (imageItem.isVideo()) {
        //如果只能选择图片和视频类型一种,并且当前已经选择了图片,则该视频不可以选中
        if (isItemEnable
                && selectConfig.isSinglePickImageOrVideoType()
                && selectedFirstItemIsImage(selectList)) {
            isItemEnable = false;
            disableCode = PickerItemDisableCode.DISABLE_ONLY_SELECT_IMAGE;
        }
        //视频时长不符合选择条件
        else if (isItemEnable
                && imageItem.duration > selectConfig.getMaxVideoDuration()) {
            isItemEnable = false;
            disableCode = PickerItemDisableCode.DISABLE_VIDEO_OVER_MAX_DURATION;
        } else if (isItemEnable
                && imageItem.duration < selectConfig.getMinVideoDuration()) {
            isItemEnable = false;
            disableCode = PickerItemDisableCode.DISABLE_VIDEO_LESS_MIN_DURATION;
        }
        //如果视频只能单选并且已经选过视频
        else if (isItemEnable
                && selectConfig.isVideoSinglePick()
          /***************************************        新增该判断      ***************************************/
                && !selectConfig.isSinglePickAutoComplete()
                && isSelectedListContainsVideo(selectList)
                && !isContainsThisItem) {
            isItemEnable = false;
            disableCode = PickerItemDisableCode.DISABLE_VIDEO_ONLY_SINGLE_PICK;
        }
    }
    //如果是图片item
    else {
        //如果只能选择图片和视频类型一种,并且当前已经选择了视频,则该图片不可以选中
        if (selectConfig.isSinglePickImageOrVideoType()
                && selectedFirstItemIsVideo(selectList)) {
            isItemEnable = false;
            disableCode = PickerItemDisableCode.DISABLE_ONLY_SELECT_VIDEO;
        }
    }

    //已经超过最大选中数量
    if (isItemEnable && hasSelectedList(selectList) && selectList.size() >= selectConfig.getMaxCount()
            && !isContainsThisItem) {
        disableCode = PickerItemDisableCode.DISABLE_OVER_MAX_COUNT;
    }

    return disableCode;
}
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

1 participant