Created
April 11, 2022 06:38
-
-
Save jeyakumar-optisol/f5394b9a746e09400d6a9ab92d0e859f to your computer and use it in GitHub Desktop.
DialogFragment Result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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