alhazmy13/MediaPicker

Unable to handle Result Request in Fragments

betterclever opened this issue · 2 comments

Current Behavior
The result is delivered to the activity's onActivityResult since the return call is being made to the activity context. Result is not delivered to the fragment's onActivityResult.

Expected Behavior
Call from Fragment delivers the result to the fragment.

Okay. I saw #11 Closing, therefore.

in fragments use rxjava adapter

        new VideoPickerHelper(new VideoPicker.Builder(getActivity())
                .mode(VideoPicker.Mode.CAMERA_AND_GALLERY)
                .directory(VideoPicker.Directory.DEFAULT)
                .extension(VideoPicker.Extension.MP4)
                .enableDebuggingMode(true)

        ).getObservable().subscribe(new Observer<List<String>>() {
            @Override
            public void onSubscribe(Disposable d) {
                Log.d("Upload", "selected : "+d.isDisposed());

            }

            @Override
            public void onNext(List<String> mPaths) {
                Log.d("Upload", "selected : "+mPaths.get(0));
            }

            @Override
            public void onError(Throwable e) {
                Log.d("Upload", "selected : "+e.getMessage());

            }

            @Override
            public void onComplete() {
                Log.d("Upload", "selected :fin ");

            }
        }); 

You have to add @aar at the end of dependencies for this to build successfully.

implementation 'net.alhazmy13.MediaPicker:libary:2.4.4@aar'
implementation 'net.alhazmy13.MediaPicker:rxjava:2.4.4@aar'

-- latest rxjava and rxandroid dependencies