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

cancelTextView怎样在图片单选&点击图片直接返回的模式下隐藏 #2960

Open
haohe0627 opened this issue Dec 11, 2024 · 0 comments

Comments

@haohe0627
Copy link

haohe0627 commented Dec 11, 2024

Current use version?

当前使用的版本是多少?

3.10.6

Will this problem occur in demo?

Demo能否复现这问题?

可以

Describe the problem or provide an error log?

描述问题或提供错误log?

我想实现TitleBar的cancelTextView在图片单选&点击图片直接返回的模式下隐藏,于是有下面的写法:
val cusTitleStyle = TitleBarStyle().apply {
            isHideCancelButton = true
        }

        val selectorStyle = PictureSelectorStyle().apply {
            titleBarStyle = cusTitleStyle
        }
        
        PictureSelector.create(context)
            .openGallery(SelectMimeType.ofImage())
            .setFilterMaxFileSize(ISelector.GLOBAL_MAX_SIZE_KB.toLong())
            .setSelectorUIStyle(selectorStyle)
            .setCompressEngine(DefaultCompressEngine.create())
            .setImageEngine(GlideEngine.create())
            .setQueryFilterListener(QueryFilter.create())
            .isDisplayCamera(false)
            .isDirectReturnSingle(true)
            .setCropEngine(ThemeCropFileEngine.create())
            .forResult(listener)

但是始终无法生效,后面看了下源码发现isDirectReturnSingle(true)、setSelectionMode(SelectModeConfig.SINGLE) 设置单选后,PictureSelectorFragment中initComplete()有判断:
if (selectorConfig.selectionMode == SelectModeConfig.SINGLE && selectorConfig.isDirectReturnSingle) {
            selectorConfig.selectorStyle.getTitleBarStyle().setHideCancelButton(false);
            titleBar.getTitleCancelView().setVisibility(View.VISIBLE);
            completeSelectView.setVisibility(View.GONE);
        } 
这个判断使之前的.setSelectorUIStyle(selectorStyle)里设置isHideCancelButton=true失效,且时序永远是initComplete()在后,这样无论PictureSelector.create(context)后续api怎么调都是无效的。

我看了下cancelTextView点击事件实际和返回箭头一致,所以这里可以优化下吗?或者有其他方式提供吗
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