cart screen
This commit is contained in:
@@ -0,0 +1,125 @@
|
|||||||
|
package ch.pizzalink.android.adapter.recycler;
|
||||||
|
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import ch.pizzalink.android.R;
|
||||||
|
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||||
|
import ch.pizzalink.android.model.CartProductModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cimenmus on 05/10/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||||
|
|
||||||
|
private final int HOLDER_CART_PRODUCT = 0;
|
||||||
|
private final int HOLDER_SPACE = 1;
|
||||||
|
|
||||||
|
private ArrayList<CartProductModel> cartProductList = new ArrayList<>();
|
||||||
|
private RecyclerItemClickListener recyclerItemClickListener;
|
||||||
|
|
||||||
|
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.removeProductFromCartImageView) ImageView removeProductFromCartImageView;
|
||||||
|
|
||||||
|
public CartProductViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||||
|
super(view);
|
||||||
|
ButterKnife.bind(this, view);
|
||||||
|
removeProductFromCartImageView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if(recyclerItemClickListener != null)
|
||||||
|
recyclerItemClickListener.onItemClick(removeProductFromCartImageView, getAdapterPosition());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
public SpaceViewHolder(final View view) {
|
||||||
|
super(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
if(position == cartProductList.size())
|
||||||
|
return HOLDER_SPACE;
|
||||||
|
return HOLDER_CART_PRODUCT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CartRecyclerAdapter(ArrayList<CartProductModel> cartProductList,
|
||||||
|
RecyclerItemClickListener recyclerItemClickListener){
|
||||||
|
this.cartProductList = cartProductList;
|
||||||
|
this.recyclerItemClickListener = recyclerItemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
|
|
||||||
|
RecyclerView.ViewHolder viewHolder;
|
||||||
|
View view;
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
|
||||||
|
|
||||||
|
switch (viewType){
|
||||||
|
|
||||||
|
case HOLDER_CART_PRODUCT:
|
||||||
|
view = inflater.inflate(R.layout.row_cart, viewGroup, false);
|
||||||
|
viewHolder = new CartProductViewHolder(view, recyclerItemClickListener);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HOLDER_SPACE:
|
||||||
|
view = inflater.inflate(R.layout.row_space, viewGroup, false);
|
||||||
|
viewHolder = new SpaceViewHolder(view);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
view = inflater.inflate(R.layout.row_cart, viewGroup, false);
|
||||||
|
viewHolder = new CartProductViewHolder(view, recyclerItemClickListener);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return viewHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HOLDER_SPACE :
|
||||||
|
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return cartProductList.size() + 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,5 +10,7 @@ public class ApiEndPoints {
|
|||||||
public static final String API_LOGIN = PREFIX + "login" + SUFFIX;
|
public static final String API_LOGIN = PREFIX + "login" + SUFFIX;
|
||||||
public static final String API_LOGOUT = PREFIX + "logout" + SUFFIX;
|
public static final String API_LOGOUT = PREFIX + "logout" + SUFFIX;
|
||||||
public static final String API_GET_ORDER_HISTORY = PREFIX + "getOrders" + SUFFIX;
|
public static final String API_GET_ORDER_HISTORY = PREFIX + "getOrders" + SUFFIX;
|
||||||
|
public static final String API_GET_CART_PRODUCTS = PREFIX + "getBasketProducts" + SUFFIX;
|
||||||
|
public static final String API_GET_CLEAR_CART = PREFIX + "clearBasket" + SUFFIX;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class ApiErrorUtils {
|
|||||||
try {
|
try {
|
||||||
error = converter.convert(response.errorBody());
|
error = converter.convert(response.errorBody());
|
||||||
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, error.getMessage());
|
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, error.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ch.pizzalink.android.api;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import ch.pizzalink.android.model.CartInfoModel;
|
||||||
import ch.pizzalink.android.model.CategoryModel;
|
import ch.pizzalink.android.model.CategoryModel;
|
||||||
import ch.pizzalink.android.model.OrderModel;
|
import ch.pizzalink.android.model.OrderModel;
|
||||||
import ch.pizzalink.android.model.UserModel;
|
import ch.pizzalink.android.model.UserModel;
|
||||||
@@ -49,6 +50,12 @@ public interface ApiInterface {
|
|||||||
@GET(ApiEndPoints.API_GET_ORDER_HISTORY)
|
@GET(ApiEndPoints.API_GET_ORDER_HISTORY)
|
||||||
Call<ResponseArray<OrderModel>> getOrderHistory(@Query("token") String token);
|
Call<ResponseArray<OrderModel>> getOrderHistory(@Query("token") String token);
|
||||||
|
|
||||||
|
@GET(ApiEndPoints.API_GET_CART_PRODUCTS)
|
||||||
|
Call<ResponseObject<CartInfoModel>> getCartProducts(@Query("token") String token);
|
||||||
|
|
||||||
|
@GET(ApiEndPoints.API_GET_CLEAR_CART)
|
||||||
|
Call<ResponseObject> clearCart(@Query("token") String token);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,39 @@
|
|||||||
package ch.pizzalink.android.fragment;
|
package ch.pizzalink.android.fragment;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import butterknife.BindColor;
|
||||||
import butterknife.BindString;
|
import butterknife.BindString;
|
||||||
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
import ch.pizzalink.android.R;
|
import ch.pizzalink.android.R;
|
||||||
|
import ch.pizzalink.android.activity.BaseActivity;
|
||||||
|
import ch.pizzalink.android.adapter.recycler.CartRecyclerAdapter;
|
||||||
|
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||||
|
import ch.pizzalink.android.api.ApiService;
|
||||||
|
import ch.pizzalink.android.api.ResponseObject;
|
||||||
|
import ch.pizzalink.android.helper.DialogHelper;
|
||||||
|
import ch.pizzalink.android.helper.SessionHelper;
|
||||||
|
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||||
|
import ch.pizzalink.android.model.CartInfoModel;
|
||||||
|
import ch.pizzalink.android.model.CartProductModel;
|
||||||
|
import ch.pizzalink.android.model.CartTotalModel;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cimenmus on 18/09/2017.
|
* Created by cimenmus on 18/09/2017.
|
||||||
@@ -15,10 +41,25 @@ import ch.pizzalink.android.R;
|
|||||||
|
|
||||||
public class CartFragment extends BaseFragment {
|
public class CartFragment extends BaseFragment {
|
||||||
|
|
||||||
|
@BindView(R.id.cartFragmentMainLayout) RelativeLayout cartFragmentMainLayout;
|
||||||
|
@BindView(R.id.noProductsOnCartTextView) TextView noProductsOnCartTextView;
|
||||||
|
@BindView(R.id.cartRecyclerView) RecyclerView cartRecyclerView;
|
||||||
|
@BindView(R.id.cartInfoLayout) LinearLayout cartInfoLayout;
|
||||||
|
@BindView(R.id.cartTotalLabelTextView) TextView cartTotalLabelTextView;
|
||||||
|
@BindView(R.id.cartProductTotalTextView) TextView cartProductTotalTextView;
|
||||||
|
@BindView(R.id.continueCartButton) Button continueCartButton;
|
||||||
|
@BindView(R.id.clearCartButton) Button clearCartButton;
|
||||||
|
|
||||||
@BindString(R.string.bottom_nav_menu_item_cart) String fragmentTitle;
|
@BindString(R.string.bottom_nav_menu_item_cart) String fragmentTitle;
|
||||||
|
|
||||||
|
@BindColor(R.color.actvity_default_background_color_1) int grayColor;
|
||||||
|
@BindColor(R.color.white) int whiteColor;
|
||||||
|
|
||||||
public static final java.lang.String FRAGMENT_NAME = "cartFragment";
|
public static final java.lang.String FRAGMENT_NAME = "cartFragment";
|
||||||
|
|
||||||
|
private ArrayList<CartProductModel> cartProductList = new ArrayList<>();
|
||||||
|
private CartRecyclerAdapter cartRecyclerAdapter;
|
||||||
|
|
||||||
public CartFragment() {}
|
public CartFragment() {}
|
||||||
|
|
||||||
public static CartFragment newInstance() {
|
public static CartFragment newInstance() {
|
||||||
@@ -35,10 +76,115 @@ public class CartFragment extends BaseFragment {
|
|||||||
View view = inflater.inflate(R.layout.fragment_cart, container, false);
|
View view = inflater.inflate(R.layout.fragment_cart, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
initViews();
|
initViews();
|
||||||
|
getCartProducts();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick({R.id.clearCartButton, R.id.continueCartButton})
|
||||||
|
protected void onClick(View view){
|
||||||
|
switch (view.getId()){
|
||||||
|
case R.id.clearCartButton:
|
||||||
|
clearCart();
|
||||||
|
break;
|
||||||
|
case R.id.continueCartButton:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initViews(){
|
private void initViews(){
|
||||||
setPizzalinkToolbarFields(false, fragmentTitle);
|
setPizzalinkToolbarFields(false, fragmentTitle);
|
||||||
|
initRecyclerView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getCartProducts(){
|
||||||
|
DialogHelper.showLoadingDialog();
|
||||||
|
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
|
||||||
|
SessionHelper.getCustomerToken().getToken());
|
||||||
|
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<ResponseObject<CartInfoModel>> call, Response<ResponseObject<CartInfoModel>> response) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
if(response.isSuccessful() &&
|
||||||
|
response.body().getData() != null &&
|
||||||
|
response.body().isSuccess()){
|
||||||
|
setCartTotalFields(response.body().getData().getTotals().get(0));
|
||||||
|
fillAndNotifyAdapter(response.body().getData().getProducts());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ApiErrorUtils.parseError(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
DialogHelper.showFailedDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearCart(){
|
||||||
|
DialogHelper.showLoadingDialog();
|
||||||
|
Call<ResponseObject> call = ApiService.apiInterface.clearCart(
|
||||||
|
SessionHelper.getCustomerToken().getToken());
|
||||||
|
call.enqueue(new Callback<ResponseObject>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<ResponseObject> call, Response<ResponseObject> response) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
if(response.isSuccessful() && response.body().isSuccess()){
|
||||||
|
cartProductList.clear();
|
||||||
|
cartRecyclerAdapter.notifyDataSetChanged();
|
||||||
|
setCartLayoutsVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
ApiErrorUtils.parseError(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<ResponseObject> call, Throwable t) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
DialogHelper.showFailedDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillAndNotifyAdapter(ArrayList<CartProductModel> cartList){
|
||||||
|
CartProductModel.checkNull(cartList);
|
||||||
|
cartProductList.clear();
|
||||||
|
cartProductList.addAll(cartList);
|
||||||
|
cartRecyclerAdapter.notifyDataSetChanged();
|
||||||
|
setCartLayoutsVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCartTotalFields(CartTotalModel cartTotalModel){
|
||||||
|
cartTotalLabelTextView.setText(cartTotalModel.getTitle());
|
||||||
|
cartProductTotalTextView.setText(cartTotalModel.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initRecyclerView(){
|
||||||
|
cartRecyclerAdapter = new CartRecyclerAdapter(cartProductList, new RecyclerItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(View view, int position) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
|
||||||
|
cartRecyclerView.setLayoutManager(layoutManager);
|
||||||
|
cartRecyclerView.setAdapter(cartRecyclerAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCartLayoutsVisibility(){
|
||||||
|
if(cartProductList.size() > 0){
|
||||||
|
noProductsOnCartTextView.setVisibility(View.GONE);
|
||||||
|
cartFragmentMainLayout.setBackgroundColor(grayColor);
|
||||||
|
cartRecyclerView.setVisibility(View.VISIBLE);
|
||||||
|
cartInfoLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cartRecyclerView.setVisibility(View.GONE);
|
||||||
|
cartInfoLayout.setVisibility(View.GONE);
|
||||||
|
cartFragmentMainLayout.setBackgroundColor(whiteColor);
|
||||||
|
noProductsOnCartTextView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package ch.pizzalink.android.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cimenmus on 05/10/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CartInfoModel {
|
||||||
|
|
||||||
|
private ArrayList<CartProductModel> products;
|
||||||
|
private ArrayList<CartTotalModel> totals;
|
||||||
|
|
||||||
|
public ArrayList<CartProductModel> getProducts() {
|
||||||
|
return products;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProducts(ArrayList<CartProductModel> products) {
|
||||||
|
this.products = products;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<CartTotalModel> getTotals() {
|
||||||
|
return totals;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotals(ArrayList<CartTotalModel> totals) {
|
||||||
|
this.totals = totals;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
package ch.pizzalink.android.model;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cimenmus on 05/10/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CartProductModel {
|
||||||
|
|
||||||
|
@Expose @SerializedName("cart_id") private String cartId;
|
||||||
|
@Expose @SerializedName("product_id") private String productId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String model;
|
||||||
|
private String quantity;
|
||||||
|
private String shipping;
|
||||||
|
private String price;
|
||||||
|
private String total;
|
||||||
|
private boolean stock;
|
||||||
|
private int reward;
|
||||||
|
private ArrayList<ProductOptionModel> option;
|
||||||
|
|
||||||
|
private void checkNull(){
|
||||||
|
|
||||||
|
if(cartId == null)
|
||||||
|
cartId = "";
|
||||||
|
|
||||||
|
if(productId == null)
|
||||||
|
productId = "";
|
||||||
|
|
||||||
|
if(name == null)
|
||||||
|
name = "";
|
||||||
|
|
||||||
|
if(model == null)
|
||||||
|
model = "";
|
||||||
|
|
||||||
|
if(quantity == null)
|
||||||
|
quantity = "";
|
||||||
|
|
||||||
|
if(shipping == null)
|
||||||
|
shipping = "";
|
||||||
|
|
||||||
|
if(price == null)
|
||||||
|
price = "";
|
||||||
|
|
||||||
|
if(total == null)
|
||||||
|
total = "";
|
||||||
|
|
||||||
|
if(option != null){
|
||||||
|
for(ProductOptionModel productOptionModel : option){
|
||||||
|
productOptionModel.checkNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkNull(ArrayList<CartProductModel> cartProductList){
|
||||||
|
for(CartProductModel cartProductModel : cartProductList){
|
||||||
|
cartProductModel.checkNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCartId() {
|
||||||
|
return cartId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCartId(String cartId) {
|
||||||
|
this.cartId = cartId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(String productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModel(String model) {
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(String quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShipping() {
|
||||||
|
return shipping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShipping(String shipping) {
|
||||||
|
this.shipping = shipping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(String price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(String total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(boolean stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReward() {
|
||||||
|
return reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReward(int reward) {
|
||||||
|
this.reward = reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<ProductOptionModel> getOption() {
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOption(ArrayList<ProductOptionModel> option) {
|
||||||
|
this.option = option;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package ch.pizzalink.android.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cimenmus on 05/10/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CartTotalModel {
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package ch.pizzalink.android.model;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cimenmus on 05/10/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ProductOptionModel {
|
||||||
|
|
||||||
|
@Expose @SerializedName("product_option_id") private String id;
|
||||||
|
@Expose @SerializedName("product_option_value_id") private String valueId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public void checkNull(){
|
||||||
|
|
||||||
|
if(id == null)
|
||||||
|
id = "";
|
||||||
|
|
||||||
|
if(valueId == null)
|
||||||
|
valueId = "";
|
||||||
|
|
||||||
|
if(name == null)
|
||||||
|
name = "";
|
||||||
|
|
||||||
|
if(value == null)
|
||||||
|
value = "";
|
||||||
|
|
||||||
|
if(type == null)
|
||||||
|
type = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValueId() {
|
||||||
|
return valueId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValueId(String valueId) {
|
||||||
|
this.valueId = valueId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
4
app/src/main/res/drawable/ic_cancel_2.xml
Normal file
4
app/src/main/res/drawable/ic_cancel_2.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<vector android:height="24dp" android:viewportHeight="51.976"
|
||||||
|
android:viewportWidth="51.976" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#ec1649" android:pathData="M44.37,7.6c-10.14,-10.14 -26.63,-10.14 -36.77,0c-10.14,10.14 -10.14,26.63 0,36.77s26.63,10.14 36.77,0C54.51,34.24 54.51,17.74 44.37,7.6zM36.24,36.24c-0.78,0.78 -2.05,0.78 -2.83,0l-7.43,-7.43l-7.78,7.78c-0.78,0.78 -2.05,0.78 -2.83,0c-0.78,-0.78 -0.78,-2.05 0,-2.83l7.78,-7.78l-7.43,-7.43c-0.78,-0.78 -0.78,-2.05 0,-2.83c0.78,-0.78 2.05,-0.78 2.83,0l7.43,7.43l7.07,-7.07c0.78,-0.78 2.05,-0.78 2.83,0c0.78,0.78 0.78,2.05 0,2.83l-7.07,7.07l7.43,7.43C37.02,34.19 37.02,35.46 36.24,36.24z"/>
|
||||||
|
</vector>
|
||||||
@@ -1,16 +1,100 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/cartFragmentMainLayout"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/actvity_default_background_color_1">
|
android:background="@color/actvity_default_background_color_1">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/noProductsOnCartTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Cart Fragment"
|
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:textColor="@color/black"/>
|
android:text="@string/no_product_on_cart"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/cartRecyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@+id/cartDividerSpace"/>
|
||||||
|
|
||||||
|
<android.support.v4.widget.Space
|
||||||
|
android:id="@+id/cartDividerSpace"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="12dp"
|
||||||
|
android:background="@color/red"
|
||||||
|
android:layout_above="@+id/cartInfoLayout"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/cartInfoLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:background="@color/white"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:paddingLeft="24dp"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:paddingRight="24dp"
|
||||||
|
android:paddingEnd="24dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cartTotalLabelTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="TOTAL"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cartProductTotalTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="CHF 50.00"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/clearCartButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:text="@string/clear_cart"
|
||||||
|
style="@style/PizzalinkButtonWithoutMargin"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/continueCartButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginLeft="6dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:text="@string/continue_cart"
|
||||||
|
style="@style/PizzalinkButtonWithoutMargin"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
70
app/src/main/res/layout/row_cart.xml
Normal file
70
app/src/main/res/layout/row_cart.xml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v7.widget.CardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/white"
|
||||||
|
app:cardCornerRadius="4dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginEnd="12dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cartProductNameTotalTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Pizza Formaggio"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/removeProductFromCartImageView"
|
||||||
|
android:layout_width="32dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:padding="6dp"
|
||||||
|
android:src="@drawable/ic_cancel_2"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cartProductInfoTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Gross"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
android:paddingRight="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>
|
||||||
|
|
||||||
|
</android.support.v7.widget.CardView>
|
||||||
@@ -49,8 +49,8 @@
|
|||||||
android:id="@+id/cancelOrderImageView"
|
android:id="@+id/cancelOrderImageView"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="32dp"
|
android:layout_height="32dp"
|
||||||
android:padding="10dp"
|
android:padding="6dp"
|
||||||
android:src="@drawable/ic_cancel"
|
android:src="@drawable/ic_cancel_2"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentEnd="true" />
|
android:layout_alignParentEnd="true" />
|
||||||
|
|||||||
@@ -280,7 +280,7 @@
|
|||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginRight="12dp"
|
android:layout_marginRight="12dp"
|
||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
style="@style/AddCartButton"
|
style="@style/ContinueCartButton"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:text="Add to Cart" />
|
android:text="Add to Cart" />
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,12 @@
|
|||||||
<string name="order_history_status">Status</string>
|
<string name="order_history_status">Status</string>
|
||||||
<!-- OrderHistoryFragment-->
|
<!-- OrderHistoryFragment-->
|
||||||
|
|
||||||
|
<!-- CartFragment-->
|
||||||
|
<string name="continue_cart">DEVAM</string>
|
||||||
|
<string name="clear_cart">TEMİZLE</string>
|
||||||
|
<string name="no_product_on_cart">Sepetinizde ürün bulunmamaktadır.</string>
|
||||||
|
<!-- CartFragment-->
|
||||||
|
|
||||||
<string name="alert">Uyarı</string>
|
<string name="alert">Uyarı</string>
|
||||||
<string name="error_message">Bir hata oluştu.</string>
|
<string name="error_message">Bir hata oluştu.</string>
|
||||||
<string name="no_network_message">İnternet bağlanıtısı yok. Lütfen daha sonra tekrar deneyiniz.</string>
|
<string name="no_network_message">İnternet bağlanıtısı yok. Lütfen daha sonra tekrar deneyiniz.</string>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AddCartButton">
|
<style name="ContinueCartButton">
|
||||||
<item name="android:background">@drawable/background_button_add_cart</item>
|
<item name="android:background">@drawable/background_button_add_cart</item>
|
||||||
<item name="android:textColor">@color/white</item>
|
<item name="android:textColor">@color/white</item>
|
||||||
<item name="android:textSize">12sp</item>
|
<item name="android:textSize">12sp</item>
|
||||||
@@ -21,7 +21,14 @@
|
|||||||
<item name="android:textAllCaps">false</item>
|
<item name="android:textAllCaps">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="PizzalinkButton">
|
<style name="PizzalinkButtonWithoutMargin">
|
||||||
|
<item name="android:background">@drawable/background_button_enabled</item>
|
||||||
|
<item name="android:textColor">@color/red</item>
|
||||||
|
<item name="android:textSize">12sp</item>
|
||||||
|
<item name="android:textAllCaps">false</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="PizzalinkButton" parent="PizzalinkButtonWithoutMargin">
|
||||||
<item name="android:background">@drawable/background_button_enabled</item>
|
<item name="android:background">@drawable/background_button_enabled</item>
|
||||||
<item name="android:textColor">@color/red</item>
|
<item name="android:textColor">@color/red</item>
|
||||||
<item name="android:layout_marginLeft">24dp</item>
|
<item name="android:layout_marginLeft">24dp</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user