order services

This commit is contained in:
cimenmus
2017-10-21 21:23:17 +03:00
parent eb6b9b9bb9
commit 1283fbb631
25 changed files with 482 additions and 175 deletions

1
.idea/modules.xml generated
View File

@@ -4,6 +4,7 @@
<modules>
<module fileurl="file://$PROJECT_DIR$/Pizzalink.iml" filepath="$PROJECT_DIR$/Pizzalink.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/pizzalink-android.iml" filepath="$PROJECT_DIR$/pizzalink-android.iml" />
</modules>
</component>
</project>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.pizzalink.android">
<uses-permission android:name="android.permission.INTERNET" />
@@ -12,19 +13,39 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<activity android:name=".activity.SplashActivity">
<activity
android:name=".activity.SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.WelcomeActivity" />
<activity android:name=".activity.LoginActivity" />
<activity android:name=".activity.RegisterActivity" />
<activity android:name=".activity.MainActivity" />
<activity android:name=".activity.OrderActivity" />
<activity android:name=".activity.ForgotPasswordActivity"></activity>
<activity
android:name=".activity.WelcomeActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activity.LoginActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activity.RegisterActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activity.MainActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activity.OrderActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activity.ForgotPasswordActivity"
android:screenOrientation="portrait"/>
</application>
</manifest>

View File

