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

override onSelectFilter function is not working, my plan is to create limit assets for image and video separately. #2954

Open
krisnapy opened this issue Nov 21, 2024 · 0 comments

Comments

@krisnapy
Copy link

Current use version?

当前使用的版本是多少?

v3.11.2

Will this problem occur in demo?

Demo能否复现这问题?

override onSelectFilter function is not working, my plan is to create limit assets for image and video separately.

        PictureSelector.create(activity)
                .openGallery(if (mediaType == "video") SelectMimeType.ofVideo() else if (mediaType == "image") SelectMimeType.ofImage() else SelectMimeType.ofAll())
                .setImageEngine(imageEngine)
                .setSelectFilterListener(object : OnSelectFilterListener {
                    override fun onSelectFilter(media: LocalMedia?): Boolean {
                        Log.d("MultipleImagePicker", "media: ${media?.isChecked} ${media?.mimeType}")
                        return false
                    }
                })
                .setMaxSelectNum(maxSelectedAssets)
                .setImageSpanCount(numberOfColumn)
                .setCropEngine(onSetCropEngine())
                .isDirectReturnSingle(true)
                .isSelectZoomAnim(true)
                .isPageStrategy(true, 50)
                .isWithSelectVideoImage(true)
                .setRecordVideoMaxSecond(maxVideoDuration)
                .setMaxVideoSelectNum(if (maxVideo != 20) maxVideo else maxSelectedAssets)
                .isMaxSelectEnabledMask(true)
                .setSelectedData(selectedAssets)
                .setSelectorUIStyle(style)
                .isPreviewImage(isPreview)
                .isPreviewVideo(isPreview)
                .isDisplayCamera(isCamera)
                .setAttachViewLifecycle(customAttachViewLifecycle)
                .setInjectLayoutResourceListener(customLayoutResourceListener)
                .setSelectionMode(if (singleSelectedMode) SelectModeConfig.SINGLE else SelectModeConfig.MULTIPLE)
                .forResult(object : OnResultCallbackListener<LocalMedia?> {
                    override fun onResult(result: ArrayList<LocalMedia?>?) {
                        val localMedia: WritableArray = WritableNativeArray()
                        if (result?.size == 0) {
                            promise.resolve(localMedia)
                            return
                        }
                        if (result?.size == selectedAssets.size && (result[result.size - 1] as LocalMedia).id == (selectedAssets[selectedAssets.size - 1].id)) {
                            return
                        }
                        if (result != null) {
                            for (i in 0 until result.size) {
                                val item: LocalMedia = result[i] as LocalMedia
                                val media: WritableMap = createAttachmentResponse(item)
                                localMedia.pushMap(media)
                            }
                        }
                        promise.resolve(localMedia)
                    }

                    override fun onCancel() {
                        promise.reject("PICKER_CANCELLED", "User has canceled", null)
                    }
                })

Describe the problem or provide an error log?

描述问题或提供错误log?


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