create order

This commit is contained in:
2017-10-18 00:05:12 +03:00
parent 9ff89fbb47
commit 8d5806deed
31 changed files with 1500 additions and 9 deletions

View File

@@ -46,6 +46,7 @@ dependencies {
compile 'com.github.HITGIF:TextFieldBoxes:1.3.3'
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.1.3'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
compile 'com.github.badoualy:stepper-indicator:1.0.7'
compile 'q.rorbin:badgeview:1.1.0'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

View File

@@ -1,6 +1,5 @@
<?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" />
@@ -20,10 +19,11 @@
<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.WelcomeActivity" />
<activity android:name=".activity.LoginActivity" />
<activity android:name=".activity.RegisterActivity" />
<activity android:name=".activity.MainActivity" />
<activity android:name=".activity.OrderActivity"></activity>
</application>
</manifest>

View File

@@ -52,6 +52,7 @@ public class MainActivity extends BaseActivity {
private FragmentManager fragmentManager;
private String currentFragmentName = "";
private int currentCategoryId = -1;
private boolean isStartWithOrderHistory;
private ArrayList<CategoryModel> categoryList = new ArrayList<>();
private NavigationMenuRecyclerAdapter navigationMenuRecyclerAdapter;
private Badge badge;
@@ -63,9 +64,14 @@ public class MainActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
getDataFromIntent();
initViews();
}
private void getDataFromIntent(){
isStartWithOrderHistory = getIntent().getBooleanExtra("isStartWithOrderHistory", false);
}
private void initViews(){
initNavigationDrawer();
initBottomNavigationView();
@@ -75,7 +81,12 @@ public class MainActivity extends BaseActivity {
private void showStartScreen(){
fragmentManager = getSupportFragmentManager();
openProductsScreen(categoryList.get(2));
if(isStartWithOrderHistory){
bottomNavigationView.setCurrentItem(2);
}
else {
openProductsScreen(categoryList.get(2));
}
}
private void initBottomNavigationView(){

View File

@@ -0,0 +1,138 @@
package ch.pizzalink.android.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;
import com.badoualy.stepperindicator.StepperIndicator;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.adapter.pager.OrderPagerAdapter;
import ch.pizzalink.android.fragment.order.OrderResultFragment;
import ch.pizzalink.android.fragment.order.OrderSummaryFragment;
import ch.pizzalink.android.fragment.order.PaymentMethodFragment;
import ch.pizzalink.android.fragment.order.ShippingAddressFragment;
import ch.pizzalink.android.fragment.order.ShippingMethodFragment;
import ch.pizzalink.android.helper.SharedPrefsHelper;
import ch.pizzalink.android.view.NoSwipeViewPager;
import ch.pizzalink.android.view.PizzalinkToolbar;
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) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_order);
ButterKnife.bind(this);
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
public void onClick(View view) {
onBackPressed();
}
});
fragmentManager = getSupportFragmentManager();
initStepIndicator();
openFragment(0);
}
private void initStepIndicator(){
/*
5 fragment var, ama sonuncu step'te tik göstersin diye step sayısını, fragment sayısı - 1 yaptık
*/
stepperIndicator.setStepCount(4);
/*
stepperIndicator.addOnStepClickListener(new StepperIndicator.OnStepClickListener() {
@Override
public void onStepClicked(int step) {
openFragment(step);
}
});
*/
}
private void openFragment(int position){
switch (position){
case 0:
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
ShippingMethodFragment.newInstance()).commit();
break;
case 1:
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
ShippingAddressFragment.newInstance()).commit();
break;
case 2:
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
PaymentMethodFragment.newInstance()).commit();
break;
case 3:
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
OrderSummaryFragment.newInstance()).commit();
break;
case 4:
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
OrderResultFragment.newInstance()).commit();
break;
}
stepperIndicator.setCurrentStep(position);
}
/*
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);
}
});
}
*/
}

View File

