cart fragment fix
This commit is contained in:
@@ -14,6 +14,7 @@ import butterknife.ButterKnife;
|
|||||||
import ch.pizzalink.android.R;
|
import ch.pizzalink.android.R;
|
||||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||||
import ch.pizzalink.android.model.cart.CartProductModel;
|
import ch.pizzalink.android.model.cart.CartProductModel;
|
||||||
|
import ch.pizzalink.android.model.cart.CartProductOptionModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cimenmus on 05/10/2017.
|
* 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 {
|
public static class CartProductViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@BindView(R.id.cartProductNameTotalTextView) TextView cartProductNameTotalTextView;
|
@BindView(R.id.cartProductCountTextView) TextView cartProductCountTextView;
|
||||||
@BindView(R.id.cartProductInfoTextView) TextView cartProductInfoTextView;
|
@BindView(R.id.cartProductNameTextView) TextView cartProductNameTextView;
|
||||||
@BindView(R.id.cartProductTotalTextView) TextView cartProductTotalTextView;
|
@BindView(R.id.cartProductTotalPriceTextView) TextView cartProductTotalPriceTextView;
|
||||||
@BindView(R.id.removeProductFromCartImageView) ImageView removeProductFromCartImageView;
|
@BindView(R.id.removeProductFromCartImageView) ImageView removeProductFromCartImageView;
|
||||||
|
@BindView(R.id.cartProductInfoTextView) TextView cartProductInfoTextView;
|
||||||
|
|
||||||
public CartProductViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
public CartProductViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||||
super(view);
|
super(view);
|
||||||
@@ -102,12 +104,10 @@ public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
switch (holder.getItemViewType()){
|
switch (holder.getItemViewType()){
|
||||||
case HOLDER_CART_PRODUCT :
|
case HOLDER_CART_PRODUCT :
|
||||||
CartProductViewHolder cartProductViewHolder = (CartProductViewHolder) holder;
|
CartProductViewHolder cartProductViewHolder = (CartProductViewHolder) holder;
|
||||||
cartProductViewHolder.cartProductNameTotalTextView.setText(cartProductList.get(position).getName());
|
cartProductViewHolder.cartProductCountTextView.setText(cartProductList.get(position).getQuantity() + " x ");
|
||||||
cartProductViewHolder.cartProductTotalTextView.setText(cartProductList.get(position).getTotal());
|
cartProductViewHolder.cartProductNameTextView.setText(cartProductList.get(position).getName());
|
||||||
if(cartProductList.get(position).getOption() != null &&
|
cartProductViewHolder.cartProductTotalPriceTextView.setText(cartProductList.get(position).getTotal());
|
||||||
cartProductList.get(position).getOption().size() > 0){
|
setCartInfoText(cartProductViewHolder.cartProductInfoTextView, cartProductList.get(position));
|
||||||
cartProductViewHolder.cartProductInfoTextView.setText(cartProductList.get(position).getOption().get(0).getValue());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HOLDER_SPACE :
|
case HOLDER_SPACE :
|
||||||
@@ -122,4 +122,38 @@ public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
return cartProductList.size() + 1 ;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,22 +23,49 @@
|
|||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/cartProductNameTotalTextView"
|
android:id="@+id/cartProductCountTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Pizza Formaggio"
|
android:text="2 x "
|
||||||
android:textSize="18sp"
|
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:textStyle="bold"/>
|
android:layout_centerVertical="true"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cartProductNameTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Pizza Formaggio"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toRightOf="@+id/cartProductCountTextView"
|
||||||
|
android:layout_toEndOf="@+id/cartProductCountTextView"
|
||||||
|
android:layout_toLeftOf="@+id/cartProductTotalPriceTextView"
|
||||||
|
android:layout_toStartOf="@+id/cartProductTotalPriceTextView"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cartProductTotalPriceTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="CHF 25.00"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toLeftOf="@+id/removeProductFromCartImageView"
|
||||||
|
android:layout_toStartOf="@+id/removeProductFromCartImageView"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/removeProductFromCartImageView"
|
android:id="@+id/removeProductFromCartImageView"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="32dp"
|
android:layout_height="32dp"
|
||||||
android:padding="6dp"
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_cancel_2"
|
android:src="@drawable/ic_cancel_2"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentEnd="true"/>
|
android:layout_alignParentEnd="true"/>
|
||||||
|
|
||||||
@@ -50,21 +77,15 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Gross"
|
android:text="Gross"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
|
android:layout_marginLeft="64dp"
|
||||||
|
android:layout_marginStart="64dp"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
android:paddingLeft="12dp"
|
android:paddingLeft="12dp"
|
||||||
android:paddingStart="12dp"
|
android:paddingStart="12dp"
|
||||||
android:paddingRight="12dp"
|
android:paddingRight="12dp"
|
||||||
android:paddingEnd="12dp" />
|
android:paddingEnd="12dp" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/cartProductTotalTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="CHF 25.00"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
Reference in New Issue
Block a user