siralam / BSImagePicker

An image picker that extends BottomSheetDialogFragment. Camera and gallery all in one dialog. Single or Multi Selection.
201 stars 62 forks source link

After choosing an image, the list is dismissed #6

Closed oakware-lda closed 5 years ago

oakware-lda commented 6 years ago

I am using the single image selection dialog and when I choose the image, the list just disappears. Any way to override the ActivityResult to ignore that dismiss()?

siralam commented 6 years ago

Sorry I don't get what you mean, the list disappears when you select an image by design; and the library has nothing to do with onActivityResult. What are you trying to achieve?

oakware-lda commented 6 years ago

Oh sorry, I probably didn't explain correctly. Please check this example:

ezgif com-video-to-gif

As you can see, I have a grid with two images and have the following BSImagePicker.OnSingleImageSelectedListener:

override fun onSingleImageSelected(uri: Uri) {
    startActivity(Intent(this, ImageActivity::class.java).putExtra("uri", uri))
    overridePendingTransition(R.anim.pull_right, R.anim.pull_right_semi)
}

So, when I choose the image I start another activity and pass the uri so I can use the image. The problem is that after this new activity, when I go back to the previous activity (the one with the grid), the grid with the two images doesn't exists anymore.

I am pretty sure that the problem is the "dismiss()" on line 396 of the BSImagePicker.java class:

adapter.setImageTileOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (v.getTag() != null && v.getTag() instanceof Uri && onSingleImageSelectedListener != null) {
            onSingleImageSelectedListener.onSingleImageSelected((Uri) v.getTag());
            dismiss();
         }
     }
});

I know this is the normal behaviour of the library, and probably this is not even an issue, but would be nice to not dismiss the picker after an image click. Maybe add another method to the Builder to .dismissAfterClick(false).

I hope that you understand my issue. Anyway, thank you for your hard work and for this library!

siralam commented 6 years ago

Understood now! That is a valid suggestion, I will add it soon :) Thanks!

siralam commented 6 years ago

Thanks to @ikakus this will be added to next version.

siralam commented 5 years ago

Implemented in 1.1.0