@@ -0,0 +1,52 @@
package ch.pizzalink.android.adapter.pager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import ch.pizzalink.android.fragment.order.OrderResultFragment;
import ch.pizzalink.android.fragment.order.OrderSummaryFragment;
import ch.pizzalink.android.fragment.order.PaymentMethodFragment;
import ch.pizzalink.android.fragment.order.ShippingAddressFragment;
import ch.pizzalink.android.fragment.order.ShippingMethodFragment;
/**
* Created by cimenmus on 17/10/2017.
*/
public class OrderPagerAdapter extends FragmentPagerAdapter {
public OrderPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position){
case 0:
return ShippingMethodFragment.newInstance();
case 1:
return ShippingAddressFragment.newInstance();
case 2:
return PaymentMethodFragment.newInstance();
case 3:
return OrderSummaryFragment.newInstance();
case 4:
return OrderResultFragment.newInstance();
default:
return ShippingMethodFragment.newInstance();
}
}
@Override
public int getCount() {
return 5;
}
/*
@Override
public CharSequence getPageTitle(int position) {
return "Page " + position;
}
*/
}

View File

@@ -0,0 +1,119 @@
package ch.pizzalink.android.adapter.recycler;
import android.support.v7.widget.AppCompatRadioButton;
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.BindView;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.PaymentMethodModel;
/**
* Created by cimenmus on 17/10/2017.
*/
public class PaymentMethodsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_PAYMENT_METHOD = 0;
private final int HOLDER_SPACE = 1;
private ArrayList<PaymentMethodModel> paymentMethodList = new ArrayList<>();
private RecyclerItemClickListener recyclerItemClickListener;
public static class OrderViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.paymentMethodRadioButton) AppCompatRadioButton paymentMethodRadioButton;
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
}
});
}
}
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
public SpaceViewHolder(final View view) {
super(view);
}
}
@Override
public int getItemViewType(int position) {
if(position == paymentMethodList.size())
return HOLDER_SPACE;
return HOLDER_PAYMENT_METHOD;
}
public PaymentMethodsRecyclerAdapter(ArrayList<PaymentMethodModel> paymentMethodList,
RecyclerItemClickListener recyclerItemClickListener){
this.paymentMethodList = paymentMethodList;
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_PAYMENT_METHOD:
view = inflater.inflate(R.layout.row_payment_method, viewGroup, false);
viewHolder = new OrderViewHolder(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_payment_method, viewGroup, false);
viewHolder = new OrderViewHolder(view, recyclerItemClickListener);
break;
}
return viewHolder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
switch (holder.getItemViewType()){
case HOLDER_PAYMENT_METHOD :
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
orderViewHolder.paymentMethodRadioButton.setText(paymentMethodList.get(position).getName());
orderViewHolder.paymentMethodRadioButton.setChecked(paymentMethodList.get(position).isSelected());
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return paymentMethodList.size() + 1 ;
}
}

View File

@@ -0,0 +1,119 @@
package ch.pizzalink.android.adapter.recycler;
import android.support.v7.widget.AppCompatRadioButton;
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.BindView;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.AddressModel;
/**
* Created by cimenmus on 17/10/2017.
*/
public class ShippingAddressesRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_SHIPPING_ADDRESS = 0;
private final int HOLDER_SPACE = 1;
private ArrayList<AddressModel> addressList = new ArrayList<>();
private RecyclerItemClickListener recyclerItemClickListener;
public static class OrderViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.shipmentAddressRadioButton) AppCompatRadioButton shipmentAddressRadioButton;
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
}
});
}
}
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
public SpaceViewHolder(final View view) {
super(view);
}
}
@Override
public int getItemViewType(int position) {
if(position == addressList.size())
return HOLDER_SPACE;
return HOLDER_SHIPPING_ADDRESS;
}
public ShippingAddressesRecyclerAdapter(ArrayList<AddressModel> addressList,
RecyclerItemClickListener recyclerItemClickListener){
this.addressList = addressList;
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_SHIPPING_ADDRESS:
view = inflater.inflate(R.layout.row_shipment_address, viewGroup, false);
viewHolder = new OrderViewHolder(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_shipment_address, viewGroup, false);
viewHolder = new OrderViewHolder(view, recyclerItemClickListener);
break;
}
return viewHolder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
switch (holder.getItemViewType()){
case HOLDER_SHIPPING_ADDRESS :
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
orderViewHolder.shipmentAddressRadioButton.setText(addressList.get(position).getAddress());
orderViewHolder.shipmentAddressRadioButton.setChecked(addressList.get(position).isSelected());
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return addressList.size() + 1 ;
}
}

