I made a fragment name OrderYourFoodFragment
and inside of the fragment i place a BottomDialogFragment
but issue is I placed a button on the BottomDialogFragment
and I want when the button is press the condition is execute and the bottomfragment has to be close and fall back to OrderYourFoodFragment
how can i achieve that
I write this code in OrderYourFoodFragment
red.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Users").child(mobile).child("predict");
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
String order = snapshot.getValue(String.class);
int iorder = Integer.parseInt(order);
if (iorder == 0){
BottomRedFragment bottomRedFragment = new BottomRedFragment();
bottomRedFragment.show(getChildFragmentManager(), bottomRedFragment.getTag());
} else {
Toast.makeText(getActivity(), "You are already Ordered your Food", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
});