repeat order
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@@ -12,8 +12,8 @@ android {
|
|||||||
applicationId "ch.pizzapp.capri"
|
applicationId "ch.pizzapp.capri"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 9 // play store'daki version --> canlı : 8 dahili test: 6
|
versionCode 10 // play store'daki version --> canlı: 8 - dahili test: 6
|
||||||
versionName "2.11" // play store'daki version : 2.1
|
versionName "2.12" // play store'daki version --> canlı: 2.1 - dahili test: 2.11
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":8,"versionName":"2.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":9,"versionName":"2.11","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||||
@@ -71,7 +71,7 @@ public class MainActivity extends BaseActivity {
|
|||||||
private FragmentManager fragmentManager;
|
private FragmentManager fragmentManager;
|
||||||
private String currentFragmentName = "";
|
private String currentFragmentName = "";
|
||||||
private int currentCategoryId = -1;
|
private int currentCategoryId = -1;
|
||||||
private boolean isStartWithOrderHistory;
|
private boolean isStartWithOrderHistory, isStartWithCart;
|
||||||
private ArrayList<CategoryModel> categoryList = new ArrayList<>();
|
private ArrayList<CategoryModel> categoryList = new ArrayList<>();
|
||||||
private NavigationMenuRecyclerAdapter navigationMenuRecyclerAdapter;
|
private NavigationMenuRecyclerAdapter navigationMenuRecyclerAdapter;
|
||||||
//private Badge badge;
|
//private Badge badge;
|
||||||
@@ -101,6 +101,7 @@ public class MainActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void getDataFromIntent(){
|
private void getDataFromIntent(){
|
||||||
isStartWithOrderHistory = getIntent().getBooleanExtra("isStartWithOrderHistory", false);
|
isStartWithOrderHistory = getIntent().getBooleanExtra("isStartWithOrderHistory", false);
|
||||||
|
isStartWithCart = getIntent().getBooleanExtra("isStartWithCart", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews(){
|
private void initViews(){
|
||||||
@@ -161,6 +162,9 @@ public class MainActivity extends BaseActivity {
|
|||||||
if(isStartWithOrderHistory){
|
if(isStartWithOrderHistory){
|
||||||
bottomNavigationView.setCurrentItem(1);
|
bottomNavigationView.setCurrentItem(1);
|
||||||
}
|
}
|
||||||
|
else if(isStartWithCart){
|
||||||
|
bottomNavigationView.setCurrentItem(2);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
openProductsScreen(categoryList.get(3));
|
openProductsScreen(categoryList.get(3));
|
||||||
}
|
}
|
||||||
@@ -445,7 +449,8 @@ public class MainActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCartItemCount(){
|
public void setCartItemCount(){
|
||||||
addBadgeAt(2, SharedPrefsHelper.getCartItemCount());
|
updateBadge();
|
||||||
|
updateCartTotalRelativeLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reopenCartFragment(){
|
public void reopenCartFragment(){
|
||||||
@@ -454,23 +459,13 @@ public class MainActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private void addBadgeAt(int position, int number) {
|
private void addBadge(int position, int number) {
|
||||||
badge.setBadgeNumber(number);
|
badge.setBadgeNumber(number);
|
||||||
badge.bindTarget(bottomNavigationView.getBottomNavigationItemView(position));
|
badge.bindTarget(bottomNavigationView.getBottomNavigationItemView(position));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void addBadgeAt(int position, int number) {
|
private void updateCartTotalRelativeLayout() {
|
||||||
|
|
||||||
badgeTextView.setText(String.valueOf(number));
|
|
||||||
|
|
||||||
if(number <= 0){
|
|
||||||
badgeLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
badgeLayout.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SharedPrefsHelper.getCartTotalPrice().equals("0") ||
|
if(SharedPrefsHelper.getCartTotalPrice().equals("0") ||
|
||||||
SharedPrefsHelper.getCartTotalPrice().equals("0.0") ||
|
SharedPrefsHelper.getCartTotalPrice().equals("0.0") ||
|
||||||
SharedPrefsHelper.getCartTotalPrice().equals("0.00")){
|
SharedPrefsHelper.getCartTotalPrice().equals("0.00")){
|
||||||
@@ -483,4 +478,30 @@ public class MainActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateBadge(){
|
||||||
|
int count = SharedPrefsHelper.getCartItemCount();
|
||||||
|
badgeTextView.setText(String.valueOf(count));
|
||||||
|
|
||||||
|
if(count <= 0){
|
||||||
|
badgeLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
badgeLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openFragmentAt(int position){
|
||||||
|
currentFragmentName = "";
|
||||||
|
bottomNavigationView.setCurrentItem(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCartTotalLayoutVisibility(boolean isVisible){
|
||||||
|
if(isVisible){
|
||||||
|
cartTotalRelativeLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cartTotalRelativeLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
package ch.pizzapp.android.activity;
|
package ch.pizzapp.android.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
import ch.pizzapp.android.R;
|
import ch.pizzapp.android.R;
|
||||||
import ch.pizzapp.android.api.ApiEndPoints;
|
import ch.pizzapp.android.api.ApiEndPoints;
|
||||||
import ch.pizzapp.android.api.ApiErrorUtils;
|
import ch.pizzapp.android.api.ApiErrorUtils;
|
||||||
import ch.pizzapp.android.api.ApiService;
|
import ch.pizzapp.android.api.ApiService;
|
||||||
import ch.pizzapp.android.api.ResponseArray;
|
import ch.pizzapp.android.api.ResponseArray;
|
||||||
|
import ch.pizzapp.android.api.ResponseObject;
|
||||||
import ch.pizzapp.android.helper.DialogHelper;
|
import ch.pizzapp.android.helper.DialogHelper;
|
||||||
import ch.pizzapp.android.helper.PriceHelper;
|
import ch.pizzapp.android.helper.PriceHelper;
|
||||||
import ch.pizzapp.android.helper.SessionHelper;
|
import ch.pizzapp.android.helper.SessionHelper;
|
||||||
@@ -27,24 +31,16 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class OrderHistoryDetailsActivity extends BaseActivity {
|
public class OrderHistoryDetailsActivity extends BaseActivity {
|
||||||
|
|
||||||
@BindView(R.id.orderDatePizzalinkInfoLayout)
|
@BindView(R.id.orderDatePizzalinkInfoLayout) AppInfoView orderDatePizzalinkInfoLayout;
|
||||||
AppInfoView orderDatePizzalinkInfoLayout;
|
|
||||||
//@BindView(R.id.orderStatusPizzalinkInfoLayout) PizzalinkInfoView orderStatusPizzalinkInfoLayout;
|
//@BindView(R.id.orderStatusPizzalinkInfoLayout) PizzalinkInfoView orderStatusPizzalinkInfoLayout;
|
||||||
@BindView(R.id.orderShippingTimePizzalinkInfoLayout)
|
@BindView(R.id.orderShippingTimePizzalinkInfoLayout) AppInfoView orderShippingTimePizzalinkInfoLayout;
|
||||||
AppInfoView orderShippingTimePizzalinkInfoLayout;
|
@BindView(R.id.orderTotalPizzalinkInfoLayout) AppInfoView orderTotalPizzalinkInfoLayout;
|
||||||
@BindView(R.id.orderTotalPizzalinkInfoLayout)
|
@BindView(R.id.orderPaymentMethodPizzalinkInfoLayout) AppInfoView orderPaymentMethodPizzalinkInfoLayout;
|
||||||
AppInfoView orderTotalPizzalinkInfoLayout;
|
|
||||||
@BindView(R.id.orderPaymentMethodPizzalinkInfoLayout)
|
|
||||||
AppInfoView orderPaymentMethodPizzalinkInfoLayout;
|
|
||||||
@BindView(R.id.orderProductsTextView) TextView orderProductsTextView;
|
@BindView(R.id.orderProductsTextView) TextView orderProductsTextView;
|
||||||
@BindView(R.id.orderFullnamePizzalinkInfoLayout)
|
@BindView(R.id.orderFullnamePizzalinkInfoLayout) AppInfoView orderFullnamePizzalinkInfoLayout;
|
||||||
AppInfoView orderFullnamePizzalinkInfoLayout;
|
@BindView(R.id.orderShippingMethodPizzalinkInfoLayout) AppInfoView orderShippingMethodPizzalinkInfoLayout;
|
||||||
@BindView(R.id.orderShippingMethodPizzalinkInfoLayout)
|
@BindView(R.id.orderShippingAddressPizzalinkInfoLayout) AppInfoView orderShippingAddressPizzalinkInfoLayout;
|
||||||
AppInfoView orderShippingMethodPizzalinkInfoLayout;
|
@BindView(R.id.orderNotePizzalinkInfoLayout) AppInfoView orderNotePizzalinkInfoLayout;
|
||||||
@BindView(R.id.orderShippingAddressPizzalinkInfoLayout)
|
|
||||||
AppInfoView orderShippingAddressPizzalinkInfoLayout;
|
|
||||||
@BindView(R.id.orderNotePizzalinkInfoLayout)
|
|
||||||
AppInfoView orderNotePizzalinkInfoLayout;
|
|
||||||
|
|
||||||
private OrderHistoryModel orderHistoryModel;
|
private OrderHistoryModel orderHistoryModel;
|
||||||
private ArrayList<OrderHistoryProductModel> productList = new ArrayList<>();
|
private ArrayList<OrderHistoryProductModel> productList = new ArrayList<>();
|
||||||
@@ -59,6 +55,11 @@ public class OrderHistoryDetailsActivity extends BaseActivity {
|
|||||||
initViews();
|
initViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.repeatOrderButton)
|
||||||
|
public void onClick(){
|
||||||
|
clearCart();
|
||||||
|
}
|
||||||
|
|
||||||
private void getDataFromIntent(){
|
private void getDataFromIntent(){
|
||||||
orderHistoryModel = (OrderHistoryModel) getIntent().getSerializableExtra("orderHistoryModel");
|
orderHistoryModel = (OrderHistoryModel) getIntent().getSerializableExtra("orderHistoryModel");
|
||||||
}
|
}
|
||||||
@@ -192,6 +193,75 @@ public class OrderHistoryDetailsActivity extends BaseActivity {
|
|||||||
return stringBuilder.toString().trim();
|
return stringBuilder.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
if(response.isSuccessful() && response.body().isSuccess()){
|
||||||
|
/*
|
||||||
|
cartProductList.clear();
|
||||||
|
cartRecyclerAdapter.notifyDataSetChanged();
|
||||||
|
setCartLayoutsVisibility();
|
||||||
|
SharedPrefsHelper.setCartItemCount(0);
|
||||||
|
SharedPrefsHelper.setCartTotalPrice("0");
|
||||||
|
SharedPrefsHelper.setUserUsedPizzapassCampaign(false);
|
||||||
|
SharedPrefsHelper.setUserUsedChampagneCampaign(false);
|
||||||
|
MainActivity mainActivity = (MainActivity) getActivity();
|
||||||
|
mainActivity.setCartItemCount();
|
||||||
|
*/
|
||||||
|
repeatOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
ApiErrorUtils.parseError(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<ResponseObject> call, Throwable t) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
DialogHelper.showFailedDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void repeatOrder(){
|
||||||
|
|
||||||
|
HashMap<String, Object> params = new HashMap<>();
|
||||||
|
params.put("order_id", orderHistoryModel.getId());
|
||||||
|
|
||||||
|
Call<ResponseObject> call = ApiService.apiInterface.repeatOrder(
|
||||||
|
ApiEndPoints.API_REPEAT_ORDER + SessionHelper.getCustomerToken().getToken(),
|
||||||
|
params);
|
||||||
|
call.enqueue(new Callback<ResponseObject>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<ResponseObject> call, final Response<ResponseObject> response) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
if(response.isSuccessful() &&
|
||||||
|
response.body().getData() != null &&
|
||||||
|
response.body().isSuccess()){
|
||||||
|
Intent basketIntent = new Intent(OrderHistoryDetailsActivity.this, MainActivity.class);
|
||||||
|
basketIntent.putExtra("isStartWithCart", true);
|
||||||
|
startActivity(basketIntent);
|
||||||
|
finishAffinity();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ApiErrorUtils.parseError(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<ResponseObject> call, Throwable t) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
DialogHelper.showFailedDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private String getCartInfoText(CartProductModel cartProductModel){
|
private String getCartInfoText(CartProductModel cartProductModel){
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class OrderHistoryRecyclerAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
|
|
||||||
@BindView(R.id.orderDateTextView) TextView orderDateTextView;
|
@BindView(R.id.orderDateTextView) TextView orderDateTextView;
|
||||||
@BindView(R.id.orderTotalTextView) TextView orderTotalTextView;
|
@BindView(R.id.orderTotalTextView) TextView orderTotalTextView;
|
||||||
|
@BindView(R.id.repeatOrderTextView) TextView repeatOrderTextView;
|
||||||
//@BindView(R.id.orderStatusTextView) TextView orderStatusTextView;
|
//@BindView(R.id.orderStatusTextView) TextView orderStatusTextView;
|
||||||
|
|
||||||
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||||
@@ -44,6 +45,14 @@ public class OrderHistoryRecyclerAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
repeatOrderTextView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if(recyclerItemClickListener != null){
|
||||||
|
recyclerItemClickListener.onItemClick(repeatOrderTextView, getAdapterPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,4 +40,5 @@ public class ApiEndPoints {
|
|||||||
public static final String API_CHECK_CAMPAIGN_CHAMPAGNE = PREFIX + "detectChampagneCampaign" + SUFFIX + "&token=";
|
public static final String API_CHECK_CAMPAIGN_CHAMPAGNE = PREFIX + "detectChampagneCampaign" + SUFFIX + "&token=";
|
||||||
public static final String API_CHECK_DELIVERY_TIME = PREFIX + "checkDeliveryTimeService" + SUFFIX;
|
public static final String API_CHECK_DELIVERY_TIME = PREFIX + "checkDeliveryTimeService" + SUFFIX;
|
||||||
public static final String API_CREATE_PAYMENT = PREFIX + "checkBrainTreePayment" + SUFFIX + "&token=";
|
public static final String API_CREATE_PAYMENT = PREFIX + "checkBrainTreePayment" + SUFFIX + "&token=";
|
||||||
|
public static final String API_REPEAT_ORDER = PREFIX + "reOrder" + SUFFIX + "&token=";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,4 +173,8 @@ public interface ApiInterface {
|
|||||||
@POST
|
@POST
|
||||||
Call<ResponseObject> createPayment(@Url String url, @FieldMap HashMap<String, Object> body);
|
Call<ResponseObject> createPayment(@Url String url, @FieldMap HashMap<String, Object> body);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST
|
||||||
|
Call<ResponseObject> repeatOrder(@Url String url, @FieldMap HashMap<String, Object> body);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,11 @@ public class CartFragment extends BaseFragment {
|
|||||||
response.body().getData() != null &&
|
response.body().getData() != null &&
|
||||||
response.body().isSuccess()){
|
response.body().isSuccess()){
|
||||||
cartInfoModel = response.body().getData();
|
cartInfoModel = response.body().getData();
|
||||||
|
SharedPrefsHelper.setCartItemCount(cartInfoModel.getProducts().size());
|
||||||
|
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(cartInfoModel.getCartTotalModel().getText()));
|
||||||
|
MainActivity mainActivity = (MainActivity) getActivity();
|
||||||
|
mainActivity.updateBadge();
|
||||||
|
mainActivity.setCartTotalLayoutVisibility(false);
|
||||||
setCartTotalFields();
|
setCartTotalFields();
|
||||||
fillAndNotifyAdapter();
|
fillAndNotifyAdapter();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,19 +9,24 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import butterknife.BindString;
|
import butterknife.BindString;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import ch.pizzapp.android.R;
|
import ch.pizzapp.android.R;
|
||||||
import ch.pizzapp.android.activity.BaseActivity;
|
import ch.pizzapp.android.activity.BaseActivity;
|
||||||
|
import ch.pizzapp.android.activity.MainActivity;
|
||||||
import ch.pizzapp.android.activity.OrderHistoryDetailsActivity;
|
import ch.pizzapp.android.activity.OrderHistoryDetailsActivity;
|
||||||
import ch.pizzapp.android.adapter.recycler.OrderHistoryRecyclerAdapter;
|
import ch.pizzapp.android.adapter.recycler.OrderHistoryRecyclerAdapter;
|
||||||
|
import ch.pizzapp.android.api.ApiEndPoints;
|
||||||
import ch.pizzapp.android.api.ApiErrorUtils;
|
import ch.pizzapp.android.api.ApiErrorUtils;
|
||||||
import ch.pizzapp.android.api.ApiService;
|
import ch.pizzapp.android.api.ApiService;
|
||||||
import ch.pizzapp.android.api.ResponseArray;
|
import ch.pizzapp.android.api.ResponseArray;
|
||||||
|
import ch.pizzapp.android.api.ResponseObject;
|
||||||
import ch.pizzapp.android.helper.DialogHelper;
|
import ch.pizzapp.android.helper.DialogHelper;
|
||||||
import ch.pizzapp.android.helper.SessionHelper;
|
import ch.pizzapp.android.helper.SessionHelper;
|
||||||
|
import ch.pizzapp.android.helper.SharedPrefsHelper;
|
||||||
import ch.pizzapp.android.interfaces.RecyclerItemClickListener;
|
import ch.pizzapp.android.interfaces.RecyclerItemClickListener;
|
||||||
import ch.pizzapp.android.model.history.OrderHistoryModel;
|
import ch.pizzapp.android.model.history.OrderHistoryModel;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@@ -72,9 +77,15 @@ public class OrderHistoryFragment extends BaseFragment {
|
|||||||
orderHistoryRecyclerAdapter = new OrderHistoryRecyclerAdapter(orderHistoryList, new RecyclerItemClickListener() {
|
orderHistoryRecyclerAdapter = new OrderHistoryRecyclerAdapter(orderHistoryList, new RecyclerItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(View view, int position) {
|
public void onItemClick(View view, int position) {
|
||||||
Intent orderHistoryDetailsIntent = new Intent(BaseActivity.currentActivity, OrderHistoryDetailsActivity.class);
|
switch (view.getId()){
|
||||||
orderHistoryDetailsIntent.putExtra("orderHistoryModel", orderHistoryList.get(position));
|
case R.id.repeatOrderTextView:
|
||||||
startActivity(orderHistoryDetailsIntent);
|
clearCart(orderHistoryList.get(position).getId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Intent orderHistoryDetailsIntent = new Intent(BaseActivity.currentActivity, OrderHistoryDetailsActivity.class);
|
||||||
|
orderHistoryDetailsIntent.putExtra("orderHistoryModel", orderHistoryList.get(position));
|
||||||
|
startActivity(orderHistoryDetailsIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
|
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
|
||||||
@@ -141,4 +152,72 @@ public class OrderHistoryFragment extends BaseFragment {
|
|||||||
orderHistoryList.addAll(orderList);
|
orderHistoryList.addAll(orderList);
|
||||||
orderHistoryRecyclerAdapter.notifyDataSetChanged();
|
orderHistoryRecyclerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clearCart(final String orderId){
|
||||||
|
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) {
|
||||||
|
if(response.isSuccessful() && response.body().isSuccess()){
|
||||||
|
/*
|
||||||
|
cartProductList.clear();
|
||||||
|
cartRecyclerAdapter.notifyDataSetChanged();
|
||||||
|
setCartLayoutsVisibility();
|
||||||
|
SharedPrefsHelper.setCartItemCount(0);
|
||||||
|
SharedPrefsHelper.setCartTotalPrice("0");
|
||||||
|
SharedPrefsHelper.setUserUsedPizzapassCampaign(false);
|
||||||
|
SharedPrefsHelper.setUserUsedChampagneCampaign(false);
|
||||||
|
MainActivity mainActivity = (MainActivity) getActivity();
|
||||||
|
mainActivity.setCartItemCount();
|
||||||
|
*/
|
||||||
|
repeatOrder(orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
ApiErrorUtils.parseError(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<ResponseObject> call, Throwable t) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
DialogHelper.showFailedDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void repeatOrder(String orderId){
|
||||||
|
|
||||||
|
HashMap<String, Object> params = new HashMap<>();
|
||||||
|
params.put("order_id", orderId);
|
||||||
|
|
||||||
|
Call<ResponseObject> call = ApiService.apiInterface.repeatOrder(
|
||||||
|
ApiEndPoints.API_REPEAT_ORDER + SessionHelper.getCustomerToken().getToken(),
|
||||||
|
params);
|
||||||
|
call.enqueue(new Callback<ResponseObject>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<ResponseObject> call, final Response<ResponseObject> response) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
if(response.isSuccessful() &&
|
||||||
|
response.body().getData() != null &&
|
||||||
|
response.body().isSuccess()){
|
||||||
|
MainActivity mainActivity = (MainActivity) getActivity();
|
||||||
|
mainActivity.openFragmentAt(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ApiErrorUtils.parseError(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<ResponseObject> call, Throwable t) {
|
||||||
|
DialogHelper.hideLoadingDialog();
|
||||||
|
DialogHelper.showFailedDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,16 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:description="@string/order_history_order_note" />
|
app:description="@string/order_history_order_note" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/repeatOrderButton"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:background="@drawable/background_button_pizzapp_gray"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:text="@string/repeat_order_uppercased"/>
|
||||||
|
|
||||||
<android.support.v4.widget.Space
|
<android.support.v4.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="96dp" />
|
android:layout_height="96dp" />
|
||||||
|
|||||||
@@ -15,52 +15,95 @@
|
|||||||
android:layout_marginRight="12dp"
|
android:layout_marginRight="12dp"
|
||||||
android:layout_marginEnd="12dp">
|
android:layout_marginEnd="12dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="12dp">
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
android:paddingEnd="12dp">
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:id="@+id/orderDateTextView"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="@color/red"
|
|
||||||
android:padding="8dp"
|
|
||||||
fontPath="fonts/Quicksand-Bold.ttf"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_centerVertical="true"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentEnd="true">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/orderTotalTextView"
|
android:id="@+id/orderDateTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/red"
|
||||||
android:layout_marginLeft="32dp"
|
|
||||||
android:layout_marginStart="32dp"
|
|
||||||
fontPath="fonts/Quicksand-Bold.ttf"
|
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:layout_gravity="center_vertical"/>
|
fontPath="fonts/Quicksand-Bold.ttf"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:text="3 Juli 2018"
|
||||||
|
android:layout_centerVertical="true"/>
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/arrow"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="24dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="24dp"
|
android:orientation="horizontal"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_alignParentRight="true"
|
||||||
android:src="@drawable/ic_back"
|
android:layout_alignParentEnd="true">
|
||||||
android:tint="@color/black"
|
|
||||||
android:padding="6dp"
|
|
||||||
android:rotation="180"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:id="@+id/orderTotalTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:layout_marginLeft="32dp"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:text="CHF 36.50"
|
||||||
|
fontPath="fonts/Quicksand-Bold.ttf"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
<ImageView
|
||||||
|
android:id="@+id/arrow"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_back"
|
||||||
|
android:tint="@color/black"
|
||||||
|
android:padding="6dp"
|
||||||
|
android:rotation="180"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/repeatOrderTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
android:paddingEnd="12dp"
|
||||||
|
android:text="@string/repeat_order_lowercased"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
fontPath="fonts/Quicksand-Bold.ttf"
|
||||||
|
android:textColor="@color/main_black"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:background="@drawable/background_button_pizzapp_gray"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:text="@string/repeat_order_lowercased"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
|
|||||||
@@ -111,6 +111,7 @@
|
|||||||
<string name="order_history_total">Gesamtbetrag :</string>
|
<string name="order_history_total">Gesamtbetrag :</string>
|
||||||
<string name="order_history_date">Datum</string>
|
<string name="order_history_date">Datum</string>
|
||||||
<string name="order_history_status">Status</string>
|
<string name="order_history_status">Status</string>
|
||||||
|
<string name="repeat_order_lowercased"><u>Bestellung Wiederholen</u></string>
|
||||||
<!-- OrderHistoryFragment-->
|
<!-- OrderHistoryFragment-->
|
||||||
|
|
||||||
<!-- OrderHistoryDetailsActivity-->
|
<!-- OrderHistoryDetailsActivity-->
|
||||||
@@ -125,6 +126,7 @@
|
|||||||
<string name="order_history_order_shipping_method">LIEFERUNGSMETHODE</string>
|
<string name="order_history_order_shipping_method">LIEFERUNGSMETHODE</string>
|
||||||
<string name="order_history_order_shipping_address">LIEFERUNGSADRESSE</string>
|
<string name="order_history_order_shipping_address">LIEFERUNGSADRESSE</string>
|
||||||
<string name="order_history_order_note">NACHRICHT</string>
|
<string name="order_history_order_note">NACHRICHT</string>
|
||||||
|
<string name="repeat_order_uppercased">BESTELLUNG WIEDERHOLEN</string>
|
||||||
<!-- OrderHistoryDetailsActivity-->
|
<!-- OrderHistoryDetailsActivity-->
|
||||||
|
|
||||||
<!-- CreateOrderActivity -->
|
<!-- CreateOrderActivity -->
|
||||||
|
|||||||
Reference in New Issue
Block a user