View File

@@ -0,0 +1,121 @@
package ch.pizzalink.android.adapter.recycler;
import android.support.v7.widget.AppCompatRadioButton;
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.BindView;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.ShippingMethodModel;
/**
* Created by cimenmus on 17/10/2017.
*/
public class ShippingMethodsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_SHIPPING_METHOD = 0;
private final int HOLDER_SPACE = 1;
private ArrayList<ShippingMethodModel> shippingMethodList = new ArrayList<>();
private RecyclerItemClickListener recyclerItemClickListener;
public static class OrderViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.shipmentMethodRadioButton) AppCompatRadioButton shipmentMethodRadioButton;
@BindView(R.id.shipmentMethodPriceTextView) TextView shipmentMethodPriceTextView;
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
}
});
}
}
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
public SpaceViewHolder(final View view) {
super(view);
}
}
@Override
public int getItemViewType(int position) {
if(position == shippingMethodList.size())
return HOLDER_SPACE;
return HOLDER_SHIPPING_METHOD;
}
public ShippingMethodsRecyclerAdapter(ArrayList<ShippingMethodModel> shippingMethodList,
RecyclerItemClickListener recyclerItemClickListener){
this.shippingMethodList = shippingMethodList;
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_SHIPPING_METHOD:
view = inflater.inflate(R.layout.row_shipment_method, viewGroup, false);
viewHolder = new OrderViewHolder(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_shipment_method, viewGroup, false);
viewHolder = new OrderViewHolder(view, recyclerItemClickListener);
break;
}
return viewHolder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
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.shipmentMethodRadioButton.setChecked(shippingMethodList.get(position).isSelected());
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return shippingMethodList.size() + 1 ;
}
}

View File

@@ -14,8 +14,10 @@ public class ApiEndPoints {
public static final String API_GET_CLEAR_CART = PREFIX + "clearBasket" + SUFFIX;
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=sor37aVmOYP1v4OxpCsv11w3DkeGDttB";
//public static final String API_ADD_PRODUCTS_TO_BASKET = PREFIX + "addProductsToBasket" + 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_CUSTOMER_ADDRESSES = PREFIX + "getAddresses" + SUFFIX;
public static final String API_GET_PAYMENT_METHODS = PREFIX + "getPaymentMethods" + SUFFIX;
}

View File

@@ -3,6 +3,9 @@ package ch.pizzalink.android.api;
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.ShippingMethodModel;
import ch.pizzalink.android.model.cart.CartInfoModel;
import ch.pizzalink.android.model.CategoryModel;
import ch.pizzalink.android.model.OrderModel;
@@ -77,5 +80,13 @@ public interface ApiInterface {
@POST
Call<ResponseObject<AddProductToBasketResponseModel>> addProductsToBasket(@Url String url,
@FieldMap HashMap<String, Object> body);
@GET(ApiEndPoints.API_GET_SHIPPING_METHODS)
Call<ResponseArray<ShippingMethodModel>> getShippingMethods(@Query("token") String token);
@GET(ApiEndPoints.API_GET_CUSTOMER_ADDRESSES)
Call<ResponseArray<AddressModel>> getCustomerAddresses(@Query("token") String token);
@GET(ApiEndPoints.API_GET_PAYMENT_METHODS)
Call<ResponseArray<PaymentMethodModel>> getPaymentMethods(@Query("token") String token);
}

View File

