product list on order history details

This commit is contained in:
cimenmus
2018-01-17 23:01:51 +03:00
parent 934ff298d5
commit 34bb2e10f3
13 changed files with 411 additions and 8 deletions

2
.idea/misc.xml generated
View File

@@ -24,7 +24,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -147,7 +147,7 @@ public class MainActivity extends BaseActivity {
private void showStartScreen(){
fragmentManager = getSupportFragmentManager();
if(isStartWithOrderHistory){
bottomNavigationView.setCurrentItem(2);
bottomNavigationView.setCurrentItem(1);
}
else {
openProductsScreen(categoryList.get(2));

View File

@@ -1,15 +1,29 @@
package ch.pizzalink.android.activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.api.ApiEndPoints;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.api.ResponseArray;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.PriceHelper;
import ch.pizzalink.android.model.OrderHistoryModel;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.helper.TextHelper;
import ch.pizzalink.android.model.history.OrderHistoryModel;
import ch.pizzalink.android.model.history.OrderHistoryProductModel;
import ch.pizzalink.android.model.history.OrderHistoryProductOptionModel;
import ch.pizzalink.android.view.PizzalinkInfoView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class OrderHistoryDetailsActivity extends BaseActivity {
@@ -18,12 +32,14 @@ public class OrderHistoryDetailsActivity extends BaseActivity {
@BindView(R.id.orderShippingTimePizzalinkInfoLayout) PizzalinkInfoView orderShippingTimePizzalinkInfoLayout;
@BindView(R.id.orderTotalPizzalinkInfoLayout) PizzalinkInfoView orderTotalPizzalinkInfoLayout;
@BindView(R.id.orderPaymentMethodPizzalinkInfoLayout) PizzalinkInfoView orderPaymentMethodPizzalinkInfoLayout;
@BindView(R.id.orderProductsTextView) TextView orderProductsTextView;
@BindView(R.id.orderFullnamePizzalinkInfoLayout) PizzalinkInfoView orderFullnamePizzalinkInfoLayout;
@BindView(R.id.orderShippingMethodPizzalinkInfoLayout) PizzalinkInfoView orderShippingMethodPizzalinkInfoLayout;
@BindView(R.id.orderShippingAddressPizzalinkInfoLayout) PizzalinkInfoView orderShippingAddressPizzalinkInfoLayout;
@BindView(R.id.orderNotePizzalinkInfoLayout) PizzalinkInfoView orderNotePizzalinkInfoLayout;
private OrderHistoryModel orderHistoryModel;
private ArrayList<OrderHistoryProductModel> productList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -31,6 +47,7 @@ public class OrderHistoryDetailsActivity extends BaseActivity {
setContentView(R.layout.activity_order_history_details);
ButterKnife.bind(this);
getDataFromIntent();
getOrderProductList();
initViews();
}
@@ -88,4 +105,112 @@ public class OrderHistoryDetailsActivity extends BaseActivity {
return stringBuilder.toString();
}
private void getOrderProductList(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<OrderHistoryProductModel>> call = ApiService.apiInterface.getOrderProductList(
ApiEndPoints.API_GET_ORDER_PRODUCT_LIST + SessionHelper.getCustomerToken().getToken(), orderHistoryModel.getId());
call.enqueue(new Callback<ResponseArray<OrderHistoryProductModel>>() {
@Override
public void onResponse(Call<ResponseArray<OrderHistoryProductModel>> call, Response<ResponseArray<OrderHistoryProductModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess())
fillAndNotifyProductList(response.body().getData());
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseArray<OrderHistoryProductModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyProductList(ArrayList<OrderHistoryProductModel> prdctLst){
OrderHistoryProductModel.checkNull(prdctLst);
productList.clear();
productList.addAll(prdctLst);
TextHelper.setTextFromHTML(orderProductsTextView, getProductListInfoText());
}
private String getProductListInfoText(){
StringBuilder stringBuilder = new StringBuilder();
for(OrderHistoryProductModel orderHistoryProductModel : productList){
stringBuilder
.append("<b>")
.append(orderHistoryProductModel.getQuantity())
.append(" x ")
.append(orderHistoryProductModel.getName())
.append(" = ")
.append(PriceHelper.getPriceWithCurreny(orderHistoryProductModel.getTotal()))
.append("</b>")
.append("<br/>")
.append(getProductInfo(orderHistoryProductModel))
.append("<br/>");
}
if(stringBuilder.toString().trim().endsWith("<br/><br/>")){
int lastIndex = stringBuilder.toString().lastIndexOf("<br/><br/>");
return stringBuilder.toString().trim().substring(0, lastIndex);
}
return stringBuilder.toString().trim();
}
private String getProductInfo(OrderHistoryProductModel orderHistoryProductModel){
StringBuilder stringBuilder = new StringBuilder();
for(OrderHistoryProductOptionModel orderHistoryProductOptionModel : orderHistoryProductModel.getOptionList()){
if(!stringBuilder.toString().contains(orderHistoryProductOptionModel.getName())){
/*
if(!stringBuilder.toString().isEmpty()){
stringBuilder.append("<br/>");
}
*/
stringBuilder
.append("<br/>")
.append("<u>")
.append(orderHistoryProductOptionModel.getName())
.append("</u>")
.append("<br/>");
}
stringBuilder
.append("<i>")
.append(orderHistoryProductOptionModel.getValue())
.append("</i>")
.append("<br/>");
}
return stringBuilder.toString().trim();
}
/*
private String getCartInfoText(CartProductModel cartProductModel){
StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < cartProductModel.getOption().size(); i++){
if(!stringBuilder.toString().contains(cartProductModel.getOption().get(i).getName())){
if(!stringBuilder.toString().isEmpty()){
stringBuilder.append("<br/>");
}
stringBuilder
.append("<b>")
.append("<u>")
.append(cartProductModel.getOption().get(i).getName())
.append("</u>")
.append("</b>")
.append("<br/>")
.append("<br/>");
}
stringBuilder
.append(cartProductModel.getOption().get(i).getValue())
.append("<br/>");
}
return stringBuilder.toString().trim();
}
*/
}

View File

@@ -13,7 +13,7 @@ import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.helper.PriceHelper;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.OrderHistoryModel;
import ch.pizzalink.android.model.history.OrderHistoryModel;
/**
* Created by cimenmus on 04/10/2017.

View File

@@ -33,4 +33,5 @@ public class ApiEndPoints {
public static final String API_UPDATE_PROFILE = PREFIX + "updateCustomerInfo" + SUFFIX + "&token=";
public static final String API_REMOVE_RPODUCT_FORM_CART = PREFIX + "removeProductFromBasket" + SUFFIX + "&token=";
public static final String API_GET_STORE_INFO = PREFIX + "getStoreInfo" + SUFFIX;
public static final String API_GET_ORDER_PRODUCT_LIST = PREFIX + "getOrderProducts" + SUFFIX;
}

View File

@@ -16,8 +16,9 @@ import ch.pizzalink.android.model.CityModel;
import ch.pizzalink.android.model.ZoneModel;
import ch.pizzalink.android.model.cart.CartInfoModel;
import ch.pizzalink.android.model.CategoryModel;
import ch.pizzalink.android.model.OrderHistoryModel;
import ch.pizzalink.android.model.history.OrderHistoryModel;
import ch.pizzalink.android.model.UserModel;
import ch.pizzalink.android.model.history.OrderHistoryProductModel;
import ch.pizzalink.android.model.menu.MenuProductModel;
import okhttp3.RequestBody;
import retrofit2.Call;
@@ -136,4 +137,9 @@ public interface ApiInterface {
@GET(ApiEndPoints.API_GET_STORE_INFO)
Call<ResponseObject<StoreInfoModel>> getStoreInfo();
@FormUrlEncoded
@POST
Call<ResponseArray<OrderHistoryProductModel>> getOrderProductList(@Url String url,
@Field("order_id") String orderId);
}

View File

@@ -23,7 +23,7 @@ import ch.pizzalink.android.api.ResponseArray;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.OrderHistoryModel;
import ch.pizzalink.android.model.history.OrderHistoryModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

View File

@@ -117,6 +117,12 @@ public class PriceHelper {
else if(price.endsWith(".00")){
price = price.replace(".00", ".-");
}
else if(price.endsWith(".000")){
price = price.replace(".000", ".-");
}
else if(price.endsWith(".0000")){
price = price.replace(".0000", ".-");
}
return price;
}

View File

@@ -1,4 +1,4 @@
package ch.pizzalink.android.model;
package ch.pizzalink.android.model.history;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

View File

@@ -0,0 +1,121 @@
package ch.pizzalink.android.model.history;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
* Created by cimenmus on 17.01.2018.
*/
public class OrderHistoryProductModel {
@SerializedName("product_id") private String productId;
@SerializedName("option") private ArrayList<OrderHistoryProductOptionModel> optionList;
private String name;
private String model;
private String quantity;
private String price;
private String total;
private String reward;
private void checkNull(){
if(productId == null){
productId = "";
}
if(name == null){
name = "";
}
if(model == null){
model = "";
}
if(quantity == null){
quantity = "";
}
if(price == null){
price = "";
}
if(total == null){
total = "";
}
if(reward == null){
reward = "";
}
if(optionList == null){
optionList = new ArrayList<>();
}
else{
OrderHistoryProductOptionModel.checkNull(optionList);
}
}
public static void checkNull(ArrayList<OrderHistoryProductModel> orderHistoryProductModels){
for(OrderHistoryProductModel orderHistoryProductModel : orderHistoryProductModels){
orderHistoryProductModel.checkNull();
}
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public ArrayList<OrderHistoryProductOptionModel> getOptionList() {
return optionList;
}
public void setOptionList(ArrayList<OrderHistoryProductOptionModel> optionList) {
this.optionList = optionList;
}
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 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 String getReward() {
return reward;
}
public void setReward(String reward) {
this.reward = reward;
}
}

View File

@@ -0,0 +1,119 @@
package ch.pizzalink.android.model.history;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
* Created by cimenmus on 17.01.2018.
*/
public class OrderHistoryProductOptionModel {
@SerializedName("order_option_id") private String optionId;
@Expose @SerializedName("order_id") private String orderId;
@Expose @SerializedName("order_product_id") private String productId;
@Expose @SerializedName("product_option_id") private String productOptionId;
@Expose @SerializedName("product_option_value_id") private String productOptionValueId;
private String name;
private String value;
private String type;
private void checkNull(){
if(optionId == null){
optionId = "";
}
if(orderId == null){
orderId = "";
}
if(productId == null){
productId = "";
}
if(productOptionId == null){
productOptionId = "";
}
if(productOptionValueId == null){
productOptionValueId = "";
}
if(name == null){
name = "";
}
if(value == null){
value = "";
}
if(type == null){
type = "";
}
}
public static void checkNull(ArrayList<OrderHistoryProductOptionModel> orderHistoryProductOptionModels){
for(OrderHistoryProductOptionModel orderHistoryProductOptionModel : orderHistoryProductOptionModels){
orderHistoryProductOptionModel.checkNull();
}
}
public String getOptionId() {
return optionId;
}
public void setOptionId(String optionId) {
this.optionId = optionId;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getProductOptionId() {
return productOptionId;
}
public void setProductOptionId(String productOptionId) {
this.productOptionId = productOptionId;
}
public String getProductOptionValueId() {
return productOptionValueId;
}
public void setProductOptionValueId(String productOptionValueId) {
this.productOptionValueId = productOptionValueId;
}
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;
}
}

View File

@@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingPrefix"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -82,6 +83,29 @@
android:layout_height="wrap_content"
app:description="@string/order_history_order_payment_method" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<TextView
fontPath="fonts/Quicksand-Bold.ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_products"
android:textColor="@color/navy"
android:textSize="12sp" />
<TextView
android:id="@+id/orderProductsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textColor="@color/red" />
</LinearLayout>
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/orderFullnamePizzalinkInfoLayout"
android:layout_width="match_parent"

View File

@@ -108,6 +108,7 @@
<string name="order_history_order_shipping_time">VERSANDZEIT</string>    
<string name="order_history_order_total">ZWISHENSUMME</string>    
<string name="order_history_order_payment_method">ZAHLUNGSWEISE</string>    
<string name="order_products">PRODUCTS</string>    
<string name="order_history_order_fullname">VOLLNAME</string>    
<string name="order_history_order_shipping_method">LIEFERUNGSMETHODE</string>    
<string name="order_history_order_shipping_address">LIEFERUNGSADRESSE</string>