diff --git a/README.md b/README.md index 48e7dd2..8b67153 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ android library for gallery images and videos, and capture camera image and vide ```groovy - implementation 'com.github.mostafahashim:GalleryLibrary:1.2.1' + implementation 'com.github.mostafahashim:GalleryLibrary:1.2.2' ``` # Usage @@ -49,6 +49,9 @@ fun openGallery() { binding.viewModel?.galleryModels ?: ArrayList() ) } + override fun onDismiss() { + + } }, galleryResultLauncher = galleryResultLauncher ) diff --git a/app/src/main/java/hashim/gallery/presentation/main/MainActivity.kt b/app/src/main/java/hashim/gallery/presentation/main/MainActivity.kt index 207248c..349fc80 100644 --- a/app/src/main/java/hashim/gallery/presentation/main/MainActivity.kt +++ b/app/src/main/java/hashim/gallery/presentation/main/MainActivity.kt @@ -93,6 +93,10 @@ class MainActivity : AppCompatActivity(), MainViewModel.Observer { binding.viewModel?.galleryModels ?: ArrayList() ) } + + override fun onDismiss() { + + } }, galleryResultLauncher = galleryResultLauncher ) diff --git a/gallerylib/build.gradle b/gallerylib/build.gradle index c4bc2c0..bb7ba3b 100644 --- a/gallerylib/build.gradle +++ b/gallerylib/build.gradle @@ -88,7 +88,7 @@ afterEvaluate { groupId = 'com.github.mostafahashim' artifactId = 'gallery-lib' - version = '1.2.1' + version = '1.2.2' } } } diff --git a/gallerylib/src/main/java/hashim/gallerylib/observer/OnResultCallback.kt b/gallerylib/src/main/java/hashim/gallerylib/observer/OnResultCallback.kt index b87a289..207a55b 100644 --- a/gallerylib/src/main/java/hashim/gallerylib/observer/OnResultCallback.kt +++ b/gallerylib/src/main/java/hashim/gallerylib/observer/OnResultCallback.kt @@ -4,4 +4,5 @@ import hashim.gallerylib.model.GalleryModel interface OnResultCallback { fun onResult(list: ArrayList) + fun onDismiss() } \ No newline at end of file diff --git a/gallerylib/src/main/java/hashim/gallerylib/view/galleryActivity/BottomSheetGalleryFragment.kt b/gallerylib/src/main/java/hashim/gallerylib/view/galleryActivity/BottomSheetGalleryFragment.kt index 8577d09..f10db29 100644 --- a/gallerylib/src/main/java/hashim/gallerylib/view/galleryActivity/BottomSheetGalleryFragment.kt +++ b/gallerylib/src/main/java/hashim/gallerylib/view/galleryActivity/BottomSheetGalleryFragment.kt @@ -3,6 +3,7 @@ package hashim.gallerylib.view.galleryActivity import android.Manifest import android.app.Activity import android.content.Context +import android.content.DialogInterface import android.content.Intent import android.content.pm.PackageManager import android.media.MediaScannerConnection @@ -136,6 +137,12 @@ class BottomSheetGalleryFragment : BottomSheetDialogFragment(), GalleryViewModel } } + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + if (::onResultCallback.isInitialized) + onResultCallback.onDismiss() + } + override fun openFinish() { binding.viewModel?.selectedPhotos = binding.viewModel?.recyclerGalleryAdapter?.getSelected() ?: ArrayList() diff --git a/gallerylib/src/main/java/hashim/gallerylib/view/galleryActivity/showMethod.kt b/gallerylib/src/main/java/hashim/gallerylib/view/galleryActivity/showMethod.kt index bf8b949..b55f780 100644 --- a/gallerylib/src/main/java/hashim/gallerylib/view/galleryActivity/showMethod.kt +++ b/gallerylib/src/main/java/hashim/gallerylib/view/galleryActivity/showMethod.kt @@ -37,7 +37,11 @@ class GalleryLib(var myActivity: AppCompatActivity) { bottomSheetFragment.arguments = bundle bottomSheetFragment.onResultCallback = object : OnResultCallback { override fun onResult(list: ArrayList) { - onResultCallback?.onResult(list) + onResultCallback.onResult(list) + } + + override fun onDismiss() { + onResultCallback.onDismiss() } } bottomSheetFragment.show(myActivity.supportFragmentManager, bottomSheetFragment.tag)