@@ -1,5 +1,6 @@
package ch.pizzalink.android.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
@@ -25,6 +26,7 @@ import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
import ch.pizzalink.android.activity.MainActivity;
import ch.pizzalink.android.activity.OrderActivity;
import ch.pizzalink.android.adapter.recycler.CartRecyclerAdapter;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
@@ -105,6 +107,7 @@ public class CartFragment extends BaseFragment {
});
break;
case R.id.continueCartButton:
startActivity(new Intent(BaseActivity.currentActivity, OrderActivity.class));
break;
}
}

View File

@@ -0,0 +1,42 @@
package ch.pizzalink.android.fragment.order;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.BindString;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.fragment.BaseFragment;
/**
* Created by cimenmus on 17/10/2017.
*/
public class OrderResultFragment extends BaseFragment {
public static final java.lang.String FRAGMENT_NAME = "orderResultFragment";
public OrderResultFragment() {}
public static OrderResultFragment newInstance() {
return new OrderResultFragment();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_order_result, container, false);
ButterKnife.bind(this, view);
initViews();
return view;
}
private void initViews(){
}
}

View File

@@ -0,0 +1,42 @@
package ch.pizzalink.android.fragment.order;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.BindString;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.fragment.BaseFragment;
/**
* Created by cimenmus on 17/10/2017.
*/
public class OrderSummaryFragment extends BaseFragment {
public static final java.lang.String FRAGMENT_NAME = "orderSummaryFragment";
public OrderSummaryFragment() {}
public static OrderSummaryFragment newInstance() {
return new OrderSummaryFragment();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_order_summary, container, false);
ButterKnife.bind(this, view);
initViews();
return view;
}
private void initViews(){
}
}

View File

