use of com.example.asus.onlinecanteen.model.Product in project OnlineCanteen by josephgunawan97.
the class DeleteProductFragment method attachDatabaseReadListener.
private void attachDatabaseReadListener() {
if (productEventListener == null) {
productEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Product product = dataSnapshot.getValue(Product.class);
if (merchant.getUid().equals(product.getTokoId()))
deleteAdapter.addProductList(product);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
databaseProducts.addChildEventListener(productEventListener);
}
}
use of com.example.asus.onlinecanteen.model.Product in project OnlineCanteen by josephgunawan97.
the class UserProductListFragment method attachProductDatabaseListener.
// ---------------- FIREBASE CHILD EVENT LISTENER -----------------//
private void attachProductDatabaseListener() {
if (productsEventListener == null) {
productsEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Product product = dataSnapshot.getValue(Product.class);
userProductItemAdapter.addProduct(product);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
productsQuery.addChildEventListener(productsEventListener);
}
}
use of com.example.asus.onlinecanteen.model.Product in project OnlineCanteen by josephgunawan97.
the class UserOrderProductAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
// Get product and cart
Cart cart = orders.get(position);
Product product = products.get(position);
// Set on view
holder.userOrderProductNameTextView.setText(cart.getProductName());
holder.userOrderProductPriceTextView.setText("Rp " + String.valueOf(cart.getProductPrice()));
holder.userOrderProductQuantityTextView.setText(String.valueOf(cart.getQuantity()));
// Get image
if (product.getImageUrl() != null) {
Glide.with(holder.userOrderProductImageView.getContext()).load(product.getImageUrl()).into(holder.userOrderProductImageView);
}
if (product.getStock() <= 0) {
holder.userOrderProductIncreaseButton.setEnabled(false);
holder.userOrderProductDecreaseButton.setEnabled(false);
holder.userOrderProductIncreaseButton.setBackgroundColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.gray));
holder.userOrderProductDecreaseButton.setBackgroundColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.gray));
holder.outOfStockLayout.setVisibility(View.VISIBLE);
} else {
holder.outOfStockLayout.setVisibility(View.GONE);
}
}
use of com.example.asus.onlinecanteen.model.Product in project OnlineCanteen by josephgunawan97.
the class MerchantProductListFragment method attachDatabaseReadListener.
private void attachDatabaseReadListener() {
if (productEventListener == null) {
productEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Product product = dataSnapshot.getValue(Product.class);
if (merchant.getUid().equals(product.getTokoId()))
menuListAdapter.add(product);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
Product product = dataSnapshot.getValue(Product.class);
if (merchant.getUid().equals(product.getTokoId()))
menuListAdapter.add(product);
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
databaseProducts.addChildEventListener(productEventListener);
}
}
Aggregations