cart fragment fix
This commit is contained in:
@@ -14,6 +14,7 @@ import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.cart.CartProductModel;
|
||||
import ch.pizzalink.android.model.cart.CartProductOptionModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 05/10/2017.
|
||||
@@ -29,10 +30,11 @@ public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
public static class CartProductViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.cartProductNameTotalTextView) TextView cartProductNameTotalTextView;
|
||||
@BindView(R.id.cartProductInfoTextView) TextView cartProductInfoTextView;
|
||||
@BindView(R.id.cartProductTotalTextView) TextView cartProductTotalTextView;
|
||||
@BindView(R.id.cartProductCountTextView) TextView cartProductCountTextView;
|
||||
@BindView(R.id.cartProductNameTextView) TextView cartProductNameTextView;
|
||||
@BindView(R.id.cartProductTotalPriceTextView) TextView cartProductTotalPriceTextView;
|
||||
@BindView(R.id.removeProductFromCartImageView) ImageView removeProductFromCartImageView;
|
||||
@BindView(R.id.cartProductInfoTextView) TextView cartProductInfoTextView;
|
||||
|
||||
public CartProductViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||
super(view);
|
||||
@@ -102,12 +104,10 @@ public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
switch (holder.getItemViewType()){
|
||||
case HOLDER_CART_PRODUCT :
|
||||
CartProductViewHolder cartProductViewHolder = (CartProductViewHolder) holder;
|
||||
cartProductViewHolder.cartProductNameTotalTextView.setText(cartProductList.get(position).getName());
|
||||
cartProductViewHolder.cartProductTotalTextView.setText(cartProductList.get(position).getTotal());
|
||||
if(cartProductList.get(position).getOption() != null &&
|
||||
cartProductList.get(position).getOption().size() > 0){
|
||||
cartProductViewHolder.cartProductInfoTextView.setText(cartProductList.get(position).getOption().get(0).getValue());
|
||||
}
|
||||
cartProductViewHolder.cartProductCountTextView.setText(cartProductList.get(position).getQuantity() + " x ");
|
||||
cartProductViewHolder.cartProductNameTextView.setText(cartProductList.get(position).getName());
|
||||
cartProductViewHolder.cartProductTotalPriceTextView.setText(cartProductList.get(position).getTotal());
|
||||
setCartInfoText(cartProductViewHolder.cartProductInfoTextView, cartProductList.get(position));
|
||||
break;
|
||||
|
||||
case HOLDER_SPACE :
|
||||
@@ -122,4 +122,38 @@ public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
return cartProductList.size() + 1 ;
|
||||
}
|
||||
|
||||
private void setCartInfoText(TextView textView, CartProductModel cartProductModel){
|
||||
|
||||
if(cartProductModel.getOption() == null || cartProductModel.getOption().size() == 0){
|
||||
textView.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
textView.setText(getCartInfoText(cartProductModel));
|
||||
}
|
||||
|
||||
private String getCartInfoText(CartProductModel cartProductModel){
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for(CartProductOptionModel cartProductOptionModel : cartProductModel.getOption()){
|
||||
if(!cartProductOptionModel.getType().toLowerCase().equals("checkbox")){
|
||||
stringBuilder.append(cartProductOptionModel.getValue())
|
||||
.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
// stringBuilder.append("\n");
|
||||
|
||||
for(CartProductOptionModel cartProductOptionModel : cartProductModel.getOption()){
|
||||
if(cartProductOptionModel.getType().toLowerCase().equals("checkbox")){
|
||||
stringBuilder.append(cartProductOptionModel.getValue())
|
||||
.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return stringBuilder.toString().trim();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user