@@ -0,0 +1,124 @@
package ch.pizzalink.android.fragment.order;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
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.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 retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by cimenmus on 17/10/2017.
*/
public class PaymentMethodFragment extends BaseFragment {
@BindView(R.id.paymentMethodsRecyclerView) RecyclerView paymentMethodsRecyclerView;
private ArrayList<PaymentMethodModel> paymentMethodList = new ArrayList<>();
private PaymentMethodsRecyclerAdapter paymentMethodsRecyclerAdapter;
public static final java.lang.String FRAGMENT_NAME = "paymentMethodFragment";
public PaymentMethodFragment() {}
public static PaymentMethodFragment newInstance() {
return new PaymentMethodFragment();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_payment_method, container, false);
ButterKnife.bind(this, view);
initViews();
//getPaymentMethods();
createSamplePaymentModels();
return view;
}
private void initViews(){
initRecyclerView();
}
private void getPaymentMethods(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<PaymentMethodModel>> call = ApiService.apiInterface.getPaymentMethods(
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseArray<PaymentMethodModel>>() {
@Override
public void onResponse(Call<ResponseArray<PaymentMethodModel>> call, Response<ResponseArray<PaymentMethodModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyAdapter(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<PaymentMethodModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyAdapter(ArrayList<PaymentMethodModel> paymentMethodModels){
PaymentMethodModel.checkNull(paymentMethodModels);
paymentMethodList.clear();
paymentMethodList.addAll(paymentMethodModels);
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
}
private void initRecyclerView(){
paymentMethodsRecyclerAdapter = new PaymentMethodsRecyclerAdapter(paymentMethodList, new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
for (PaymentMethodModel paymentMethodModel : paymentMethodList){
paymentMethodModel.setSelected(false);
}
paymentMethodList.get(position).setSelected(true);
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
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ı"));
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
}
}

View File

@@ -0,0 +1,114 @@
package ch.pizzalink.android.fragment.order;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
import ch.pizzalink.android.adapter.recycler.ShippingAddressesRecyclerAdapter;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.api.ResponseArray;
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.AddressModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by cimenmus on 17/10/2017.
*/
public class ShippingAddressFragment extends BaseFragment {
@BindView(R.id.shippingAddressesRecyclerView) RecyclerView shippingAddressesRecyclerView;
private ArrayList<AddressModel> addressList = new ArrayList<>();
private ShippingAddressesRecyclerAdapter shippingAddressesRecyclerAdapter;
public static final java.lang.String FRAGMENT_NAME = "shippingAddressMethod";
public ShippingAddressFragment() {}
public static ShippingAddressFragment newInstance() {
return new ShippingAddressFragment();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_shipping_address, container, false);
ButterKnife.bind(this, view);
initViews();
getCustomerShippingAddresses();
return view;
}
private void initViews(){
initRecyclerView();
}
private void getCustomerShippingAddresses(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<AddressModel>> call = ApiService.apiInterface.getCustomerAddresses(
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseArray<AddressModel>>() {
@Override
public void onResponse(Call<ResponseArray<AddressModel>> call, Response<ResponseArray<AddressModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyAdapter(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<AddressModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyAdapter(ArrayList<AddressModel> addressModels){
AddressModel.checkNull(addressModels);
addressList.clear();
addressList.addAll(addressModels);
shippingAddressesRecyclerAdapter.notifyDataSetChanged();
}
private void initRecyclerView(){
shippingAddressesRecyclerAdapter = new ShippingAddressesRecyclerAdapter(addressList, new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
for(AddressModel addressModel : addressList){
addressModel.setSelected(false);
}
addressList.get(position).setSelected(true);
shippingAddressesRecyclerAdapter.notifyDataSetChanged();
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
shippingAddressesRecyclerView.setLayoutManager(layoutManager);
shippingAddressesRecyclerView.setAdapter(shippingAddressesRecyclerAdapter);
}
}

View File

@@ -0,0 +1,122 @@
package ch.pizzalink.android.fragment.order;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
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.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 retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by cimenmus on 17/10/2017.
*/
public class ShippingMethodFragment extends BaseFragment {
@BindView(R.id.shippingMethodsRecyclerView) RecyclerView shippingMethodsRecyclerView;
private ArrayList<ShippingMethodModel> shippingMethodList = new ArrayList<>();
private ShippingMethodsRecyclerAdapter shippingMethodsRecyclerAdapter;
public static final java.lang.String FRAGMENT_NAME = "shippingMethodFragment";
public ShippingMethodFragment() {}
public static ShippingMethodFragment newInstance() {
return new ShippingMethodFragment();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_shipping_method, container, false);
ButterKnife.bind(this, view);
initViews();
//getShippingMethods();
createSampleShippingMethods();
return view;
}
private void initViews(){
initRecyclerView();
}
private void getShippingMethods(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<ShippingMethodModel>> call = ApiService.apiInterface.getShippingMethods(
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseArray<ShippingMethodModel>>() {
@Override
public void onResponse(Call<ResponseArray<ShippingMethodModel>> call, Response<ResponseArray<ShippingMethodModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyAdapter(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<ShippingMethodModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyAdapter(ArrayList<ShippingMethodModel> shippingMethodModels){
ShippingMethodModel.checkNull(shippingMethodModels);
shippingMethodList.clear();
shippingMethodList.addAll(shippingMethodModels);
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
}
private void initRecyclerView(){
shippingMethodsRecyclerAdapter = new ShippingMethodsRecyclerAdapter(shippingMethodList, new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
for(ShippingMethodModel shippingMethodModel : shippingMethodList){
shippingMethodModel.setSelected(false);
}
shippingMethodList.get(position).setSelected(true);
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
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"));
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
}
}

View File

@@ -0,0 +1,59 @@
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 17/10/2017.
*/
public class AddressModel {
@Expose
@SerializedName("address_id")
private String id;
private String address;
private boolean isSelected;
private void checkNull(){
if(id == null)
id = "";
if(address == null)
address = "";
}
public static void checkNull(ArrayList<AddressModel> addressModelList){
for(AddressModel addressModel : addressModelList){
addressModel.checkNull();
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean selected) {
isSelected = selected;
}
}

View File

@@ -0,0 +1,8 @@
package ch.pizzalink.android.model;
/**
* Created by cimenmus on 17/10/2017.
*/
public class CreateOrderModel {
}

View File

@@ -0,0 +1,52 @@
package ch.pizzalink.android.model;
import java.util.ArrayList;
/**
* Created by cimenmus on 17/10/2017.
*/
public class PaymentMethodModel {
private String id;
private String name;
private boolean isSelected;
public PaymentMethodModel(String name) {
this.name = name;
}
private void checkNull(){
}
public static void checkNull(ArrayList<PaymentMethodModel> paymentMethodList){
for(PaymentMethodModel paymentMethodModel : paymentMethodList){
paymentMethodModel.checkNull();
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean selected) {
isSelected = selected;
}
}

View File

@@ -0,0 +1,53 @@
package ch.pizzalink.android.model;
import java.util.ArrayList;
/**
* Created by cimenmus on 17/10/2017.
*/
public class ShippingMethodModel {
private String name;
private String price;
private boolean isSelected;
public ShippingMethodModel(String name, String price) {
this.name = name;
this.price = price;
}
private void checkNull(){
}
public static void checkNull(ArrayList<ShippingMethodModel> shippingMethodList){
for(ShippingMethodModel shippingMethodModel : shippingMethodList){
shippingMethodModel.checkNull();
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean selected) {
isSelected = selected;
}
}

View File

@@ -0,0 +1,47 @@
package ch.pizzalink.android.view;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* Created by cimenmus on 17/10/2017.
*/
public class NoSwipeViewPager extends ViewPager {
private boolean enabled;
public NoSwipeViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
this.enabled = false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (this.enabled) {
return super.onTouchEvent(event);
}
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (this.enabled) {
return super.onInterceptTouchEvent(event);
}
return false;
}
public void setPagingEnabled(boolean enabled) {
this.enabled = enabled;
}
@Override
public boolean canScrollHorizontally(int direction) {
return false;
}
}

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
tools:context="ch.pizzalink.android.activity.OrderActivity">
<ch.pizzalink.android.view.PizzalinkToolbar
android:id="@+id/orderToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/activity_title_create_order"
android:background="@color/white"
app:showBackIcon="true"
app:titleTextColor="@color/black" />
<LinearLayout
android:id="@+id/stepIndicatorLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/orderToolbar">
<com.badoualy.stepperindicator.StepperIndicator
android:id="@+id/stepperIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:stpi_labels="@array/stepperLabels" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/shadow"/>
</LinearLayout>
<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" />
<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>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Order Result"
android:layout_centerInParent="true"/>
</RelativeLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Order Summary"
android:layout_centerInParent="true"/>
</RelativeLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<android.support.v7.widget.RecyclerView
android:id="@+id/paymentMethodsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</RelativeLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<android.support.v7.widget.RecyclerView
android:id="@+id/shippingAddressesRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</RelativeLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<android.support.v7.widget.RecyclerView
android:id="@+id/shippingMethodsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</RelativeLayout>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="12dp">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/paymentMethodRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gel ad"
android:clickable="false"/>
</RelativeLayout>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="12dp">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/shipmentAddressRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gel ad"
android:clickable="false"/>
</RelativeLayout>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="12dp">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/shipmentMethodRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gel ad"
android:clickable="false"/>
<RelativeLayout
android:layout_width="84dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true">
<TextView
android:id="@+id/shipmentMethodPriceTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CHF 14.00"/>
</RelativeLayout>
</RelativeLayout>

View File

@@ -121,5 +121,17 @@
<string name="no_options_selected_part">is not selected.</string>
<string name="alert_clear_cart">Sepetinizdeki ürünleri silmek istediğinize emin misiniz?</string>
<string name="activity_title_create_order">Sipariş Ver</string>
<string name="next">NEXT</string>
<string name="previous">PREVIOUS</string>
<string-array name="stepperLabels">
<item>Shipping Method</item>
<item>Shipping Address</item>
<item>Payment Method</item>
<item>Summary</item>
</string-array>
</resources>