private void confirmOrder() {
FirebaseDatabase.getInstance().getReference().child("Hospital").child("Users").child(uid).child("Cart")
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
FirebaseDatabase.getInstance().getReference().child("Hospital").child("Users").child(uid).child("Order")
.setValue(snapshot.getValue()).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
Toast.makeText(ProfileActivity.this, "Order Confirmed", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(ProfileActivity.this, "Failed!", Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
0 Comments