ParkSangGwon / TedBottomPicker

TedBottomPicker is simple image picker using bottom sheet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

라이브러리 웹뷰 적용 시 문제입니다.

timoki opened this issue · comments

웹뷰 파일 선택 시 onShowFileChooser() 함수로 콜백이 되는데 이때 TedBottomPicker 라이브러리를 띄웟을 경우 이미지를 선택하고 다시 파일선택 할때는 문제가 안되는데 만약 이미지 선택을 취소 했을 경우에는 onShowFileChooser() 함수로 콜백 진입이 안됩니다. 디버그 모드로 취소하였을때 진입점이 어디로 되는지 찾을려 해도 TedBottomPicker.Builder().setOnErrorListener(), TedBottomPicker.onCancel() 둘다 진입이 안됩니다. 방법이 있습니까?

// For Android Version 5.0+
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
if (mFilePathCallback != null) {
mFilePathCallback.onReceiveValue(null);
mFilePathCallback = null;
}
mFilePathCallback = filePathCallback;
String[] str = new String[]{"사진선택", "동영상촬영"};
android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(WebviewAct.this, android.app.AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
alertDialogBuilder.setSingleChoiceItems(str, 0, new DialogInterface.OnClickListener() {
@OverRide
public void onClick(DialogInterface dialog, final int which) {
if (which == 0){
imageChooser();
}else{
videoRecord();
}
dialog.dismiss();
}
});
alertDialogBuilder.show();

            return true;
        }

        public void imageChooser(){
            TedBottomPicker tedBottomPicker = new TedBottomPicker.Builder(WebviewAct.this).setImageProvider(new TedBottomPicker.ImageProvider() {
                @Override
                public void onProvideImage(ImageView imageView, Uri imageUri) {
                    Glide.with(WebviewAct.this).load(imageUri).apply(RequestOptions.centerCropTransform()).into(imageView);
                }
            }).setOnImageSelectedListener(new TedBottomPicker.OnImageSelectedListener() {
                @Override
                public void onImageSelected(Uri uri) {
                    FileUploadHelper helper = new FileUploadHelper();
                    Uri[] u = new Uri[]{Uri.fromFile(helper.getResizeFile(WebviewAct.this, uri.getPath()))};
                    mFilePathCallback.onReceiveValue(u);
                    mFilePathCallback = null;
                }
            }).setOnErrorListener(new TedBottomPicker.OnErrorListener() { //진입안됨
                @Override
                public void onError(String message) {
                    mFilePathCallback.onReceiveValue(null);
                    mFilePathCallback = null;
                }
            }).create();

            tedBottomPicker.onCancel(new DialogInterface() {
                @Override
                public void cancel() { //진입안됨
                    mFilePathCallback.onReceiveValue(null);
                    mFilePathCallback = null;
                }

                @Override
                public void dismiss() { //진입안됨
                    mFilePathCallback.onReceiveValue(null);
                    mFilePathCallback = null;
                }
            });

            tedBottomPicker.show(getSupportFragmentManager());
        }