Skip to content

Instantly share code, notes, and snippets.

@jeyakumar-optisol
Created April 11, 2022 06:38
Show Gist options
  • Save jeyakumar-optisol/f5394b9a746e09400d6a9ab92d0e859f to your computer and use it in GitHub Desktop.
Save jeyakumar-optisol/f5394b9a746e09400d6a9ab92d0e859f to your computer and use it in GitHub Desktop.
DialogFragment Result
// Add view binding on below
class GalleryPickerBottomSheet :
BaseBottomSheetDialogFragment<FragmentBottomSheetPickerBinding, GalleryPickerBottomSheetViewModel>(
FragmentBottomSheetPickerBinding::inflate,
GalleryPickerBottomSheetViewModel::class.java
) {
override fun onInit() {
//do something
}
companion object {
const val RESULT_PICKER: String = "gallery_picker"
}
}
//Callby
GalleryPickerBottomSheet().apply {
supportFragmentManager.setFragmentResultListener( //result received
GalleryPickerBottomSheet.RESULT_FRAGMENT,
this
) { key, bundle ->
if (key == GalleryPickerBottomSheet.RESULT_FRAGMENT) {
bundle.getInt(GalleryPickerBottomSheet.PICKER_VALUE, 0).apply {
Log.e("JeyK", "PICKER_VALUE $this") //value
}
}
}
}.show(supportFragmentManager, "GalleryPickerBottomSheet")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment