calling parent fragment from DialogFragment called using navigation component

103
April 22, 2022, at 02:30 AM

My fragment calls a DialogFragment using navigation component like this

this.findNavController().navigate(                    
    CartSingleSellerDirections.actionCartSingleSellerToSelectPickUpOrDelivery(email,sellerPK)
)

And here's the called DialogFragment class. I'm trying to call a method on the parent fragment upon dismissing the dialog, so I override dismiss, but the code below throws the error java.lang.ClassCastException: androidx.navigation.fragment.NavHostFragment cannot be cast to android.content.DialogInterface$OnDismissListener

class SelectPickUpOrDelivery : DialogFragment() {
    override fun dismiss() {
        super.dismiss()        
        val parentFragment: Fragment? = parentFragment
        (parentFragment as DialogInterface.OnDismissListener?)!!.onDismiss(dialog)
   }
}
Rent Charter Buses Company
READ ALSO
Incoming call notification in Android like whatsapp

Incoming call notification in Android like whatsapp

I am an android developerI didn't get any idea how to show notification when call is generate from server using opentok api

78
ViewModel: Error on loading long list in IO Dispatcher

ViewModel: Error on loading long list in IO Dispatcher

I want to load a long list inside my ViewModel class, queried from databaseData will then be shown using LazyColumn

107
Material Container Transform animation not working in Java

Material Container Transform animation not working in Java

Im trying to use Material Container Transform in Recyclerview Adapter as described by this post MaterialContainerTransform transition is not Working on Return , but after implementing this in my project im getting null pointer exception errorAs everyone...

76