reference link: best: https://stackoverflow.com/questions/46106607/pass-or-listen-data-from-bottomsheetdialogfragment-to-fragment?rq=1
reference link:https://androidwave.com/bottom-sheet-dialog-fragment-in-android/
1.First create an interface
public static class ShowBottomSheetDialog extends BottomSheetDialogFragment { //stp 1 public interface BottomSheetListener{//step 1 void onUpdateClick(Object updatedInfo,String CallBackTag); }
//stp 2 2.create a member variable or that interface private BottomSheetListener mBListener;//step 2
3.onattach init the member variable
try { mBListener=(BottomSheetListener) context;//step 3 }catch (ClassCastException e){ throw new ClassCastException(context.toString()+" need to impliment BottomSheetListener interface."); }
3.1: impliment the Listener
public void setOnUpdateClickListener(BottomSheetListener mBListener){ try { this.mBListener=(BottomSheetListener)mBListener; // mBListener=(BottomSheetListener) context;//step 3 }catch (ClassCastException e){ throw new ClassCastException(context.toString()+" need to impliment BottomSheetListener interface."); } }
///////////////////////////////////////////
4.pass callback value————->>>>
mBListener.onUpdateClick(newDeposit,Define.DEPOSIT_TAG);
}
}
========================NOw in activity -impliment the interface and get data
@Override public void onUpdateClick(Object updatedInfo, String CallBackTag) { if(CallBackTag.equals(DEPOSIT_TAG)){ FireStoreModelDeposit updateDepo=(FireStoreModelDeposit) updatedInfo; //Helper.TOAST(this,updateDepo.getMem_deposit_amount()); Helper.LOG("new_UPdated_deposit",updateDepo.getMem_deposit_amount()); } }