@@ -27,12 +27,8 @@ public class OrderActivity extends BaseActivity {
@BindView(R.id.orderToolbar) PizzalinkToolbar orderToolbar;
@BindView(R.id.stepperIndicator) StepperIndicator stepperIndicator;
@BindView(R.id.previousTextView) TextView previousTextView;
@BindView(R.id.nextTextView) TextView nextTextView;
private FragmentManager fragmentManager;
private String currentFragmentName = "";
private int currentPosition;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -42,31 +38,6 @@ public class OrderActivity extends BaseActivity {
initViews();
}
@OnClick({R.id.previousTextView, R.id.nextTextView})
protected void onClick(View view){
switch (view.getId()){
case R.id.previousTextView:
if(currentPosition == 0){
onBackPressed();
break;
}
openFragment(--currentPosition);
break;
case R.id.nextTextView:
if(currentPosition == 4){
Intent mainActivityIntent = new Intent(this, MainActivity.class);
mainActivityIntent.putExtra("isStartWithOrderHistory", true);
startActivity(mainActivityIntent);
SharedPrefsHelper.setCartItemCount(0);
finishAffinity();
break;
}
openFragment(++currentPosition);
break;
}
}
private void initViews(){
orderToolbar.setBackIconClickListener(new View.OnClickListener() {
@Override
@@ -118,21 +89,67 @@ public class OrderActivity extends BaseActivity {
break;
}
stepperIndicator.setCurrentStep(position);
}
public void onNextClicked(String clickedFragmentName){
switch (clickedFragmentName){
case ShippingMethodFragment.FRAGMENT_NAME:
openFragment(1);
break;
case ShippingAddressFragment.FRAGMENT_NAME:
openFragment(2);
break;
case PaymentMethodFragment.FRAGMENT_NAME:
openFragment(3);
break;
case OrderSummaryFragment.FRAGMENT_NAME:
openFragment(4);
break;
case OrderResultFragment.FRAGMENT_NAME:
Intent mainActivityIntent = new Intent(this, MainActivity.class);
mainActivityIntent.putExtra("isStartWithOrderHistory", true);
startActivity(mainActivityIntent);
SharedPrefsHelper.setCartItemCount(0);
finishAffinity();
break;
}
}
public void onPreviousClicked(String clickedFragmentName){
switch (clickedFragmentName){
case ShippingAddressFragment.FRAGMENT_NAME:
openFragment(0);
break;
case PaymentMethodFragment.FRAGMENT_NAME:
openFragment(1);
break;
case OrderSummaryFragment.FRAGMENT_NAME:
openFragment(2);
break;
}
}
public void setShippingInfo(){
}
/*
private void initOrderViewPager(){
orderPagerAdapter = new OrderPagerAdapter(getSupportFragmentManager());
orderViewPager.setAdapter(orderPagerAdapter);
stepperIndicator.setViewPager(orderViewPager, true);
stepperIndicator.setCurrentStep();
stepperIndicator.addOnStepClickListener(new StepperIndicator.OnStepClickListener() {
@Override
public void onStepClicked(int step) {
orderViewPager.setCurrentItem(step, true);
public void getShippingMethodTitle(){
}
});
public void getShippingMethodCode(){
}
public void setPaymentInfo(){
}
public void getPaymentMethodTitle(){
}
public void getPaymentMethodCode(){
}
*/
}

View File

@@ -100,7 +100,7 @@ public class PaymentMethodsRecyclerAdapter extends RecyclerView.Adapter<Recycler
switch (holder.getItemViewType()){
case HOLDER_PAYMENT_METHOD :
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
orderViewHolder.paymentMethodRadioButton.setText(paymentMethodList.get(position).getName());
orderViewHolder.paymentMethodRadioButton.setText(paymentMethodList.get(position).getTitle());
orderViewHolder.paymentMethodRadioButton.setChecked(paymentMethodList.get(position).isSelected());
break;

View File

@@ -101,8 +101,8 @@ public class ShippingMethodsRecyclerAdapter extends RecyclerView.Adapter<Recycle
switch (holder.getItemViewType()){
case HOLDER_SHIPPING_METHOD :
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
orderViewHolder.shipmentMethodPriceTextView.setText(shippingMethodList.get(position).getPrice());
orderViewHolder.shipmentMethodRadioButton.setText(shippingMethodList.get(position).getName());
orderViewHolder.shipmentMethodPriceTextView.setText(shippingMethodList.get(position).getPriceText());
orderViewHolder.shipmentMethodRadioButton.setText(shippingMethodList.get(position).getTitle());
orderViewHolder.shipmentMethodRadioButton.setChecked(shippingMethodList.get(position).isSelected());
break;

View File

@@ -15,9 +15,9 @@ public class ApiEndPoints {
public static final String API_GET_PRODUCTS_BY_CATEGORY = PREFIX + "getProductsByCategory" + SUFFIX;
public static final String API_GET_PRODUCT = PREFIX + "getProduct" + SUFFIX;
public static final String API_ADD_PRODUCTS_TO_BASKET = PREFIX + "addProductsToBasket" + SUFFIX + "&token=";
public static final String API_GET_SHIPPING_METHODS = PREFIX + "getShippingMethods" + SUFFIX;
public static final String API_GET_SHIPPING_METHODS = PREFIX + "getShippingMethodsArray" + SUFFIX;
public static final String API_GET_CUSTOMER_ADDRESSES = PREFIX + "getAddresses" + SUFFIX;
public static final String API_GET_PAYMENT_METHODS = PREFIX + "getPaymentMethods" + SUFFIX;
public static final String API_GET_PAYMENT_METHODS = PREFIX + "getPaymentMethodsArray" + SUFFIX;
}

View File

@@ -5,7 +5,9 @@ import java.util.HashMap;
import ch.pizzalink.android.model.AddProductToBasketResponseModel;
import ch.pizzalink.android.model.AddressModel;
import ch.pizzalink.android.model.PaymentMethodModel;
import ch.pizzalink.android.model.PaymentMethodsResponseModel;
import ch.pizzalink.android.model.ShippingMethodModel;
import ch.pizzalink.android.model.ShippingMethodsResponseModel;
import ch.pizzalink.android.model.cart.CartInfoModel;
import ch.pizzalink.android.model.CategoryModel;
import ch.pizzalink.android.model.OrderModel;
@@ -87,6 +89,6 @@ public interface ApiInterface {
Call<ResponseArray<AddressModel>> getCustomerAddresses(@Query("token") String token);
@GET(ApiEndPoints.API_GET_PAYMENT_METHODS)
Call<ResponseArray<PaymentMethodModel>> getPaymentMethods(@Query("token") String token);
Call<ResponseObject<PaymentMethodsResponseModel>> getPaymentMethods(@Query("token") String token);
}

View File

@@ -0,0 +1,17 @@
package ch.pizzalink.android.fragment.order;
import android.widget.TextView;
import butterknife.BindView;
import ch.pizzalink.android.R;
import ch.pizzalink.android.fragment.BaseFragment;
/**
* Created by cimenmus on 21.10.2017.
*/
public class OrderBaseFragment extends BaseFragment {
@BindView(R.id.previousTextView) TextView previousTextView;
@BindView(R.id.nextTextView) TextView nextTextView;
}

View File

@@ -7,17 +7,23 @@ import android.view.ViewGroup;
import butterknife.BindString;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.OrderActivity;
import ch.pizzalink.android.fragment.BaseFragment;
/**
* Created by cimenmus on 17/10/2017.
*/
public class OrderResultFragment extends BaseFragment {
public class OrderResultFragment extends OrderBaseFragment {
@BindString(R.string.done_order) String doneOrderText;
public static final java.lang.String FRAGMENT_NAME = "orderResultFragment";
private boolean isOrderSuccessed;
public OrderResultFragment() {}
public static OrderResultFragment newInstance() {
@@ -37,6 +43,24 @@ public class OrderResultFragment extends BaseFragment {
return view;
}
@OnClick({R.id.previousTextView, R.id.nextTextView})
protected void onClick(View view){
OrderActivity orderActivity = (OrderActivity) getActivity();
switch (view.getId()){
case R.id.previousTextView:
orderActivity.onPreviousClicked(FRAGMENT_NAME);
break;
case R.id.nextTextView:
if(isOrderSuccessed){
orderActivity.onNextClicked(FRAGMENT_NAME);
}
break;
}
}
private void initViews(){
isOrderSuccessed = true;
previousTextView.setVisibility(View.GONE);
nextTextView.setText(doneOrderText);
}
}

View File

@@ -7,14 +7,18 @@ import android.view.ViewGroup;
import butterknife.BindString;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.OrderActivity;
import ch.pizzalink.android.fragment.BaseFragment;
/**
* Created by cimenmus on 17/10/2017.
*/
public class OrderSummaryFragment extends BaseFragment {
public class OrderSummaryFragment extends OrderBaseFragment {
@BindString(R.string.confirm_order) String confirmOrderText;
public static final java.lang.String FRAGMENT_NAME = "orderSummaryFragment";
@@ -37,6 +41,13 @@ public class OrderSummaryFragment extends BaseFragment {
return view;
}
@OnClick(R.id.nextTextView)
protected void onClick(){
OrderActivity orderActivity = (OrderActivity) getActivity();
orderActivity.onNextClicked(FRAGMENT_NAME);
}
private void initViews(){
nextTextView.setText(confirmOrderText);
}
}

View File

@@ -12,17 +12,21 @@ import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
import ch.pizzalink.android.activity.OrderActivity;
import ch.pizzalink.android.adapter.recycler.PaymentMethodsRecyclerAdapter;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.api.ResponseArray;
import ch.pizzalink.android.api.ResponseObject;
import ch.pizzalink.android.fragment.BaseFragment;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.PaymentMethodModel;
import ch.pizzalink.android.model.PaymentMethodsResponseModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -31,13 +35,17 @@ import retrofit2.Response;
* Created by cimenmus on 17/10/2017.
*/
public class PaymentMethodFragment extends BaseFragment {
public class PaymentMethodFragment extends OrderBaseFragment {
@BindView(R.id.paymentMethodsRecyclerView) RecyclerView paymentMethodsRecyclerView;
@BindString(R.string.alert_choose_payment_method) String choosePaymentMethodText;
private ArrayList<PaymentMethodModel> paymentMethodList = new ArrayList<>();
private PaymentMethodsRecyclerAdapter paymentMethodsRecyclerAdapter;
private boolean isPaymentMethodSelected;
public static final java.lang.String FRAGMENT_NAME = "paymentMethodFragment";
public PaymentMethodFragment() {}
@@ -56,27 +64,44 @@ public class PaymentMethodFragment extends BaseFragment {
View view = inflater.inflate(R.layout.fragment_payment_method, container, false);
ButterKnife.bind(this, view);
initViews();
//getPaymentMethods();
createSamplePaymentModels();
getPaymentMethods();
return view;
}
@OnClick({R.id.previousTextView, R.id.nextTextView})
protected void onClick(View view){
OrderActivity orderActivity = (OrderActivity) getActivity();
switch (view.getId()){
case R.id.previousTextView:
orderActivity.onPreviousClicked(FRAGMENT_NAME);
break;
case R.id.nextTextView:
if(isPaymentMethodSelected){
orderActivity.onNextClicked(FRAGMENT_NAME);
}
else {
DialogHelper.showAlertDialog(BaseActivity.currentActivity, choosePaymentMethodText);
}
break;
}
}
private void initViews(){
initRecyclerView();
}
private void getPaymentMethods(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<PaymentMethodModel>> call = ApiService.apiInterface.getPaymentMethods(
Call<ResponseObject<PaymentMethodsResponseModel>> call = ApiService.apiInterface.getPaymentMethods(
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseArray<PaymentMethodModel>>() {
call.enqueue(new Callback<ResponseObject<PaymentMethodsResponseModel>>() {
@Override
public void onResponse(Call<ResponseArray<PaymentMethodModel>> call, Response<ResponseArray<PaymentMethodModel>> response) {
public void onResponse(Call<ResponseObject<PaymentMethodsResponseModel>> call, Response<ResponseObject<PaymentMethodsResponseModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyAdapter(response.body().getData());
fillAndNotifyAdapter(response.body().getData().getPaymentMethodsList());
}
else {
ApiErrorUtils.parseError(response);
@@ -84,7 +109,7 @@ public class PaymentMethodFragment extends BaseFragment {
}
@Override
public void onFailure(Call<ResponseArray<PaymentMethodModel>> call, Throwable t) {
public void onFailure(Call<ResponseObject<PaymentMethodsResponseModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
@@ -93,10 +118,12 @@ public class PaymentMethodFragment extends BaseFragment {
private void fillAndNotifyAdapter(ArrayList<PaymentMethodModel> paymentMethodModels){
PaymentMethodModel.checkNull(paymentMethodModels);
PaymentMethodModel.sort(paymentMethodModels);
paymentMethodList.clear();
paymentMethodList.addAll(paymentMethodModels);
if(paymentMethodList.size() != 0){
paymentMethodList.get(0).setSelected(true);
isPaymentMethodSelected = true;
}
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
}
@@ -109,6 +136,7 @@ public class PaymentMethodFragment extends BaseFragment {
paymentMethodModel.setSelected(false);
}
paymentMethodList.get(position).setSelected(true);
isPaymentMethodSelected = true;
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
}
});
@@ -116,13 +144,4 @@ public class PaymentMethodFragment extends BaseFragment {
paymentMethodsRecyclerView.setLayoutManager(layoutManager);
paymentMethodsRecyclerView.setAdapter(paymentMethodsRecyclerAdapter);
}
private void createSamplePaymentModels(){
paymentMethodList.add(new PaymentMethodModel("Kapıda Ödeme"));
paymentMethodList.add(new PaymentMethodModel("Havale"));
paymentMethodList.add(new PaymentMethodModel("Kredi Kartı"));
paymentMethodList.add(new PaymentMethodModel("Banka kartı"));
paymentMethodList.get(0).setSelected(true);
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
}
}

View File

@@ -9,10 +9,13 @@ import android.view.ViewGroup;
import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
import ch.pizzalink.android.activity.OrderActivity;
import ch.pizzalink.android.adapter.recycler.ShippingAddressesRecyclerAdapter;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
@@ -30,13 +33,17 @@ import retrofit2.Response;
* Created by cimenmus on 17/10/2017.
*/
public class ShippingAddressFragment extends BaseFragment {
public class ShippingAddressFragment extends OrderBaseFragment {
@BindView(R.id.shippingAddressesRecyclerView) RecyclerView shippingAddressesRecyclerView;
@BindString(R.string.alert_choose_shipping_address) String chooseShippingAddressText;
private ArrayList<AddressModel> addressList = new ArrayList<>();
private ShippingAddressesRecyclerAdapter shippingAddressesRecyclerAdapter;
private boolean isShippingAddressSelected;
public static final java.lang.String FRAGMENT_NAME = "shippingAddressMethod";
public ShippingAddressFragment() {}
@@ -59,6 +66,24 @@ public class ShippingAddressFragment extends BaseFragment {
return view;
}
@OnClick({R.id.previousTextView, R.id.nextTextView})
protected void onClick(View view){
OrderActivity orderActivity = (OrderActivity) getActivity();
switch (view.getId()){
case R.id.previousTextView:
orderActivity.onPreviousClicked(FRAGMENT_NAME);
break;
case R.id.nextTextView:
if(isShippingAddressSelected){
orderActivity.onNextClicked(FRAGMENT_NAME);
}
else {
DialogHelper.showAlertDialog(BaseActivity.currentActivity, chooseShippingAddressText);
}
break;
}
}
private void initViews(){
initRecyclerView();
}
@@ -95,6 +120,7 @@ public class ShippingAddressFragment extends BaseFragment {
addressList.addAll(addressModels);
if(addressList.size() != 0){
addressList.get(0).setSelected(true);
isShippingAddressSelected = true;
}
shippingAddressesRecyclerAdapter.notifyDataSetChanged();
}
@@ -107,6 +133,7 @@ public class ShippingAddressFragment extends BaseFragment {
addressModel.setSelected(false);
}
addressList.get(position).setSelected(true);
isShippingAddressSelected = true;
shippingAddressesRecyclerAdapter.notifyDataSetChanged();
}
});

View File

@@ -6,23 +6,28 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
import ch.pizzalink.android.activity.OrderActivity;
import ch.pizzalink.android.adapter.recycler.ShippingMethodsRecyclerAdapter;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.api.ResponseArray;
import ch.pizzalink.android.api.ResponseObject;
import ch.pizzalink.android.fragment.BaseFragment;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.ShippingMethodModel;
import ch.pizzalink.android.model.ShippingMethodsResponseModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -31,13 +36,17 @@ import retrofit2.Response;
* Created by cimenmus on 17/10/2017.
*/
public class ShippingMethodFragment extends BaseFragment {
public class ShippingMethodFragment extends OrderBaseFragment {
@BindView(R.id.shippingMethodsRecyclerView) RecyclerView shippingMethodsRecyclerView;
@BindString(R.string.alert_choose_shipping_method) String chooseShippingMethodText;
private ArrayList<ShippingMethodModel> shippingMethodList = new ArrayList<>();
private ShippingMethodsRecyclerAdapter shippingMethodsRecyclerAdapter;
private boolean isShippingMethodSelected;
public static final java.lang.String FRAGMENT_NAME = "shippingMethodFragment";
public ShippingMethodFragment() {}
@@ -56,13 +65,24 @@ public class ShippingMethodFragment extends BaseFragment {
View view = inflater.inflate(R.layout.fragment_shipping_method, container, false);
ButterKnife.bind(this, view);
initViews();
//getShippingMethods();
createSampleShippingMethods();
getShippingMethods();
return view;
}
@OnClick(R.id.nextTextView)
protected void onClick(){
if(isShippingMethodSelected){
OrderActivity orderActivity = (OrderActivity) getActivity();
orderActivity.onNextClicked(FRAGMENT_NAME);
}
else {
DialogHelper.showAlertDialog(BaseActivity.currentActivity, chooseShippingMethodText);
}
}
private void initViews(){
initRecyclerView();
previousTextView.setVisibility(View.GONE);
}
private void getShippingMethods(){
@@ -97,6 +117,7 @@ public class ShippingMethodFragment extends BaseFragment {
shippingMethodList.addAll(shippingMethodModels);
if(shippingMethodList.size() != 0){
shippingMethodList.get(0).setSelected(true);
isShippingMethodSelected = true;
}
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
}
@@ -109,6 +130,7 @@ public class ShippingMethodFragment extends BaseFragment {
shippingMethodModel.setSelected(false);
}
shippingMethodList.get(position).setSelected(true);
isShippingMethodSelected = true;
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
}
});
@@ -116,11 +138,4 @@ public class ShippingMethodFragment extends BaseFragment {
shippingMethodsRecyclerView.setLayoutManager(layoutManager);
shippingMethodsRecyclerView.setAdapter(shippingMethodsRecyclerAdapter);
}
private void createSampleShippingMethods(){
shippingMethodList.add(new ShippingMethodModel("Gel al", "CHF 0.00"));
shippingMethodList.add(new ShippingMethodModel("Kapına gelsin", "CHF 5.00"));
shippingMethodList.get(0).setSelected(true);
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
}
}

View File

@@ -1,6 +1,11 @@
package ch.pizzalink.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
/**
* Created by cimenmus on 17/10/2017.
@@ -8,16 +13,27 @@ import java.util.ArrayList;
public class PaymentMethodModel {
private String id;
private String name;
private String code;
private String title;
private String terms;
private boolean isSelected;
public PaymentMethodModel(String name) {
this.name = name;
}
@Expose @SerializedName("sort_order")
private String sortOrder;
private void checkNull(){
if(code == null)
code = "";
if(title == null)
title = "";
if(terms == null)
terms = "";
if(sortOrder == null)
sortOrder = "0";
}
public static void checkNull(ArrayList<PaymentMethodModel> paymentMethodList){
@@ -26,20 +42,37 @@ public class PaymentMethodModel {
}
}
public String getId() {
return id;
public static void sort(ArrayList<PaymentMethodModel> paymentMethodList){
Collections.sort(paymentMethodList, new Comparator<PaymentMethodModel>() {
@Override
public int compare(PaymentMethodModel pm1, PaymentMethodModel pm2){
return Integer.valueOf(pm1.sortOrder).compareTo(Integer.valueOf(pm2.sortOrder));
}
});
}
public void setId(String id) {
this.id = id;
public String getCode() {
return code;
}
public String getName() {
return name;
public void setCode(String code) {
this.code = code;
}
public void setName(String name) {
this.name = name;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getTerms() {
return terms;
}
public void setTerms(String terms) {
this.terms = terms;
}
public boolean isSelected() {
@@ -49,4 +82,12 @@ public class PaymentMethodModel {
public void setSelected(boolean selected) {
isSelected = selected;
}
public String getSortOrder() {
return sortOrder;
}
public void setSortOrder(String sortOrder) {
this.sortOrder = sortOrder;
}
}

View File

@@ -0,0 +1,25 @@
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 21.10.2017.
*/
public class PaymentMethodsResponseModel {
@Expose
@SerializedName("payment_methods")
private ArrayList<PaymentMethodModel> paymentMethodsList;
public ArrayList<PaymentMethodModel> getPaymentMethodsList() {
return paymentMethodsList;
}
public void setPaymentMethodsList(ArrayList<PaymentMethodModel> paymentMethodsList) {
this.paymentMethodsList = paymentMethodsList;
}
}

View File

@@ -1,5 +1,8 @@
package ch.pizzalink.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
@@ -8,17 +11,33 @@ import java.util.ArrayList;
public class ShippingMethodModel {
private String name;
private String price;
private String code;
private String title;
private boolean isSelected;
public ShippingMethodModel(String name, String price) {
this.name = name;
this.price = price;
}
@Expose
@SerializedName("cost")
private double priceDouble;
@Expose
@SerializedName("tax_class_id")
private int taxClassId;
@Expose
@SerializedName("text")
private String priceText;
private void checkNull(){
if(code == null)
code = "";
if(title == null)
title = "";
if(priceText == null)
priceText = "";
}
public static void checkNull(ArrayList<ShippingMethodModel> shippingMethodList){
@@ -27,20 +46,20 @@ public class ShippingMethodModel {
}
}
public String getName() {
return name;
public String getCode() {
return code;
}
public void setName(String name) {
this.name = name;
public void setCode(String code) {
this.code = code;
}
public String getPrice() {
return price;
public String getTitle() {
return title;
}
public void setPrice(String price) {
this.price = price;
public void setTitle(String title) {
this.title = title;
}
public boolean isSelected() {
@@ -50,4 +69,28 @@ public class ShippingMethodModel {
public void setSelected(boolean selected) {
isSelected = selected;
}
public double getPriceDouble() {
return priceDouble;
}
public void setPriceDouble(double priceDouble) {
this.priceDouble = priceDouble;
}
public int getTaxClassId() {
return taxClassId;
}
public void setTaxClassId(int taxClassId) {
this.taxClassId = taxClassId;
}
public String getPriceText() {
return priceText;
}
public void setPriceText(String priceText) {
this.priceText = priceText;
}
}

View File

@@ -0,0 +1,25 @@
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 21.10.2017.
*/
public class ShippingMethodsResponseModel {
@Expose
@SerializedName("shipping_methods")
private ArrayList<ShippingMethodModel> paymentMethodsList;
public ArrayList<ShippingMethodModel> getPaymentMethodsList() {
return paymentMethodsList;
}
public void setPaymentMethodsList(ArrayList<ShippingMethodModel> paymentMethodsList) {
this.paymentMethodsList = paymentMethodsList;
}
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<LinearLayout
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"
@@ -22,8 +22,7 @@
android:id="@+id/stepIndicatorLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/orderToolbar">
android:orientation="vertical">
<com.badoualy.stepperindicator.StepperIndicator
android:id="@+id/stepperIndicator"
@@ -42,57 +41,7 @@
<FrameLayout
android:id="@+id/orderFragmentsContainer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/actvity_default_background_color_1"
android:layout_below="@+id/stepIndicatorLayout"
android:layout_above="@+id/ordersBottomLayout"/>
<LinearLayout
android:id="@+id/ordersBottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/shadow"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<TextView
android:id="@+id/previousTextView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="@color/red"
android:text="@string/previous"
android:textStyle="bold"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:gravity="center" />
android:background="@color/actvity_default_background_color_1" />
<TextView
android:id="@+id/nextTextView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="@color/red"
android:text="@string/next"
android:textStyle="bold"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:gravity="center" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View File

@@ -10,6 +10,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Order Result"
android:layout_centerInParent="true"/>
android:layout_centerInParent="true"
android:layout_above="@+id/ordersBottomLayout"/>
<include layout="@layout/layout_orders_bottom"/>
</RelativeLayout>

View File

@@ -10,6 +10,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Order Summary"
android:layout_centerInParent="true"/>
android:layout_centerInParent="true"
android:layout_above="@+id/ordersBottomLayout"/>
<include layout="@layout/layout_orders_bottom"/>
</RelativeLayout>

View File

@@ -10,6 +10,9 @@
android:id="@+id/paymentMethodsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
android:scrollbars="vertical"
android:layout_above="@+id/ordersBottomLayout"/>
<include layout="@layout/layout_orders_bottom"/>
</RelativeLayout>

View File

@@ -10,6 +10,9 @@
android:id="@+id/shippingAddressesRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
android:scrollbars="vertical"
android:layout_above="@+id/ordersBottomLayout"/>
<include layout="@layout/layout_orders_bottom"/>
</RelativeLayout>

View File

@@ -10,6 +10,9 @@
android:id="@+id/shippingMethodsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
android:scrollbars="vertical"
android:layout_above="@+id/ordersBottomLayout"/>
<include layout="@layout/layout_orders_bottom"/>
</RelativeLayout>

View File

@@ -0,0 +1,48 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ordersBottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/shadow"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<TextView
android:id="@+id/previousTextView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="@color/red"
android:text="@string/previous"
android:textStyle="bold"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:gravity="center" />
<TextView
android:id="@+id/nextTextView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="@color/red"
android:text="@string/next"
android:textStyle="bold"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:gravity="center" />
</RelativeLayout>
</LinearLayout>

View File

@@ -133,6 +133,13 @@
<string name="next">NEXT</string>
<string name="previous">PREVIOUS</string>
<string name="alert_choose_shipping_method">Lütfen bir teslimat yöntemi seçiniz.</string>
<string name="alert_choose_shipping_address">Lütfen bir teslimat adresi seçiniz ya da yeni bir teslimat adresi ekleyiniz.</string>
<string name="alert_choose_payment_method">Lütfen bir ödeme yöntemi seçiniz.</string>
<string name="confirm_order">APPROVE</string>
<string name="done_order">DONE</string>
<string-array name="stepperLabels">
<item>Shipping Method</item>
<item>Shipping Address</item>