private void retriveData(String pid) {
FirebaseDatabase.getInstance().getReference().child("Hospital").child("Products").child(pid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
String x = snapshot.child("About").getValue().toString();
String y = x.replace("n","\r\n\n");
pTitle.setText(snapshot.child("Title").getValue().toString());
pDescription.setText(y);
pPrice.setText("Rs." +snapshot.child("Price").getValue().toString());
pWeight.setText(snapshot.child("Weight").getValue().toString() + " g");
Glide.with(ProductActivity.this).load(snapshot.child("Image").getValue().toString()).placeholder(R.drawable.ic_image).into(pImage);
up = Integer.parseInt((String) snapshot.child("Price").getValue());
uw = Integer.parseInt(snapshot.child("Weight").getValue().toString());
im = snapshot.child("Image").getValue().toString();
calculation(up, uw);
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
0 Comments