public void addToCart(View view){
String uid = FirebaseAuth.getInstance().getUid();
calendar = Calendar.getInstance();
date = DateFormat.getDateInstance().format(calendar.getTime());
HashMap<String, Object> map = new HashMap<>();
map.put("ProductId", pid);
map.put("Quantity", pQuantity.getText().toString());
map.put("Amount", pTotal.getText().toString());
map.put("Weight", pItemsWeight.getText().toString());
map.put("Title", pTitle.getText().toString());
map.put("Image", im);
map.put("Date", date);
FirebaseDatabase.getInstance().getReference().child("Hospital").child("Users").child(uid).child("Cart").child(pid).updateChildren(map).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
Toast.makeText(ProductActivity.this, "கூடையில் சேர்க்கப்பட்டது", Toast.LENGTH_SHORT).show();
startActivity(new Intent(ProductActivity.this, CartActivity.class));
}
});
}
0 Comments