Skip to content

Commit

Permalink
dismisListener
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafahashim committed Oct 31, 2023
1 parent 50091dc commit d1636e1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,6 +49,9 @@ fun openGallery() {
binding.viewModel?.galleryModels ?: ArrayList()
)
}
override fun onDismiss() {

}
},
galleryResultLauncher = galleryResultLauncher
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class MainActivity : AppCompatActivity(), MainViewModel.Observer {
binding.viewModel?.galleryModels ?: ArrayList()
)
}

override fun onDismiss() {

}
},
galleryResultLauncher = galleryResultLauncher
)
Expand Down
2 changes: 1 addition & 1 deletion gallerylib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ afterEvaluate {

groupId = 'com.github.mostafahashim'
artifactId = 'gallery-lib'
version = '1.2.1'
version = '1.2.2'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import hashim.gallerylib.model.GalleryModel

interface OnResultCallback {
fun onResult(list: ArrayList<GalleryModel>)
fun onDismiss()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ class GalleryLib(var myActivity: AppCompatActivity) {
bottomSheetFragment.arguments = bundle
bottomSheetFragment.onResultCallback = object : OnResultCallback {
override fun onResult(list: ArrayList<GalleryModel>) {
onResultCallback?.onResult(list)
onResultCallback.onResult(list)
}

override fun onDismiss() {
onResultCallback.onDismiss()
}
}
bottomSheetFragment.show(myActivity.supportFragmentManager, bottomSheetFragment.tag)
Expand Down

0 comments on commit d1636e1

Please sign in to comment.