app id changed

This commit is contained in:
2020-04-18 22:58:14 +03:00
parent 8aa1cb3bfb
commit 8e4f53ed9a
136 changed files with 705 additions and 705 deletions

View File

@@ -0,0 +1,63 @@
package ch.pizzacucina.android;
import android.support.multidex.MultiDexApplication;
import com.crashlytics.android.Crashlytics;
import com.jakewharton.picasso.OkHttp3Downloader;
import com.onesignal.OneSignal;
import com.squareup.picasso.Picasso;
import io.fabric.sdk.android.Fabric;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
/**
* Created by cimenmus on 11/09/2017.
*/
public class App extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
initCalligraphy();
initPicasso();
initFabric();
initOneSignal();
}
private void initCalligraphy(){
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Quicksand-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
.build()
);
}
private void initPicasso(){
// DISK CACHE
// Disk cache of 2% storage space up to 50MB but no less than 5MB
// 48 megabyte
//Picasso picasso = new Picasso.Builder(this).downloader(new OkHttp3Downloader(getCacheDir(), 48 * 1024 * 1024)).build();
Picasso picasso = new Picasso.Builder(this).downloader(new OkHttp3Downloader(getCacheDir())).build();
Picasso.setSingletonInstance(picasso);
/*
// MEMORY CACHE
//default cache size is %15 of available memory
// LRU memory cache of 15% the available application RAM
//LruCache() takes byte parameter. Here is 4 megabyte
Picasso.Builder picassoBuilder = new Picasso.Builder(this).memoryCache(new LruCache(8 * 1024 * 1024));
Picasso.setSingletonInstance(picassoBuilder.build());
*/
}
private void initFabric(){
Fabric.with(this, new Crashlytics());
}
private void initOneSignal(){
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
}
}

View File

@@ -0,0 +1,363 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.os.Bundle;
import android.view.View;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.ViewHelper;
import ch.pizzacucina.android.model.AddNewAddressResponseModel;
import ch.pizzacucina.android.model.CityModel;
import ch.pizzacucina.android.model.CountryModel;
import ch.pizzacucina.android.model.ZoneModel;
import ch.pizzacucina.android.view.AppDropdownView;
import ch.pizzacucina.android.view.AppEditText;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class AddAddressActivity extends BaseActivity {
@BindView(R.id.address1PizzalinkEditText) AppEditText address1AppEditText;
@BindView(R.id.cityPizzalinkDropdown) AppDropdownView cityPizzalinkDropdown;
@BindView(R.id.postcodePizzalinkEditText) AppEditText postcodeAppEditText;
@BindView(R.id.countryPizzalinkDropdown) AppDropdownView countryPizzalinkDropdown;
@BindView(R.id.zonePizzalinkDropdown) AppDropdownView zonePizzalinkDropdown;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_select_country_first) String selectCountryFirstText;
@BindString(R.string.new_address_added) String newAddressAddedText;
@BindString(R.string.alert_invalid_post_code) String invalidPostcodeText;
private ArrayList<CityModel> cityList = new ArrayList<>();
private ArrayList<CountryModel> countryList = new ArrayList<>();
private ArrayList<ZoneModel> zoneList = new ArrayList<>();
private CityModel selectedCityModel;
private CountryModel selectedCountryModel;
private ZoneModel selectedZoneModel;
private int activeRequestCount = 0;
private ReentrantLock lock = new ReentrantLock();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_address);
ButterKnife.bind(this);
getCityList();
//getCountryList();
}
@OnClick({R.id.cityPizzalinkDropdown, R.id.countryPizzalinkDropdown,
R.id.zonePizzalinkDropdown, R.id.addNewAddressButton})
protected void onClick(View view){
switch (view.getId()){
case R.id.cityPizzalinkDropdown:
showCityDialog();
break;
case R.id.countryPizzalinkDropdown:
showCountryDialog();
break;
case R.id.zonePizzalinkDropdown:
if(selectedCountryModel != null){
getZoneList();
}
else {
DialogHelper.showAlertDialog(BaseActivity.currentActivity, selectCountryFirstText);
}
break;
case R.id.addNewAddressButton:
ViewHelper.hideKeyboard();
if(checkFields())
addNewAddress();
break;
}
}
private boolean checkFields(){
/*
if(address1PizzalinkEditText.isEmail() ||
selectedCityModel == null ||
selectedCountryModel == null ||
selectedZoneModel == null){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
return false;
}
*/
if(address1AppEditText.isEmpty() ||
selectedCityModel == null ||
postcodeAppEditText.isEmpty()){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
return false;
}
if(postcodeAppEditText.getText().length() != 4){
DialogHelper.showAlertDialog(this, invalidPostcodeText);
return false;
}
return true;
}
private void getCityList(){
if(activeRequestCount == 0)
DialogHelper.showLoadingDialog();
Call<ResponseArray<CityModel>> call = ApiService.apiInterface.getCityList(SessionHelper.getSelectedStore().getStoreName());
call.enqueue(new Callback<ResponseArray<CityModel>>() {
@Override
public void onResponse(Call<ResponseArray<CityModel>> call, Response<ResponseArray<CityModel>> response) {
decreaseActiveRequestCount();
if(activeRequestCount == 0)
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyCityList(response.body().getData());
}
else if(activeRequestCount == 0){
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<CityModel>> call, Throwable t) {
decreaseActiveRequestCount();
if(activeRequestCount == 0){
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
}
});
increaseActiveRequestCount();
}
private void getCountryList(){
if(activeRequestCount == 0)
DialogHelper.showLoadingDialog();
increaseActiveRequestCount();
Call<ResponseArray<CountryModel>> call = ApiService.apiInterface.getCountryList(SessionHelper.getSelectedStore().getStoreName());
call.enqueue(new Callback<ResponseArray<CountryModel>>() {
@Override
public void onResponse(Call<ResponseArray<CountryModel>> call, Response<ResponseArray<CountryModel>> response) {
decreaseActiveRequestCount();
if(activeRequestCount == 0)
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyCountryList(response.body().getData());
}
else if(activeRequestCount == 0){
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<CountryModel>> call, Throwable t) {
decreaseActiveRequestCount();
if(activeRequestCount == 0){
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
}
});
}
private void getZoneList(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<ZoneModel>> call = ApiService.apiInterface.getZoneList(
SessionHelper.getSelectedStore().getStoreName(),
selectedCountryModel.getId());
call.enqueue(new Callback<ResponseArray<ZoneModel>>() {
@Override
public void onResponse(Call<ResponseArray<ZoneModel>> call, Response<ResponseArray<ZoneModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndShowZoneList(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<ZoneModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyCityList(ArrayList<CityModel> cities){
CityModel.checkNull(cities);
cityList.clear();
cityList.addAll(cities);
}
private void fillAndNotifyCountryList(ArrayList<CountryModel> countries){
CountryModel.checkNull(countries);
countryList.clear();
countryList.addAll(countries);
}
private void fillAndShowZoneList(ArrayList<ZoneModel> zones){
ZoneModel.checkNull(zones);
zoneList.clear();
zoneList.addAll(zones);
showZoneDialog();
}
private void showCityDialog(){
final ArrayList<String> zoneNameList = new ArrayList<>();
for(CityModel zone : cityList){
zoneNameList.add(zone.getCity());
}
DialogHelper.showListDialog(zoneNameList, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
selectedCityModel = cityList.get(position);
cityPizzalinkDropdown.setText(selectedCityModel.getCity());
}
});
}
private void showCountryDialog(){
final ArrayList<String> countryNameList = new ArrayList<>();
for(CountryModel country : countryList){
countryNameList.add(country.getName());
}
DialogHelper.showListDialog(countryNameList, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
selectedCountryModel = countryList.get(position);
countryPizzalinkDropdown.setText(selectedCountryModel.getName());
}
});
}
private void showZoneDialog(){
final ArrayList<String> zoneNameList = new ArrayList<>();
for(ZoneModel zone : zoneList){
zoneNameList.add(zone.getName());
}
DialogHelper.showListDialog(zoneNameList, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
selectedZoneModel = zoneList.get(position);
zonePizzalinkDropdown.setText(selectedZoneModel.getName());
}
});
}
private void addNewAddress(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<AddNewAddressResponseModel>> call = ApiService.apiInterface.addNewAddress(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_ADD_NEW_ADDRESS + SessionHelper.getCustomerToken().getToken(),
getAddNewAddressRequestParams());
call.enqueue(new Callback<ResponseObject<AddNewAddressResponseModel>>() {
@Override
public void onResponse(Call<ResponseObject<AddNewAddressResponseModel>> call, final Response<ResponseObject<AddNewAddressResponseModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
DialogHelper.showOneButtonDialogWithCallback(newAddressAddedText,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
Intent newAddressIntent = new Intent();
newAddressIntent.putExtra("newAddressId",
response.body().getData().getAddressId());
setResult(RESULT_OK, newAddressIntent);
finish();
}
});
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<AddNewAddressResponseModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private HashMap<String, Object> getAddNewAddressRequestParams(){
HashMap<String, Object> params = new HashMap<>();
params.put("address_1", address1AppEditText.getText());
params.put("address_2", "");
params.put("city", selectedCityModel.getCity());
//params.put("postcode", selectedCityModel.getPostcode());
params.put("postcode", postcodeAppEditText.getText());
//params.put("country_id", selectedCountryModel.getId());
//params.put("zone_id", selectedZoneModel.getZoneId());
params.put("country_id", "1");
params.put("zone_id", "1");
return params;
}
private synchronized void increaseActiveRequestCount(){
lock.lock();
try {
activeRequestCount++;
}finally {
lock.unlock();
}
}
private synchronized void decreaseActiveRequestCount(){
lock.lock();
try {
activeRequestCount--;
}finally {
lock.unlock();
}
}
}

View File

@@ -0,0 +1,44 @@
package ch.pizzacucina.android.activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import ch.pizzacucina.android.helper.DisplayHelper;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
/**
* Created by cimenmus on 11/09/2017.
*/
public class BaseActivity extends AppCompatActivity {
public static BaseActivity currentActivity;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setCurrentActivity(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
DisplayHelper.changeStatusColor();
}
}
@Override
protected void onResume() {
super.onResume();
setCurrentActivity(this);
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
public static void setCurrentActivity(BaseActivity currentActivity) {
BaseActivity.currentActivity = currentActivity;
}
}

View File

@@ -0,0 +1,463 @@
package ch.pizzacucina.android.activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.adapter.recycler.ProductCheckboxOptionsRecyclerAdapter;
import ch.pizzacucina.android.adapter.recycler.ProductRadioOptionsRecyclerAdapter;
import ch.pizzacucina.android.api.ApiConstants;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.ImageLoadHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.helper.TextHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.AddProductToBasketResponseModel;
import ch.pizzacucina.android.model.CampaignModel;
import ch.pizzacucina.android.model.cart.CartInfoModel;
import ch.pizzacucina.android.model.menu.MenuProductModel;
import ch.pizzacucina.android.model.menu.MenuProductOptionModel;
import ch.pizzacucina.android.model.menu.MenuProductOptionValueModel;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class CampaignProductDetailsActivity extends BaseActivity {
@BindView(R.id.closeImageView) ImageView closeImageView;
@BindView(R.id.backIcon) ImageView backIcon;
@BindView(R.id.productImageView) ImageView productImageView;
@BindView(R.id.productNameTextView) TextView productNameTextView;
@BindView(R.id.productPriceTextView) TextView productPriceTextView;
@BindView(R.id.productDescriptionTextView) TextView productDescriptionTextView;
@BindView(R.id.wunschpizzaAlertTextView) TextView wunschpizzaAlertTextView;
@BindView(R.id.addToCartButton) Button addToCartButton;
@BindView(R.id.recycler1HeaderTextView) TextView recycler1HeaderTextView;
@BindView(R.id.recyclerView1) RecyclerView recyclerView1;
@BindView(R.id.recycler2HeaderTextView) TextView recycler2HeaderTextView;
@BindView(R.id.recyclerView2) RecyclerView recyclerView2;
@BindView(R.id.increaseProductCountImageView) ImageView increaseProductCountImageView;
@BindView(R.id.deccreaseProductCountImageView) ImageView deccreaseProductCountImageView;
@BindView(R.id.productCountTextView) TextView productCountTextView;
@BindString(R.string.no_options_selected_part) String noOptionsSelectedText;
@BindString(R.string.cannot_use_campaign) String cannotUseCampaignText;
private int productCount = 1;
private MenuProductModel menuProductModel;
private CampaignModel campaignModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_campaign_product_details);
ButterKnife.bind(this);
getDataFromIntent();
initViews();
}
@OnClick({R.id.closeImageView,
R.id.backIcon,
R.id.addToCartButton})
public void onCLick(View view){
switch (view.getId()){
case R.id.closeImageView:
case R.id.backIcon:
finish();
break;
case R.id.addToCartButton:
if(checkFields()){
if(SessionHelper.isCustomerLoggedIn()){
addProductToCart();
/*
if((campaignModel.getCode().equals(ApiConstants.CAMPAIGN_CODE_PIZZAPASS) && SessionHelper.isUserUsedPizzapassCampaign()) ||
(campaignModel.getCode().equals(ApiConstants.CAMPAIGN_CODE_KEBAPPASS) && SessionHelper.isUserUsedKebappassCampaign())){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, cannotUseCampaignText);
}
else {
addProductToCart();
}
*/
}
else {
DialogHelper.showNeedToLoginDialog(R.string.need_to_login_for_shopping);
}
}
break;
}
}
@Override
public void onDestroy() {
super.onDestroy();
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
menuProductOptionValueModel.setSelected(false);
}
}
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
if(menuProductOptionValueModel.getPrice().equals("0") || menuProductOptionValueModel.getPrice().equals("0.00")){
/*
//checkbox
if(!(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
menuProductOptionModel.getType().toLowerCase().equals("select"))){
menuProductOptionValueModel.setSelected(true);
}
//radio
else if(!isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList())){
menuProductOptionValueModel.setSelected(true);
}
*/
/*
boolean isRadio = menuProductOptionModel.getType().toLowerCase().equals("radio") || menuProductOptionModel.getType().toLowerCase().equals("select");
boolean isAnyOptionValueSelected = isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList());
if(isRadio && !isAnyOptionValueSelected){
menuProductOptionValueModel.setSelected(true);
}
*/
}
}
}
}
private void getDataFromIntent(){
menuProductModel = (MenuProductModel) getIntent().getSerializableExtra("menuProductModel");
campaignModel = (CampaignModel) getIntent().getSerializableExtra("campaignModel");
}
private void initViews(){
setFields();
initRecyclerViews();
}
public void setMenuProductModel(MenuProductModel menuProductModel){
this.menuProductModel = menuProductModel;
}
private void initRecyclerViews(){
fixRadioAndCheckbox();
for(int i = 0; i < menuProductModel.getProductOptionList().size(); i++){
MenuProductOptionModel menuProductOptionModel = menuProductModel.getProductOptionList().get(i);
setSelectedPriceShowingOptions(menuProductOptionModel);
switch (i){
case 0:
initRecyclerView(
recycler1HeaderTextView,
recyclerView1,
menuProductOptionModel);
break;
case 1:
initRecyclerView(
recycler2HeaderTextView,
recyclerView2,
menuProductOptionModel);
break;
}
}
}
private void initRecyclerView(TextView headerTextView,
RecyclerView recyclerView,
final MenuProductOptionModel menuProductOptionModel){
headerTextView.setText(menuProductOptionModel.getName());
recyclerView.setNestedScrollingEnabled(false);
GridLayoutManager gridLayoutManager = new GridLayoutManager(BaseActivity.currentActivity, 1);
recyclerView.setLayoutManager(gridLayoutManager);
if(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
menuProductOptionModel.getType().toLowerCase().equals("select")){
final ProductRadioOptionsRecyclerAdapter productRadioOptionsRecyclerAdapter =
new ProductRadioOptionsRecyclerAdapter(menuProductOptionModel.getOptionValueModelList());
productRadioOptionsRecyclerAdapter.setRecyclerItemClickListener(new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
ArrayList<MenuProductOptionValueModel> optionValueList = menuProductOptionModel.getOptionValueModelList();
if(!optionValueList.get(position).isSelected()){
for(MenuProductOptionValueModel menuProductOptionValueModel : optionValueList){
menuProductOptionValueModel.setSelected(false);
}
optionValueList.get(position).setSelected(true);
productRadioOptionsRecyclerAdapter.notifyDataSetChanged();
productPriceTextView.setText(PriceHelper.calculatePriceAfterRadioOptionValueChanged(
productCount, menuProductModel, optionValueList.get(position)));
}
}
});
recyclerView.setAdapter(productRadioOptionsRecyclerAdapter);
headerTextView.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.VISIBLE);
}
else{
final ProductCheckboxOptionsRecyclerAdapter productCheckboxOptionsRecyclerAdapter =
new ProductCheckboxOptionsRecyclerAdapter(menuProductOptionModel.getOptionValueModelList());
productCheckboxOptionsRecyclerAdapter.setRecyclerItemClickListener(new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
ArrayList<MenuProductOptionValueModel> optionValueList = menuProductOptionModel.getOptionValueModelList();
optionValueList.get(position).setSelected(
!optionValueList.get(position).isSelected());
productCheckboxOptionsRecyclerAdapter.notifyItemChanged(position);
productPriceTextView.setText(
PriceHelper.calculatePriceAfterCheckboxOptionValueChanged(
productCount, menuProductModel, optionValueList));
}
});
recyclerView.setAdapter(productCheckboxOptionsRecyclerAdapter);
headerTextView.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.VISIBLE);
}
}
private void setFields(){
TextHelper.setTextFromHTML(productDescriptionTextView, menuProductModel.getDescription());
ImageLoadHelper.loadImage(productImageView, menuProductModel.getImageURL());
productNameTextView.setText(menuProductModel.getName());
productPriceTextView.setText(PriceHelper.getPriceWithCurreny(menuProductModel.getPrice()));
productPriceTextView.setText(PriceHelper.getPriceWithCurreny(menuProductModel.getPrice()));
if(menuProductModel.getId().equals(String.valueOf(ApiConstants.PRODUCT_ID_WUNSCHPIZZA))){
wunschpizzaAlertTextView.setVisibility(View.VISIBLE);
}
else {
wunschpizzaAlertTextView.setVisibility(View.GONE);
}
}
private void fixRadioAndCheckbox(){
if(menuProductModel.getId().equals(String.valueOf(ApiConstants.PRODUCT_ID_ABEND_MENU)) ||
menuProductModel.getId().equals(String.valueOf(ApiConstants.PRODUCT_ID_MITTAGS_MENU))){
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
boolean isAbendMenuPizzaSelection =
menuProductOptionModel.getOptionId().equals(ApiConstants.OPTION_ID_ABEND_AND_MITTAGS_MENU_PIZZA_SELECTION) &&
menuProductOptionModel.getProductOptionId().equals(ApiConstants.PRODUCT_OPTION_ID_ABEND_MENU_PIZZA_SELECTION);
boolean isMittagsMenuPizzaSelection =
menuProductOptionModel.getOptionId().equals(ApiConstants.OPTION_ID_ABEND_AND_MITTAGS_MENU_PIZZA_SELECTION) &&
menuProductOptionModel.getProductOptionId().equals(ApiConstants.PRODUCT_OPTION_ID_MITTAGS_MENU_OPTIONS);
if(isAbendMenuPizzaSelection || isMittagsMenuPizzaSelection){
menuProductOptionModel.setType("radio");
}
}
}
ArrayList<MenuProductOptionModel> sortedOptionList = menuProductModel.getProductOptionList();
Collections.sort(
sortedOptionList,
new Comparator<MenuProductOptionModel>() {
@Override
public int compare(MenuProductOptionModel o1, MenuProductOptionModel o2) {
//return o2.getType().compareTo(o1.getType());
//return o1.getOptionValueModelList().size() - o2.getOptionValueModelList().size();
return o1.getOrder() - o2.getOrder();
}
});
menuProductModel.setProductOptionList(sortedOptionList);
}
private void setSelectedPriceShowingOptions(MenuProductOptionModel menuProductOptionModel){
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
if(menuProductOptionValueModel.getPrice().equals("0") || menuProductOptionValueModel.getPrice().equals("0.00")){
/*
//checkbox
if(!(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
menuProductOptionModel.getType().toLowerCase().equals("select"))){
menuProductOptionValueModel.setSelected(true);
}
//radio
else if(!isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList())){
menuProductOptionValueModel.setSelected(true);
}
*/
/*
boolean isRadio = menuProductOptionModel.getType().toLowerCase().equals("radio") || menuProductOptionModel.getType().toLowerCase().equals("select");
boolean isAnyOptionValueSelected = isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList());
if(isRadio && !isAnyOptionValueSelected){
menuProductOptionValueModel.setSelected(true);
}
*/
}
}
}
private void addProductToCart(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<AddProductToBasketResponseModel>> call =
ApiService.apiInterface.addProductsToBasket(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_ADD_PRODUCTS_TO_BASKET + SessionHelper.getCustomerToken().getToken(),
getAddToCartRequestParams());
call.enqueue(new Callback<ResponseObject<AddProductToBasketResponseModel>>() {
@Override
public void onResponse(Call<ResponseObject<AddProductToBasketResponseModel>> call, Response<ResponseObject<AddProductToBasketResponseModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() && response.body().getData() != null){
if(response.body().isSuccess()){
getCartItemCount(response.body().getData().getSuccessMessage());
}
else
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, response.body().getData().getErrorMessage());
}
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseObject<AddProductToBasketResponseModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private RequestBody getAddToCartRequestParams(){
FormBody.Builder formBodyBuilder = new FormBody.Builder();
formBodyBuilder.add("product_id", menuProductModel.getId());
formBodyBuilder.add("quantity", String.valueOf(productCount));
for(MenuProductOptionModel productOptionModel : menuProductModel.getProductOptionList()){
ArrayList<String> selectedCheckboxOptionList = new ArrayList<>();
for(MenuProductOptionValueModel productOptionValueModel : productOptionModel.getOptionValueModelList()){
if(productOptionValueModel.isSelected()){
if(productOptionModel.getType().toLowerCase().equals("checkbox")){
selectedCheckboxOptionList.add(productOptionValueModel.getProductOptionValueId());
}
else {
String key = "option[" + productOptionModel.getProductOptionId() + "]";
formBodyBuilder.add(key, productOptionValueModel.getProductOptionValueId());
}
}
}
if(productOptionModel.getType().toLowerCase().equals("checkbox")){
for(int i = 0; i < selectedCheckboxOptionList.size(); i++){
String key = "option[" + productOptionModel.getProductOptionId() + "][" + String.valueOf(i) + "]";
formBodyBuilder.add(key, selectedCheckboxOptionList.get(i));
}
}
}
return formBodyBuilder.build();
}
private void getCartItemCount(final String dialogMessage){
/*
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
*/
HashMap<String, Object> params = new HashMap<>();
if(SessionHelper.getSelectedCoupon() != null){
params.put("coupon", SessionHelper.getSelectedCoupon().getCode());
}
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
params);
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
@Override
public void onResponse(Call<ResponseObject<CartInfoModel>> call, Response<ResponseObject<CartInfoModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
SharedPrefsHelper.setCartItemCount(response.body().getData().getProducts().size());
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(response.body().getData().getCartTotalModel().getText()));
DialogHelper.showOneButtonDialogWithCallback(
dialogMessage,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
setResult(RESULT_OK);
finish();
}
},
false);
}
}
@Override
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
}
});
}
private boolean checkFields(){
for(int i = 0; i < menuProductModel.getProductOptionList().size(); i++){
MenuProductOptionModel menuProductOptionValueModel = menuProductModel.getProductOptionList().get(i);
boolean isRadio = menuProductOptionValueModel.getType().toLowerCase().equals("radio") || menuProductOptionValueModel.getType().toLowerCase().equals("select");
if(isRadio && !isSelectedAtLeastOne(menuProductModel.getProductOptionList().get(i).getOptionValueModelList())){
DialogHelper.showAlertDialog(BaseActivity.currentActivity,
menuProductModel.getProductOptionList().get(i).getName() + " " + noOptionsSelectedText);
return false;
}
}
return true;
}
private boolean isSelectedAtLeastOne(ArrayList<MenuProductOptionValueModel> menuProductOptionValueModels){
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionValueModels){
if(menuProductOptionValueModel.isSelected()){
return true;
}
}
return false;
}
private boolean isAnyOptionValueSelected(ArrayList<MenuProductOptionValueModel> menuProductOptionValueModels){
for (MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionValueModels){
if(menuProductOptionValueModel.isSelected()){
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,133 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.adapter.recycler.MenuProductRecyclerAdapter;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.CampaignModel;
import ch.pizzacucina.android.model.menu.MenuProductModel;
import ch.pizzacucina.android.view.AppToolbar;
import ch.pizzacucina.android.view.GridSpacesItemDecoration;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class CampaignProductListActivity extends BaseActivity {
@BindView(R.id.campaignProductsAppToolbar) AppToolbar campaignProductsAppToolbar;
@BindView(R.id.campaignProductRecyclerView) RecyclerView campaignProductRecyclerView;
private ArrayList<MenuProductModel> menuProductList = new ArrayList<>();
private MenuProductRecyclerAdapter menuProductRecyclerAdapter;
private CampaignModel campaignModel;
private int REQUEST_CODE_CAMPAIGN_PRODUCT_PROPERTIES = 4756;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_campaign_product_list);
ButterKnife.bind(this);
getDataFromIntent();
initViews();
getCampaignProducts();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE_CAMPAIGN_PRODUCT_PROPERTIES && resultCode == RESULT_OK){
setResult(RESULT_OK);
finish();
}
}
private void getDataFromIntent(){
campaignModel = (CampaignModel) getIntent().getSerializableExtra("campaignModel");
}
private void initViews(){
campaignProductsAppToolbar.setTitle(campaignModel.getName());
initRecyclerView();
}
private void initRecyclerView(){
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
campaignProductRecyclerView.setLayoutManager(layoutManager);
menuProductRecyclerAdapter = new MenuProductRecyclerAdapter(
menuProductList,
true,
new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, CampaignProductDetailsActivity.class);
productPropertiesIntent.putExtra("menuProductModel", menuProductList.get(position));
productPropertiesIntent.putExtra("campaignModel", campaignModel);
//productPropertiesIntent.putExtra("isFromPizzapassCampaign", categoryModel.isPizzapassCampaign());
//productPropertiesIntent.putExtra("isFromKebappassCampaign", categoryModel.isKebappassCampaign());
startActivityForResult(productPropertiesIntent, REQUEST_CODE_CAMPAIGN_PRODUCT_PROPERTIES);
}
});
campaignProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(2, 16, true));
campaignProductRecyclerView.setAdapter(menuProductRecyclerAdapter);
}
private void getCampaignProducts(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductsByCategory(
SessionHelper.getSelectedStore().getStoreName(),
campaignModel.getCategoryId());
call.enqueue(new Callback<ResponseArray<MenuProductModel>>() {
@Override
public void onResponse(Call<ResponseArray<MenuProductModel>> call, Response<ResponseArray<MenuProductModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess())
fillAndNotifyProductList(response.body().getData());
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseArray<MenuProductModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyProductList(ArrayList<MenuProductModel> productList){
MenuProductModel.checkNull(productList);
menuProductList.clear();
menuProductList.addAll(productList);
sortProductsByName();
menuProductRecyclerAdapter.notifyDataSetChanged();
}
private void sortProductsByName(){
Collections.sort(menuProductList, new Comparator<MenuProductModel>() {
@Override
public int compare(MenuProductModel product1, MenuProductModel product2) {
return product1.getName().compareTo(product2.getName());
}
});
}
}

View File

@@ -0,0 +1,306 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.CardView;
import android.view.View;
import android.webkit.WebView;
import com.badoualy.stepperindicator.StepperIndicator;
import com.braintreepayments.api.dropin.utils.PaymentMethodType;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiConstants;
import ch.pizzacucina.android.fragment.createOrder.CreateOrderNoteFragment;
import ch.pizzacucina.android.fragment.createOrder.CreateOrderResultFragment;
import ch.pizzacucina.android.fragment.createOrder.CreateOrderSummaryFragment;
import ch.pizzacucina.android.fragment.createOrder.PaymentMethodFragment;
import ch.pizzacucina.android.fragment.createOrder.ShippingAddressFragment;
import ch.pizzacucina.android.fragment.createOrder.ShippingMethodFragment;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.model.AddressModel;
import ch.pizzacucina.android.model.PaymentMethodModel;
import ch.pizzacucina.android.model.ShippingMethodModel;
import ch.pizzacucina.android.model.cart.CartInfoModel;
public class CreateOrderActivity extends BaseActivity {
@BindView(R.id.createOrderCardView) CardView createOrderCardView;
@BindView(R.id.paymentWebView) WebView paymentWebView;
@BindView(R.id.stepperIndicator) StepperIndicator stepperIndicator;
private FragmentManager fragmentManager;
private CartInfoModel cartInfoModel;
private ShippingMethodModel selectedShippingMethod;
private AddressModel selectedShippingAddress;
private PaymentMethodModel selectedPaymentMethod;
private Boolean slicePizza;
private String orderNote;
private String discountAmount;
private String couponCode;
private ArrayList<PaymentMethodModel> paymentMethodList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_order);
ButterKnife.bind(this);
getDataFromIntent();
initViews();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
private void getDataFromIntent(){
cartInfoModel = (CartInfoModel) getIntent().getSerializableExtra("cartInfoModel");
}
private void initViews(){
fragmentManager = getSupportFragmentManager();
initStepIndicator();
openFragment(0);
}
private void initStepIndicator(){
/*
6 fragment var, ama sonuncu step'te tik göstersin diye step sayısını, fragment sayısı - 1 yaptık
*/
stepperIndicator.setStepCount(5);
/*
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,
CreateOrderNoteFragment.newInstance()).commit();
break;
case 4:
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
CreateOrderSummaryFragment.newInstance()).commit();
break;
case 5:
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
CreateOrderResultFragment.newInstance()).commit();
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 CreateOrderNoteFragment.FRAGMENT_NAME:
openFragment(4);
break;
case CreateOrderSummaryFragment.FRAGMENT_NAME:
openFragment(5);
break;
case CreateOrderResultFragment.FRAGMENT_NAME:
Intent mainActivityIntent = new Intent(this, MainActivity.class);
mainActivityIntent.putExtra("isStartWithOrderHistory", true);
startActivity(mainActivityIntent);
SharedPrefsHelper.setCartItemCount(0);
SharedPrefsHelper.setCartTotalPrice("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 CreateOrderNoteFragment.FRAGMENT_NAME:
openFragment(2);
break;
case CreateOrderSummaryFragment.FRAGMENT_NAME:
openFragment(3);
break;
}
}
public CartInfoModel getCartInfo(){
return cartInfoModel;
}
/**
* Kampanya urunu detay sayfasında urunun fiyatı 0 olan tum optionlarını seçiyor,
* bunun da düzeltilmesi gerekiyor!!
*/
/**
* eğer kampanya kullanıldıysa cartInfoModel de isPizzapassCampaignUsed ve isKebappassCampaignUsed
* alanalrını true olarak set ediyoruz. create order ekranlarında herhangi bir yerde sepet sorgusu yapınca
* buradaki cartInfoModel i de güncelliyoruz. fakat isPizzapassCampaignUsed ve isKebappassCampaignUsed alanları
* servisten gelmeyen değerler, bizim loaklde tuttuğumuz değişkenler. bu sebeple bu alanlar servisten hep false geliyor,
* buradakinde true olsa bile değişkeni guncellediğimiz için bu alanlar kayboluyor. bunu engellemek için bu metodu yazdım.
*/
public void setCartInfoSafeForCampaigns(CartInfoModel cartInfoModel) {
cartInfoModel.setPizzapassCampaignUsed(this.cartInfoModel.isPizzapassCampaignUsed());
cartInfoModel.setKebappassCampaignUsed(this.cartInfoModel.isKebappassCampaignUsed());
this.cartInfoModel = cartInfoModel;
}
/*
public void setCartInfo(CartInfoModel cartInfoModel) {
this.cartInfoModel = cartInfoModel;
}
*/
public ShippingMethodModel getSelectedShippingMethod(){
return selectedShippingMethod;
}
public void setSelectedShippingMethod(ShippingMethodModel selectedShippingMethod){
this.selectedShippingMethod = selectedShippingMethod;
}
public AddressModel getSelectedShippingAddress(){
return selectedShippingAddress;
}
public void setSelectedShippingAddress(AddressModel selectedShippingAddress){
this.selectedShippingAddress = selectedShippingAddress;
}
public PaymentMethodModel getSelectedPaymentMethod(){
return selectedPaymentMethod;
}
public void setSelectedPaymentMethod(PaymentMethodModel selectedPaymentMethod){
this.selectedPaymentMethod = selectedPaymentMethod;
}
public void setSelectedPaymentMethodForBraintree(PaymentMethodType paymentMethodType){
String paymentMethodCode = "";
switch (paymentMethodType){
case PAYPAL:
paymentMethodCode = ApiConstants.PAYMENT_METHOD_CODE_PAYPAL;
break;
case ANDROID_PAY:
paymentMethodCode = ApiConstants.PAYMENT_METHOD_CODE_ANDROID_PAY;
break;
default:
paymentMethodCode = ApiConstants.PAYMENT_METHOD_CODE_CREDIT_DEBIT_CARD;
break;
}
for(PaymentMethodModel paymentMethodModel : paymentMethodList){
if(paymentMethodModel.getCode().equalsIgnoreCase(paymentMethodCode)){
selectedPaymentMethod = paymentMethodModel;
break;
}
}
}
public String getOrderNote(){
if(orderNote == null)
orderNote = "";
return orderNote;
}
public void setPaymentWebViewVisibility(final boolean show){
if(show){
createOrderCardView.setVisibility(View.GONE);
paymentWebView.setVisibility(View.VISIBLE);
}
else {
createOrderCardView.setVisibility(View.VISIBLE);
paymentWebView.setVisibility(View.GONE);
}
}
/*
@Override
public void onBackPressed() {
if(paymentWebView.getVisibility() == View.VISIBLE){
if(paymentWebView.canGoBack()){
paymentWebView.goBack();
}
else{
setPaymentWebViewVisibility(false);
}
}
else{
super.onBackPressed();
}
}
*/
public void setOrderNote(String orderNote){
this.orderNote = orderNote;
}
public Boolean getSlicePizza() {
return slicePizza;
}
public void setSlicePizza(Boolean slicePizza) {
this.slicePizza = slicePizza;
}
public String getDiscountAmount() {
return discountAmount;
}
public void setDiscountAmount(String discountAmount) {
this.discountAmount = discountAmount;
}
public String getCouponCode() {
return couponCode;
}
public void setCouponCode(String couponCode) {
this.couponCode = couponCode;
}
public void setPaymentMethodList(ArrayList<PaymentMethodModel> paymentMethodList) {
this.paymentMethodList = paymentMethodList;
}
public WebView getPaymentWebView() {
return paymentWebView;
}
}

View File

@@ -0,0 +1,98 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.os.Bundle;
import android.widget.Button;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.ViewHelper;
import ch.pizzacucina.android.view.AppEditText;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ForgotPasswordActivity extends BaseActivity {
@BindView(R.id.forgotPasswordEmailPizzalinkEditText)
AppEditText forgotPasswordEmailAppEditText;
@BindView(R.id.resetPasswordButton) Button resetPasswordButton;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_invalid_email) String validEmailText;
@BindString(R.string.password_reset) String passwordResetText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forgot_password);
ButterKnife.bind(this);
}
@OnClick(R.id.resetPasswordButton)
protected void onClick(){
ViewHelper.hideKeyboard();
if(checkFields()){
resetPassword();
}
}
private boolean checkFields(){
if(forgotPasswordEmailAppEditText.isEmpty()){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
return false;
}
if(!forgotPasswordEmailAppEditText.isEmail()){
DialogHelper.showAlertDialog(this, validEmailText);
return false;
}
return true;
}
private void resetPassword(){
DialogHelper.showLoadingDialog();
Call<ResponseObject> call = ApiService.apiInterface.forgotPassword(
SessionHelper.getSelectedStore().getStoreName(),
forgotPasswordEmailAppEditText.getText());
call.enqueue(new Callback<ResponseObject>() {
@Override
public void onResponse(Call<ResponseObject> call, Response<ResponseObject> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() && response.body().isSuccess()){
DialogHelper.showOneButtonDialogWithCallback(passwordResetText, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent(BaseActivity.currentActivity, LoginActivity.class);
BaseActivity.currentActivity.startActivity(intent);
BaseActivity.currentActivity.finishAffinity();
}
});
}
else{
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
}

View File

@@ -0,0 +1,176 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.helper.ViewHelper;
import ch.pizzacucina.android.model.CustomerTokenModel;
import ch.pizzacucina.android.model.UserModel;
import ch.pizzacucina.android.model.cart.CartInfoModel;
import ch.pizzacucina.android.view.AppEditText;
import ch.pizzacucina.android.view.AppToolbar;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LoginActivity extends BaseActivity {
@BindView(R.id.loginAppToolbar) AppToolbar loginAppToolbar;
@BindView(R.id.emailPizzalinkEditText) AppEditText emailAppEditText;
@BindView(R.id.passwordPizzalinkEditText) AppEditText passwordAppEditText;
@BindView(R.id.loginButton) Button loginButton;
@BindView(R.id.forgotPasswordTextView) TextView forgotPasswordTextView;
@BindString(R.string.forgot_password_hint) String forgotPasswordHintText;
@BindString(R.string.reset_password) String resetPasswordText;
@BindString(R.string.not_have_an_accaount) String notHaveAnAccountText;
@BindString(R.string.register_text) String registerText;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_invalid_email) String validEmailText;
private boolean showBackIcon;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
getDataFromIntent();
initViews();
}
@OnClick({R.id.loginButton, R.id.forgotPasswordTextView,
R.id.registerButton, R.id.loginAsGuestTextView})
protected void onClick(View view){
switch (view.getId()){
case R.id.loginButton:
ViewHelper.hideKeyboard();
if(checkFields())
login();
break;
case R.id.forgotPasswordTextView:
startActivity(new Intent(LoginActivity.this, ForgotPasswordActivity.class));
break;
case R.id.registerButton:
startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
break;
case R.id.loginAsGuestTextView:
startActivity(new Intent(LoginActivity.this, MainActivity.class));
break;
}
}
private void getDataFromIntent(){
showBackIcon = getIntent().getBooleanExtra("showBackIcon", false);
}
private void initViews(){
loginAppToolbar.setBackIconVisibility(showBackIcon);
}
private boolean checkFields(){
if(emailAppEditText.isEmpty() || passwordAppEditText.isEmpty()){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
return false;
}
if(!emailAppEditText.isEmail()){
DialogHelper.showAlertDialog(this, validEmailText);
return false;
}
return true;
}
private void login(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<UserModel>> call = ApiService.apiInterface.login(
SessionHelper.getSelectedStore().getStoreName(),
emailAppEditText.getText(), passwordAppEditText.getText());
call.enqueue(new Callback<ResponseObject<UserModel>>() {
@Override
public void onResponse(Call<ResponseObject<UserModel>> call, Response<ResponseObject<UserModel>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
SharedPrefsHelper.saveUser(response.body().getData());
CustomerTokenModel customerTokenModel = response.body().getData().getToken();
customerTokenModel.setStoreOfToken(SessionHelper.getSelectedStore());
SharedPrefsHelper.saveCustomerToken(customerTokenModel);
SharedPrefsHelper.setCustomerLoggedIn(true);
getCartItemCount();
}
else{
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseErrorWithoutAuthorizationErrorControl(response);
}
}
@Override
public void onFailure(Call<ResponseObject<UserModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void getCartItemCount(){
/*
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
*/
HashMap<String, Object> params = new HashMap<>();
if(SessionHelper.getSelectedCoupon() != null){
params.put("coupon", SessionHelper.getSelectedCoupon().getCode());
}
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
params);
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
@Override
public void onResponse(Call<ResponseObject<CartInfoModel>> call, Response<ResponseObject<CartInfoModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
SharedPrefsHelper.setCartItemCount(response.body().getData().getProducts().size());
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(response.body().getData().getCartTotalModel().getText()));
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finishAffinity();
}
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
}

View File

@@ -0,0 +1,558 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindColor;
import butterknife.BindDrawable;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.adapter.recycler.NavigationMenuRecyclerAdapter;
import ch.pizzacucina.android.fragment.CartFragment;
import ch.pizzacucina.android.fragment.OrderHistoryFragment;
import ch.pizzacucina.android.fragment.StoreInfoFragment;
import ch.pizzacucina.android.fragment.MenuFragment;
import ch.pizzacucina.android.fragment.ProductFragment;
import ch.pizzacucina.android.fragment.ProfileFragment;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.model.CategoryModel;
import ch.pizzacucina.android.view.AppToolbar;
import io.github.luizgrp.sectionedrecyclerviewadapter.SectionParameters;
import io.github.luizgrp.sectionedrecyclerviewadapter.SectionedRecyclerViewAdapter;
import io.github.luizgrp.sectionedrecyclerviewadapter.StatelessSection;
public class MainActivity extends BaseActivity {
@BindView(R.id.drawerLayout) DrawerLayout drawerLayout;
@BindView(R.id.navigationMenuRecyclerView) RecyclerView navigationMenuRecyclerView;
@BindView(R.id.pizzalinkToolbar) AppToolbar appToolbar;
@BindView(R.id.cartTotalRelativeLayout) RelativeLayout cartTotalRelativeLayout;
@BindView(R.id.cartTotalTextView) TextView cartTotalTextView;
@BindView(R.id.minimumPriceTextView) TextView minimumPriceTextView;
@BindView(R.id.bottomNavigationView) BottomNavigationViewEx bottomNavigationView;
@BindView(R.id.badgeLayout) RelativeLayout badgeLayout;
@BindView(R.id.badgeTextView) TextView badgeTextView;
@BindView(R.id.shoppingCartButtonLayout) RelativeLayout shoppingCartButtonLayout;
@BindView(R.id.shoppingCartImageView) ImageView shoppingCartImageView;
@BindView(R.id.shoppingCartTextView) TextView shoppingCartTextView;
@BindDrawable(R.drawable.ic_bottom_nav_item_cart_gray) Drawable grayCartDrawable;
@BindDrawable(R.drawable.ic_bottom_nav_item_cart_yellow) Drawable yellowCartDrawable;
@BindColor(R.color.yellow) int yellowColor;
@BindColor(R.color.white) int whiteColor;
private FragmentManager fragmentManager;
private String currentFragmentName = "";
private int currentCategoryId = -1;
private boolean isStartWithOrderHistory, isStartWithCart;
private ArrayList<CategoryModel> categoryList = new ArrayList<>();
private NavigationMenuRecyclerAdapter navigationMenuRecyclerAdapter;
//private Badge badge;
private Animation animUp,animDown;
private SectionedRecyclerViewAdapter sectionAdapter = new SectionedRecyclerViewAdapter();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
getDataFromIntent();
initViews();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onResume() {
super.onResume();
setCartItemCount();
}
private void getDataFromIntent(){
isStartWithOrderHistory = getIntent().getBooleanExtra("isStartWithOrderHistory", false);
isStartWithCart = getIntent().getBooleanExtra("isStartWithCart", false);
}
private void initViews(){
//initBadgeView();
initNavigationDrawer();
initBottomNavigationView();
showStartScreen();
setCartItemCount();
initShoppingCartButton();
minimumPriceTextView.setText(PriceHelper.getPriceWithCurreny(SessionHelper.getSelectedStore().getMinimumPrice()));
}
private void initShoppingCartButton(){
animDown = AnimationUtils.loadAnimation(this, R.anim.anim_scale_down);
animUp = AnimationUtils.loadAnimation(this, R.anim.anim_scale_up);
shoppingCartButtonLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case (android.view.MotionEvent.ACTION_DOWN):
shoppingCartButtonLayout.startAnimation(animDown);
return false;
case (android.view.MotionEvent.ACTION_UP):
shoppingCartButtonLayout.startAnimation(animUp);
return false;
case (android.view.MotionEvent.ACTION_CANCEL):
shoppingCartButtonLayout.startAnimation(animUp);
}
return false;
}
});
shoppingCartButtonLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!SessionHelper.isCustomerLoggedIn()){
DialogHelper.showNeedToLoginDialog(R.string.need_to_login_for_that_part);
return;
}
bottomNavigationView.setCurrentItem(2);
}
});
}
/*
private void initBadgeView(){
badge = new QBadgeView(this)
.setBadgeBackgroundColor(yellowColor)
.setBadgeTextColor(whiteColor)
.setBadgeGravity(Gravity.TOP | Gravity.END);
}
*/
private void showStartScreen(){
fragmentManager = getSupportFragmentManager();
if(isStartWithOrderHistory){
bottomNavigationView.setCurrentItem(1);
}
else if(isStartWithCart){
bottomNavigationView.setCurrentItem(2);
}
else {
openProductsScreen(getDefaultCategory());
}
}
private void initBottomNavigationView(){
//bottomNavigationView.enableAnimation(false);
bottomNavigationView.enableShiftingMode(false);
bottomNavigationView.setTextSize(10);
bottomNavigationView.enableItemShiftingMode(false);
bottomNavigationView.setTextVisibility(true);
bottomNavigationView.setIconSize(24, 24);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.action_menu:
/*
if (currentFragmentName.equals(MenuFragment.FRAGMENT_NAME))
return true;
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
MenuFragment.newInstance(categoryList.get(ApiConstants.NAVIGATION_MENU_DEFAULT_CATEGORY_INDEX))).commit();
currentFragmentName = MenuFragment.FRAGMENT_NAME;
*/
openProductsScreen(getDefaultCategory());
shoppingCartImageView.setImageDrawable(grayCartDrawable);
shoppingCartTextView.setTextColor(whiteColor);
if(!SessionHelper.isCustomerLoggedIn()) {
cartTotalRelativeLayout.setVisibility(View.GONE);
return true;
}
/*
if(!SharedPrefsHelper.getCartTotalPrice().equals("0") &&
!SharedPrefsHelper.getCartTotalPrice().equals("0.0") &&
!SharedPrefsHelper.getCartTotalPrice().equals("0.00")){
cartTotalTextView.setText(PriceHelper.getPriceWithCurreny(SharedPrefsHelper.getCartTotalPrice()));
cartTotalRelativeLayout.setVisibility(View.VISIBLE);
}
*/
cartTotalRelativeLayout.setVisibility(View.VISIBLE);
return true;
case R.id.action_empty:
if(!SessionHelper.isCustomerLoggedIn()){
DialogHelper.showNeedToLoginDialog(R.string.need_to_login_for_that_part);
return false;
}
if (currentFragmentName.equals(CartFragment.FRAGMENT_NAME))
return true;
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, CartFragment.newInstance()).commit();
currentFragmentName = CartFragment.FRAGMENT_NAME;
currentCategoryId = -1;
cartTotalRelativeLayout.setVisibility(View.GONE);
shoppingCartImageView.setImageDrawable(yellowCartDrawable);
shoppingCartTextView.setTextColor(yellowColor);
return true;
case R.id.action_history:
if(!SessionHelper.isCustomerLoggedIn()){
DialogHelper.showNeedToLoginDialog(R.string.need_to_login_for_that_part);
return false;
}
if (currentFragmentName.equals(OrderHistoryFragment.FRAGMENT_NAME))
return true;
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, OrderHistoryFragment.newInstance()).commit();
currentFragmentName = OrderHistoryFragment.FRAGMENT_NAME;
currentCategoryId = -1;
cartTotalRelativeLayout.setVisibility(View.GONE);
shoppingCartImageView.setImageDrawable(grayCartDrawable);
shoppingCartTextView.setTextColor(whiteColor);
return true;
case R.id.action_profile:
if(!SessionHelper.isCustomerLoggedIn()){
DialogHelper.showNeedToLoginDialog(R.string.need_to_login_for_that_part);
return false;
}
if (currentFragmentName.equals(ProfileFragment.FRAGMENT_NAME))
return true;
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, ProfileFragment.newInstance()).commit();
currentFragmentName = ProfileFragment.FRAGMENT_NAME;
currentCategoryId = -1;
cartTotalRelativeLayout.setVisibility(View.GONE);
shoppingCartImageView.setImageDrawable(grayCartDrawable);
shoppingCartTextView.setTextColor(whiteColor);
return true;
case R.id.action_info:
if (currentFragmentName.equals(StoreInfoFragment.FRAGMENT_NAME))
return true;
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, StoreInfoFragment.newInstance()).commit();
currentFragmentName = StoreInfoFragment.FRAGMENT_NAME;
currentCategoryId = -1;
cartTotalRelativeLayout.setVisibility(View.GONE);
shoppingCartImageView.setImageDrawable(grayCartDrawable);
shoppingCartTextView.setTextColor(whiteColor);
return true;
}
return false;
}
});
}
private void initNavigationDrawer(){
initNavigationMenuRecyclerView();
appToolbar.getHamburgerIcon().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(drawerLayout.isDrawerOpen(GravityCompat.START))
drawerLayout.closeDrawers();
else
openNavigationDrawer();
}
});
}
private void openNavigationDrawer(){
drawerLayout.openDrawer(GravityCompat.START);
}
public void setPizzalinkToolbarFields(boolean showHamburgerIcon, String title){
appToolbar.setHamburgerIconVisibility(showHamburgerIcon);
appToolbar.setTitle(title);
if(showHamburgerIcon)
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
else
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
private void initNavigationMenuRecyclerView(){
categoryList = SharedPrefsHelper.readCategoryList();
for(int i = 0; i < categoryList.size(); i++){
List<CategoryModel> subcategoryList = categoryList.get(i).getSubCategoryList();
sectionAdapter.addSection(new CategorySection(i, categoryList.get(i).getName(), subcategoryList));
}
navigationMenuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
navigationMenuRecyclerView.setAdapter(sectionAdapter);
}
private class CategorySection extends StatelessSection {
String title;
List<CategoryModel> list;
int pstn;
CategorySection(int pstn, String title, List<CategoryModel> list) {
super(new SectionParameters.Builder(R.layout.row_subcategory)
.headerResourceId(R.layout.row_category)
.build());
this.title = title;
this.list = list;
this.pstn = pstn;
}
private class HeaderViewHolder extends RecyclerView.ViewHolder {
private final View rootView;
private final TextView categoryNameItem;
private final View bottomLineView;
HeaderViewHolder(View view) {
super(view);
rootView = view;
categoryNameItem = (TextView) view.findViewById(R.id.categoryNameItem);
bottomLineView = view.findViewById(R.id.bottomLineView);
}
}
private class ItemViewHolder extends RecyclerView.ViewHolder {
private final View rootView;
private final TextView subcategoryNameItem;
private final View bottomLineView;
ItemViewHolder(View view) {
super(view);
rootView = view;
subcategoryNameItem = (TextView) view.findViewById(R.id.subcategoryNameItem);
bottomLineView = (View) view.findViewById(R.id.bottomLineView);
}
}
@Override
public RecyclerView.ViewHolder getHeaderViewHolder(View view) {
return new HeaderViewHolder(view);
}
@Override
public RecyclerView.ViewHolder getItemViewHolder(View view) {
return new ItemViewHolder(view);
}
@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder) {
final HeaderViewHolder headerHolder = (HeaderViewHolder) holder;
headerHolder.categoryNameItem.setText(title);
headerHolder.rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openProductsScreen(categoryList.get(pstn));
}
});
if(pstn == categoryList.size() - 1){
headerHolder.bottomLineView.setVisibility(View.GONE);
return;
}
if(categoryList.get(pstn).getSubCategoryList() == null ||
categoryList.get(pstn).getSubCategoryList().size() == 0){
headerHolder.bottomLineView.setVisibility(View.VISIBLE);
}else {
headerHolder.bottomLineView.setVisibility(View.GONE);
}
}
@Override
public void onBindItemViewHolder(RecyclerView.ViewHolder holder, final int position) {
final ItemViewHolder itemHolder = (ItemViewHolder) holder;
String name = list.get(position).getName();
itemHolder.subcategoryNameItem.setText(name);
if(position == list.size() - 1){
itemHolder.bottomLineView.setVisibility(View.VISIBLE);
}
else {
itemHolder.bottomLineView.setVisibility(View.GONE);
}
itemHolder.rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openProductsScreen(list.get(position));
}
});
}
@Override
public int getContentItemsTotal() {
return list.size();
}
}
private void openProductsScreen(CategoryModel clickedCategoryModel){
drawerLayout.closeDrawers();
if(clickedCategoryModel.isSpecialCategory()){
if(currentFragmentName.equals(ProductFragment.FRAGMENT_NAME) &&
currentCategoryId == clickedCategoryModel.getId())
return;
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
ProductFragment.newInstance(clickedCategoryModel)).commit();
currentFragmentName = ProductFragment.FRAGMENT_NAME;
currentCategoryId = clickedCategoryModel.getId();
}
else {
if(currentFragmentName.equals(MenuFragment.FRAGMENT_NAME) &&
currentCategoryId == clickedCategoryModel.getId())
return;
fragmentManager.beginTransaction().replace(R.id.fragmentContainer,
MenuFragment.newInstance(clickedCategoryModel)).commit();
currentFragmentName = MenuFragment.FRAGMENT_NAME;
currentCategoryId = clickedCategoryModel.getId();
}
}
public void setCartItemCount(){
updateBadge();
updateCartTotalRelativeLayout();
}
public void reopenCartFragment(){
currentFragmentName = "";
bottomNavigationView.setCurrentItem(2);
}
/*
private void addBadge(int position, int number) {
badge.setBadgeNumber(number);
badge.bindTarget(bottomNavigationView.getBottomNavigationItemView(position));
}
*/
private void updateCartTotalRelativeLayout() {
if(!SessionHelper.isCustomerLoggedIn()) {
cartTotalRelativeLayout.setVisibility(View.GONE);
return;
}
/*
if(SharedPrefsHelper.getCartTotalPrice().equals("0") ||
SharedPrefsHelper.getCartTotalPrice().equals("0.0") ||
SharedPrefsHelper.getCartTotalPrice().equals("0.00")){
cartTotalRelativeLayout.setVisibility(View.GONE);
}
else {
cartTotalTextView.setText(PriceHelper.getPriceWithCurreny(SharedPrefsHelper.getCartTotalPrice()));
cartTotalRelativeLayout.setVisibility(View.VISIBLE);
}
*/
cartTotalTextView.setText(PriceHelper.getPriceWithCurreny(SharedPrefsHelper.getCartTotalPrice()));
if(getSupportFragmentManager().findFragmentById(R.id.fragmentContainer) != null &&
getSupportFragmentManager().findFragmentById(R.id.fragmentContainer) instanceof MenuFragment){
cartTotalRelativeLayout.setVisibility(View.VISIBLE);
}
}
public void updateBadge(){
if(!SessionHelper.isCustomerLoggedIn()) {
badgeLayout.setVisibility(View.GONE);
return;
}
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(!SessionHelper.isCustomerLoggedIn()) {
cartTotalRelativeLayout.setVisibility(View.GONE);
return;
}
if(isVisible){
cartTotalRelativeLayout.setVisibility(View.VISIBLE);
}
else {
cartTotalRelativeLayout.setVisibility(View.GONE);
}
}
private CategoryModel getDefaultCategory(){
CategoryModel defaultCategory = null;
for(CategoryModel categoryModel: categoryList){
if(categoryModel.isDefault() || categoryModel.getId() == 20){
defaultCategory = categoryModel;
break;
}
}
return defaultCategory;
}
}

View File

@@ -0,0 +1,162 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.adapter.recycler.MyAddressesRecyclerAdapter;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.AddressModel;
import ch.pizzacucina.android.model.DeleteAddressResponseModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MyAddressesActivity extends BaseActivity {
@BindView(R.id.myAddressesRecyclerView) RecyclerView myAddressesRecyclerView;
@BindView(R.id.addNewAddressButton) Button addNewAddressButton;
@BindString(R.string.alert_delete_address) String deleteAddressAlertText;
@BindString(R.string.address_deleted) String addressDeletedText;
private ArrayList<AddressModel> addressList = new ArrayList<>();
private MyAddressesRecyclerAdapter addressesRecyclerAdapter;
private int REQUEST_CODE_ADD_NEW_ADDRESS = 8573;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_addresses);
ButterKnife.bind(this);
initViews();
getCustomerAddresses();
}
@OnClick(R.id.addNewAddressButton)
public void onClick(){
Intent addNewAddressIntent = new Intent(this, AddAddressActivity.class);
startActivityForResult(addNewAddressIntent, REQUEST_CODE_ADD_NEW_ADDRESS);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE_ADD_NEW_ADDRESS &&
resultCode == RESULT_OK){
getCustomerAddresses();
}
}
private void initViews(){
initRecyclerView();
}
private void getCustomerAddresses(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<AddressModel>> call = ApiService.apiInterface.getCustomerAddresses(
SessionHelper.getSelectedStore().getStoreName(),
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);
addressesRecyclerAdapter.notifyDataSetChanged();
}
private void initRecyclerView(){
addressesRecyclerAdapter = new MyAddressesRecyclerAdapter(addressList, new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, final int position) {
DialogHelper.showTwoButtonsDialog(BaseActivity.currentActivity, deleteAddressAlertText,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
deleteAddress(position);
}
},
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
});
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
myAddressesRecyclerView.setLayoutManager(layoutManager);
myAddressesRecyclerView.setAdapter(addressesRecyclerAdapter);
}
private void deleteAddress(final int position){
DialogHelper.hideLoadingDialog();
Call<ResponseObject<DeleteAddressResponseModel>> call = ApiService.apiInterface.deleteAddress(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_DELETE_ADDRESS + SessionHelper.getCustomerToken().getToken(),
addressList.get(position).getId());
call.enqueue(new Callback<ResponseObject<DeleteAddressResponseModel>>() {
@Override
public void onResponse(Call<ResponseObject<DeleteAddressResponseModel>> call, Response<ResponseObject<DeleteAddressResponseModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body() != null &&
response.body().isSuccess()){
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, addressDeletedText);
addressList.remove(position);
addressesRecyclerAdapter.notifyDataSetChanged();
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<DeleteAddressResponseModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
}

View File

@@ -0,0 +1,295 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.TextHelper;
import ch.pizzacucina.android.model.history.OrderHistoryModel;
import ch.pizzacucina.android.model.history.OrderHistoryProductModel;
import ch.pizzacucina.android.model.history.OrderHistoryProductOptionModel;
import ch.pizzacucina.android.view.AppInfoView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class OrderHistoryDetailsActivity extends BaseActivity {
@BindView(R.id.orderDatePizzalinkInfoLayout) AppInfoView orderDatePizzalinkInfoLayout;
//@BindView(R.id.orderStatusPizzalinkInfoLayout) PizzalinkInfoView orderStatusPizzalinkInfoLayout;
@BindView(R.id.orderShippingTimePizzalinkInfoLayout) AppInfoView orderShippingTimePizzalinkInfoLayout;
@BindView(R.id.orderTotalPizzalinkInfoLayout) AppInfoView orderTotalPizzalinkInfoLayout;
@BindView(R.id.orderPaymentMethodPizzalinkInfoLayout) AppInfoView orderPaymentMethodPizzalinkInfoLayout;
@BindView(R.id.orderProductsTextView) TextView orderProductsTextView;
@BindView(R.id.orderFullnamePizzalinkInfoLayout) AppInfoView orderFullnamePizzalinkInfoLayout;
@BindView(R.id.orderShippingMethodPizzalinkInfoLayout) AppInfoView orderShippingMethodPizzalinkInfoLayout;
@BindView(R.id.orderShippingAddressPizzalinkInfoLayout) AppInfoView orderShippingAddressPizzalinkInfoLayout;
@BindView(R.id.orderNotePizzalinkInfoLayout) AppInfoView orderNotePizzalinkInfoLayout;
private OrderHistoryModel orderHistoryModel;
private ArrayList<OrderHistoryProductModel> productList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_order_history_details);
ButterKnife.bind(this);
getDataFromIntent();
getOrderProductList();
initViews();
}
@OnClick(R.id.repeatOrderButton)
public void onClick(){
clearCart();
}
private void getDataFromIntent(){
orderHistoryModel = (OrderHistoryModel) getIntent().getSerializableExtra("orderHistoryModel");
}
private void initViews(){
orderDatePizzalinkInfoLayout.setText(orderHistoryModel.getFormattedCreateDate());
//orderStatusPizzalinkInfoLayout.setText(orderHistoryModel.getStatus());
if(orderHistoryModel.getShippingTime().isEmpty()){
orderShippingTimePizzalinkInfoLayout.setVisibility(View.GONE);
}
else {
orderShippingTimePizzalinkInfoLayout.setText(orderHistoryModel.getShippingTime());
}
orderTotalPizzalinkInfoLayout.setText(PriceHelper.roundFractions(orderHistoryModel.getTotalString()));
orderPaymentMethodPizzalinkInfoLayout.setText(orderHistoryModel.getPaymentMethod());
orderFullnamePizzalinkInfoLayout.setText(orderHistoryModel.getFirstname() + " " + orderHistoryModel.getLastname());
orderShippingMethodPizzalinkInfoLayout.setText(orderHistoryModel.getShippingMethod());
orderShippingAddressPizzalinkInfoLayout.setText(createAddress());
if(orderHistoryModel.getComment().isEmpty()){
orderNotePizzalinkInfoLayout.setVisibility(View.GONE);
}
else {
orderNotePizzalinkInfoLayout.setText(orderHistoryModel.getComment());
}
}
private String createAddress(){
StringBuilder stringBuilder = new StringBuilder();
stringBuilder
.append(orderHistoryModel.getFirstname())
.append(" ")
.append(orderHistoryModel.getLastname())
.append("\n");
if(!orderHistoryModel.getPaymentAddress1().isEmpty()){
stringBuilder
.append(orderHistoryModel.getShippingAddress1())
.append("\n");
}
if(!orderHistoryModel.getShippingAddress2().isEmpty()){
stringBuilder
.append(orderHistoryModel.getShippingAddress2())
.append("\n");
}
stringBuilder
.append(orderHistoryModel.getShippingPostcode())
.append(" ")
.append(orderHistoryModel.getShippingCity())
.append("\n")
.append(orderHistoryModel.getShippingCountry());
return stringBuilder.toString();
}
private void getOrderProductList(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<OrderHistoryProductModel>> call = ApiService.apiInterface.getOrderProductList(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_ORDER_PRODUCT_LIST + SessionHelper.getCustomerToken().getToken(), orderHistoryModel.getId());
call.enqueue(new Callback<ResponseArray<OrderHistoryProductModel>>() {
@Override
public void onResponse(Call<ResponseArray<OrderHistoryProductModel>> call, Response<ResponseArray<OrderHistoryProductModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess())
fillAndNotifyProductList(response.body().getData());
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseArray<OrderHistoryProductModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyProductList(ArrayList<OrderHistoryProductModel> prdctLst){
OrderHistoryProductModel.checkNull(prdctLst);
productList.clear();
productList.addAll(prdctLst);
TextHelper.setTextFromHTML(orderProductsTextView, getProductListInfoText());
}
private String getProductListInfoText(){
StringBuilder stringBuilder = new StringBuilder();
for(OrderHistoryProductModel orderHistoryProductModel : productList){
stringBuilder
.append("<b>")
.append(orderHistoryProductModel.getQuantity())
.append(" x ")
.append(orderHistoryProductModel.getName())
.append(" = ")
.append(PriceHelper.getPriceWithCurreny(orderHistoryProductModel.getTotal()))
.append("</b>")
.append("<br/>")
.append(getProductInfo(orderHistoryProductModel))
.append("<br/>");
}
if(stringBuilder.toString().trim().endsWith("<br/><br/>")){
int lastIndex = stringBuilder.toString().lastIndexOf("<br/><br/>");
return stringBuilder.toString().trim().substring(0, lastIndex);
}
return stringBuilder.toString().trim();
}
private String getProductInfo(OrderHistoryProductModel orderHistoryProductModel){
StringBuilder stringBuilder = new StringBuilder();
for(OrderHistoryProductOptionModel orderHistoryProductOptionModel : orderHistoryProductModel.getOptionList()){
if(!stringBuilder.toString().contains(orderHistoryProductOptionModel.getName())){
/*
if(!stringBuilder.toString().isEmpty()){
stringBuilder.append("<br/>");
}
*/
stringBuilder
.append("<br/>")
.append("<u>")
.append(orderHistoryProductOptionModel.getName())
.append("</u>")
.append("<br/>");
}
stringBuilder
.append("<i>")
.append(orderHistoryProductOptionModel.getValue())
.append("</i>")
.append("<br/>");
}
return stringBuilder.toString().trim();
}
private void clearCart(){
DialogHelper.showLoadingDialog();
Call<ResponseObject> call = ApiService.apiInterface.clearCart(
SessionHelper.getSelectedStore().getStoreName(),
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.setUserUsedKebappassCampaign(false);
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
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(
"/" + SessionHelper.getSelectedStore().getStoreName() + 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){
StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < cartProductModel.getOption().size(); i++){
if(!stringBuilder.toString().contains(cartProductModel.getOption().get(i).getName())){
if(!stringBuilder.toString().isEmpty()){
stringBuilder.append("<br/>");
}
stringBuilder
.append("<b>")
.append("<u>")
.append(cartProductModel.getOption().get(i).getName())
.append("</u>")
.append("</b>")
.append("<br/>")
.append("<br/>");
}
stringBuilder
.append(cartProductModel.getOption().get(i).getValue())
.append("<br/>");
}
return stringBuilder.toString().trim();
}
*/
}

View File

@@ -0,0 +1,462 @@
package ch.pizzacucina.android.activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.adapter.recycler.ProductCheckboxOptionsRecyclerAdapter;
import ch.pizzacucina.android.adapter.recycler.ProductRadioOptionsRecyclerAdapter;
import ch.pizzacucina.android.api.ApiConstants;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.ImageLoadHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.helper.TextHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.AddProductToBasketResponseModel;
import ch.pizzacucina.android.model.CampaignModel;
import ch.pizzacucina.android.model.cart.CartInfoModel;
import ch.pizzacucina.android.model.menu.MenuProductModel;
import ch.pizzacucina.android.model.menu.MenuProductOptionModel;
import ch.pizzacucina.android.model.menu.MenuProductOptionValueModel;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ProductDetailsActivity extends BaseActivity {
@BindView(R.id.closeImageView) ImageView closeImageView;
@BindView(R.id.backIcon) ImageView backIcon;
@BindView(R.id.productImageView) ImageView productImageView;
@BindView(R.id.productNameTextView) TextView productNameTextView;
@BindView(R.id.productPriceTextView) TextView productPriceTextView;
@BindView(R.id.productDescriptionTextView) TextView productDescriptionTextView;
@BindView(R.id.wunschpizzaAlertTextView) TextView wunschpizzaAlertTextView;
@BindView(R.id.addToCartButton) Button addToCartButton;
@BindView(R.id.recycler1HeaderTextView) TextView recycler1HeaderTextView;
@BindView(R.id.recyclerView1) RecyclerView recyclerView1;
@BindView(R.id.recycler2HeaderTextView) TextView recycler2HeaderTextView;
@BindView(R.id.recyclerView2) RecyclerView recyclerView2;
@BindView(R.id.increaseProductCountImageView) ImageView increaseProductCountImageView;
@BindView(R.id.deccreaseProductCountImageView) ImageView deccreaseProductCountImageView;
@BindView(R.id.productCountTextView) TextView productCountTextView;
@BindString(R.string.no_options_selected_part) String noOptionsSelectedText;
private int productCount = 1;
private MenuProductModel menuProductModel;
private CampaignModel campaignModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product_details);
ButterKnife.bind(this);
getDataFromIntent();
initViews();
}
@OnClick({R.id.closeImageView,
R.id.backIcon,
R.id.increaseProductCountImageView,
R.id.deccreaseProductCountImageView,
R.id.addToCartButton})
public void onCLick(View view){
switch (view.getId()){
case R.id.closeImageView:
case R.id.backIcon:
finish();
break;
case R.id.increaseProductCountImageView:
productCount++;
productCountTextView.setText(String.valueOf(productCount));
productPriceTextView.setText(
PriceHelper.calculatePriceAfterCountChanged(
productPriceTextView.getText().toString(), productCount - 1, productCount));
break;
case R.id.deccreaseProductCountImageView:
if(productCount == 1)
break;
productCount--;
productCountTextView.setText(String.valueOf(productCount));
productPriceTextView.setText(
PriceHelper.calculatePriceAfterCountChanged(
productPriceTextView.getText().toString(), productCount + 1, productCount));
break;
case R.id.addToCartButton:
if(checkFields()){
if(SessionHelper.isCustomerLoggedIn()){
addProductToCart();
}
else {
DialogHelper.showNeedToLoginDialog(R.string.need_to_login_for_shopping);
}
}
break;
}
}
@Override
public void onDestroy() {
super.onDestroy();
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
menuProductOptionValueModel.setSelected(false);
}
}
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
if(menuProductOptionValueModel.getPrice().equals("0") || menuProductOptionValueModel.getPrice().equals("0.00")){
/*
//checkbox
if(!(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
menuProductOptionModel.getType().toLowerCase().equals("select"))){
menuProductOptionValueModel.setSelected(true);
}
//radio
else if(!isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList())){
menuProductOptionValueModel.setSelected(true);
}
*/
boolean isRadio = menuProductOptionModel.getType().toLowerCase().equals("radio") || menuProductOptionModel.getType().toLowerCase().equals("select");
boolean isAnyOptionValueSelected = isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList());
if(isRadio && !isAnyOptionValueSelected){
menuProductOptionValueModel.setSelected(true);
}
}
}
}
}
private void getDataFromIntent(){
menuProductModel = (MenuProductModel) getIntent().getSerializableExtra("menuProductModel");
}
private void initViews(){
setFields();
initRecyclerViews();
}
public void setMenuProductModel(MenuProductModel menuProductModel){
this.menuProductModel = menuProductModel;
}
private void initRecyclerViews(){
fixRadioAndCheckbox();
for(int i = 0; i < menuProductModel.getProductOptionList().size(); i++){
MenuProductOptionModel menuProductOptionModel = menuProductModel.getProductOptionList().get(i);
setSelectedPriceShowingOptions(menuProductOptionModel);
switch (i){
case 0:
initRecyclerView(
recycler1HeaderTextView,
recyclerView1,
menuProductOptionModel);
break;
case 1:
initRecyclerView(
recycler2HeaderTextView,
recyclerView2,
menuProductOptionModel);
break;
}
}
}
private void initRecyclerView(TextView headerTextView,
RecyclerView recyclerView,
final MenuProductOptionModel menuProductOptionModel){
headerTextView.setText(menuProductOptionModel.getName());
recyclerView.setNestedScrollingEnabled(false);
GridLayoutManager gridLayoutManager = new GridLayoutManager(BaseActivity.currentActivity, 1);
recyclerView.setLayoutManager(gridLayoutManager);
if(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
menuProductOptionModel.getType().toLowerCase().equals("select")){
final ProductRadioOptionsRecyclerAdapter productRadioOptionsRecyclerAdapter =
new ProductRadioOptionsRecyclerAdapter(menuProductOptionModel.getOptionValueModelList());
productRadioOptionsRecyclerAdapter.setRecyclerItemClickListener(new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
ArrayList<MenuProductOptionValueModel> optionValueList = menuProductOptionModel.getOptionValueModelList();
if(!optionValueList.get(position).isSelected()){
for(MenuProductOptionValueModel menuProductOptionValueModel : optionValueList){
menuProductOptionValueModel.setSelected(false);
}
optionValueList.get(position).setSelected(true);
productRadioOptionsRecyclerAdapter.notifyDataSetChanged();
productPriceTextView.setText(PriceHelper.calculatePriceAfterRadioOptionValueChanged(
productCount, menuProductModel, optionValueList.get(position)));
}
}
});
recyclerView.setAdapter(productRadioOptionsRecyclerAdapter);
headerTextView.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.VISIBLE);
}
else{
final ProductCheckboxOptionsRecyclerAdapter productCheckboxOptionsRecyclerAdapter =
new ProductCheckboxOptionsRecyclerAdapter(menuProductOptionModel.getOptionValueModelList());
productCheckboxOptionsRecyclerAdapter.setRecyclerItemClickListener(new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
ArrayList<MenuProductOptionValueModel> optionValueList = menuProductOptionModel.getOptionValueModelList();
optionValueList.get(position).setSelected(
!optionValueList.get(position).isSelected());
productCheckboxOptionsRecyclerAdapter.notifyItemChanged(position);
productPriceTextView.setText(
PriceHelper.calculatePriceAfterCheckboxOptionValueChanged(
productCount, menuProductModel, optionValueList));
}
});
recyclerView.setAdapter(productCheckboxOptionsRecyclerAdapter);
headerTextView.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.VISIBLE);
}
}
private void setFields(){
TextHelper.setTextFromHTML(productDescriptionTextView, menuProductModel.getDescription());
ImageLoadHelper.loadImage(productImageView, menuProductModel.getImageURL());
productNameTextView.setText(menuProductModel.getName());
productPriceTextView.setText(PriceHelper.getPriceWithCurreny(menuProductModel.getPrice()));
productPriceTextView.setText(PriceHelper.getPriceWithCurreny(menuProductModel.getPrice()));
if(menuProductModel.getId().equals(String.valueOf(ApiConstants.PRODUCT_ID_WUNSCHPIZZA))){
wunschpizzaAlertTextView.setVisibility(View.VISIBLE);
}
else {
wunschpizzaAlertTextView.setVisibility(View.GONE);
}
}
private void fixRadioAndCheckbox(){
if(menuProductModel.getId().equals(String.valueOf(ApiConstants.PRODUCT_ID_ABEND_MENU)) ||
menuProductModel.getId().equals(String.valueOf(ApiConstants.PRODUCT_ID_MITTAGS_MENU))){
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
boolean isAbendMenuPizzaSelection =
menuProductOptionModel.getOptionId().equals(ApiConstants.OPTION_ID_ABEND_AND_MITTAGS_MENU_PIZZA_SELECTION) &&
menuProductOptionModel.getProductOptionId().equals(ApiConstants.PRODUCT_OPTION_ID_ABEND_MENU_PIZZA_SELECTION);
boolean isMittagsMenuPizzaSelection =
menuProductOptionModel.getOptionId().equals(ApiConstants.OPTION_ID_ABEND_AND_MITTAGS_MENU_PIZZA_SELECTION) &&
menuProductOptionModel.getProductOptionId().equals(ApiConstants.PRODUCT_OPTION_ID_MITTAGS_MENU_OPTIONS);
if(isAbendMenuPizzaSelection || isMittagsMenuPizzaSelection){
menuProductOptionModel.setType("radio");
}
}
}
ArrayList<MenuProductOptionModel> sortedOptionList = menuProductModel.getProductOptionList();
Collections.sort(
sortedOptionList,
new Comparator<MenuProductOptionModel>() {
@Override
public int compare(MenuProductOptionModel o1, MenuProductOptionModel o2) {
//return o2.getType().compareTo(o1.getType());
//return o1.getOptionValueModelList().size() - o2.getOptionValueModelList().size();
return o1.getOrder() - o2.getOrder();
}
});
menuProductModel.setProductOptionList(sortedOptionList);
}
private void setSelectedPriceShowingOptions(MenuProductOptionModel menuProductOptionModel){
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionModel.getOptionValueModelList()){
if(menuProductOptionValueModel.getPrice().equals("0") || menuProductOptionValueModel.getPrice().equals("0.00")){
/*
//checkbox
if(!(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
menuProductOptionModel.getType().toLowerCase().equals("select"))){
menuProductOptionValueModel.setSelected(true);
}
//radio
else if(!isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList())){
menuProductOptionValueModel.setSelected(true);
}
*/
boolean isRadio = menuProductOptionModel.getType().toLowerCase().equals("radio") || menuProductOptionModel.getType().toLowerCase().equals("select");
boolean isAnyOptionValueSelected = isAnyOptionValueSelected(menuProductOptionModel.getOptionValueModelList());
if(isRadio && !isAnyOptionValueSelected){
menuProductOptionValueModel.setSelected(true);
}
}
}
}
private void addProductToCart(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<AddProductToBasketResponseModel>> call =
ApiService.apiInterface.addProductsToBasket(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_ADD_PRODUCTS_TO_BASKET + SessionHelper.getCustomerToken().getToken(),
getAddToCartRequestParams());
call.enqueue(new Callback<ResponseObject<AddProductToBasketResponseModel>>() {
@Override
public void onResponse(Call<ResponseObject<AddProductToBasketResponseModel>> call, Response<ResponseObject<AddProductToBasketResponseModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() && response.body().getData() != null){
if(response.body().isSuccess()){
getCartItemCount(response.body().getData().getSuccessMessage());
}
else
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, response.body().getData().getErrorMessage());
}
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseObject<AddProductToBasketResponseModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private RequestBody getAddToCartRequestParams(){
FormBody.Builder formBodyBuilder = new FormBody.Builder();
formBodyBuilder.add("product_id", menuProductModel.getId());
formBodyBuilder.add("quantity", String.valueOf(productCount));
for(MenuProductOptionModel productOptionModel : menuProductModel.getProductOptionList()){
ArrayList<String> selectedCheckboxOptionList = new ArrayList<>();
for(MenuProductOptionValueModel productOptionValueModel : productOptionModel.getOptionValueModelList()){
if(productOptionValueModel.isSelected()){
if(productOptionModel.getType().toLowerCase().equals("checkbox")){
selectedCheckboxOptionList.add(productOptionValueModel.getProductOptionValueId());
}
else {
String key = "option[" + productOptionModel.getProductOptionId() + "]";
formBodyBuilder.add(key, productOptionValueModel.getProductOptionValueId());
}
}
}
if(productOptionModel.getType().toLowerCase().equals("checkbox")){
for(int i = 0; i < selectedCheckboxOptionList.size(); i++){
String key = "option[" + productOptionModel.getProductOptionId() + "][" + String.valueOf(i) + "]";
formBodyBuilder.add(key, selectedCheckboxOptionList.get(i));
}
}
}
return formBodyBuilder.build();
}
private void getCartItemCount(final String dialogMessage){
/*
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
*/
HashMap<String, Object> params = new HashMap<>();
if(SessionHelper.getSelectedCoupon() != null){
params.put("coupon", SessionHelper.getSelectedCoupon().getCode());
}
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
params);
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
@Override
public void onResponse(Call<ResponseObject<CartInfoModel>> call, Response<ResponseObject<CartInfoModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
SharedPrefsHelper.setCartItemCount(response.body().getData().getProducts().size());
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(response.body().getData().getCartTotalModel().getText()));
DialogHelper.showOneButtonDialogWithCallback(
dialogMessage,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
setResult(RESULT_OK);
finish();
}
},
false);
}
}
@Override
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
}
});
}
private boolean checkFields(){
for(int i = 0; i < menuProductModel.getProductOptionList().size(); i++){
MenuProductOptionModel menuProductOptionValueModel = menuProductModel.getProductOptionList().get(i);
boolean isRadio = menuProductOptionValueModel.getType().toLowerCase().equals("radio") || menuProductOptionValueModel.getType().toLowerCase().equals("select");
if(isRadio && !isSelectedAtLeastOne(menuProductModel.getProductOptionList().get(i).getOptionValueModelList())){
DialogHelper.showAlertDialog(BaseActivity.currentActivity,
menuProductModel.getProductOptionList().get(i).getName() + " " + noOptionsSelectedText);
return false;
}
}
return true;
}
private boolean isSelectedAtLeastOne(ArrayList<MenuProductOptionValueModel> menuProductOptionValueModels){
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionValueModels){
if(menuProductOptionValueModel.isSelected()){
return true;
}
}
return false;
}
private boolean isAnyOptionValueSelected(ArrayList<MenuProductOptionValueModel> menuProductOptionValueModels){
for (MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionValueModels){
if(menuProductOptionValueModel.isSelected()){
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,408 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.helper.ViewHelper;
import ch.pizzacucina.android.model.CityModel;
import ch.pizzacucina.android.model.CountryModel;
import ch.pizzacucina.android.model.CustomerTokenModel;
import ch.pizzacucina.android.model.UserModel;
import ch.pizzacucina.android.model.ZoneModel;
import ch.pizzacucina.android.view.AppDropdownView;
import ch.pizzacucina.android.view.AppEditText;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RegisterActivity extends BaseActivity {
@BindViews({ R.id.firstnamePizzalinkEditText, R.id.lasstnamePizzalinkEditText,
R.id.telephonePizzalinkEditText, R.id.emailPizzalinkEditText,
R.id.passwordPizzalinkEditText, R.id.passwordAgainPizzalinkEditText,
R.id.address1PizzalinkEditText, R.id.postcodePizzalinkEditText})
List<AppEditText> appEditTextList;
@BindView(R.id.cityPizzalinkDropdown)
AppDropdownView cityPizzalinkDropdown;
@BindView(R.id.countryPizzalinkDropdown)
AppDropdownView countryPizzalinkDropdown;
@BindView(R.id.zonePizzalinkDropdown)
AppDropdownView zonePizzalinkDropdown;
@BindView(R.id.registerButton) Button registerButton;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_invalid_email) String validEmailText;
@BindString(R.string.alert_invalid_post_code) String invalidPostcodeText;
@BindString(R.string.alert_passwords_not_matched) String passwordsNotMatchedText;
@BindString(R.string.alert_select_country_first) String selectCountryFirstText;
private ArrayList<CityModel> cityList = new ArrayList<>();
private ArrayList<CountryModel> countryList = new ArrayList<>();
private ArrayList<ZoneModel> zoneList = new ArrayList<>();
private CityModel selectedCityModel;
private CountryModel selectedCountryModel;
private ZoneModel selectedZoneModel;
private int activeRequestCount = 0;
private ReentrantLock lock = new ReentrantLock();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
ButterKnife.bind(this);
getCityList();
//getCountryList();
//setTestFields();
}
@OnClick({R.id.cityPizzalinkDropdown, R.id.countryPizzalinkDropdown,
R.id.zonePizzalinkDropdown, R.id.registerButton})
protected void onClick(View view){
switch (view.getId()){
case R.id.cityPizzalinkDropdown:
showCityDialog();
break;
case R.id.countryPizzalinkDropdown:
showCountryDialog();
break;
case R.id.zonePizzalinkDropdown:
if(selectedCountryModel != null){
getZoneList();
}
else {
DialogHelper.showAlertDialog(BaseActivity.currentActivity, selectCountryFirstText);
}
break;
case R.id.registerButton:
ViewHelper.hideKeyboard();
if(checkFields())
registerUser();
break;
}
}
private boolean checkFields(){
for(AppEditText appEditText : appEditTextList){
if(appEditText.isEmpty()){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
return false;
}
}
if(!appEditTextList.get(3).isEmail()){
DialogHelper.showAlertDialog(this, validEmailText);
return false;
}
if(!appEditTextList
.get(4)
.getText()
.toLowerCase()
.equals(
appEditTextList
.get(5)
.getText()
.toLowerCase())){
DialogHelper.showAlertDialog(this, passwordsNotMatchedText);
return false;
}
if(appEditTextList.get(7).getText().length() != 4){
DialogHelper.showAlertDialog(this, invalidPostcodeText);
return false;
}
/*
if(selectedCityModel == null ||
selectedCountryModel == null ||
selectedZoneModel == null){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
*/
if(selectedCityModel == null){
DialogHelper.showAlertDialog(this, fillAllFieldsText);
return false;
}
return true;
}
private void getCityList(){
if(activeRequestCount == 0)
DialogHelper.showLoadingDialog();
Call<ResponseArray<CityModel>> call = ApiService.apiInterface.getCityList(SessionHelper.getSelectedStore().getStoreName());
call.enqueue(new Callback<ResponseArray<CityModel>>() {
@Override
public void onResponse(Call<ResponseArray<CityModel>> call, Response<ResponseArray<CityModel>> response) {
decreaseActiveRequestCount();
if(activeRequestCount == 0)
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyCityList(response.body().getData());
}
else if(activeRequestCount == 0){
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<CityModel>> call, Throwable t) {
decreaseActiveRequestCount();
if(activeRequestCount == 0){
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
}
});
increaseActiveRequestCount();
}
private void getCountryList(){
if(activeRequestCount == 0)
DialogHelper.showLoadingDialog();
increaseActiveRequestCount();
Call<ResponseArray<CountryModel>> call = ApiService.apiInterface.getCountryList(SessionHelper.getSelectedStore().getStoreName());
call.enqueue(new Callback<ResponseArray<CountryModel>>() {
@Override
public void onResponse(Call<ResponseArray<CountryModel>> call, Response<ResponseArray<CountryModel>> response) {
decreaseActiveRequestCount();
if(activeRequestCount == 0)
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyCountryList(response.body().getData());
}
else if(activeRequestCount == 0){
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<CountryModel>> call, Throwable t) {
decreaseActiveRequestCount();
if(activeRequestCount == 0){
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
}
});
}
private void getZoneList(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<ZoneModel>> call = ApiService.apiInterface.getZoneList(
SessionHelper.getSelectedStore().getStoreName(),
selectedCountryModel.getId());
call.enqueue(new Callback<ResponseArray<ZoneModel>>() {
@Override
public void onResponse(Call<ResponseArray<ZoneModel>> call, Response<ResponseArray<ZoneModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndShowZoneList(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<ZoneModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyCityList(ArrayList<CityModel> cities){
CityModel.checkNull(cities);
cityList.clear();
cityList.addAll(cities);
}
private void fillAndNotifyCountryList(ArrayList<CountryModel> countries){
CountryModel.checkNull(countries);
countryList.clear();
countryList.addAll(countries);
}
private void fillAndShowZoneList(ArrayList<ZoneModel> zones){
ZoneModel.checkNull(zones);
zoneList.clear();
zoneList.addAll(zones);
showZoneDialog();
}
private void registerUser(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<UserModel>> call = ApiService.apiInterface.register(
SessionHelper.getSelectedStore().getStoreName(),
getRegisterParams());
call.enqueue(new Callback<ResponseObject<UserModel>>() {
@Override
public void onResponse(Call<ResponseObject<UserModel>> call, Response<ResponseObject<UserModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
response.body().getData().checkNull();
SharedPrefsHelper.saveUser(response.body().getData());
CustomerTokenModel customerTokenModel = response.body().getData().getToken();
customerTokenModel.setStoreOfToken(SessionHelper.getSelectedStore());
SharedPrefsHelper.saveCustomerToken(customerTokenModel);
SharedPrefsHelper.setCustomerLoggedIn(true);
startActivity(new Intent(RegisterActivity.this, MainActivity.class));
finishAffinity();
}
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseObject<UserModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private HashMap<String, Object> getRegisterParams(){
HashMap<String, Object> params = new HashMap<>();
params.put("firstname", appEditTextList.get(0).getText());
params.put("lastname", appEditTextList.get(1).getText());
params.put("telephone", appEditTextList.get(2).getText());
params.put("email", appEditTextList.get(3).getText());
params.put("password", appEditTextList.get(4).getText());
params.put("password1", appEditTextList.get(5).getText());
params.put("address_1", appEditTextList.get(6).getText());
params.put("address_2", "");
params.put("city", selectedCityModel.getCity());
params.put("postcode", appEditTextList.get(7).getText());
//params.put("country_id", selectedCountryModel.getId());
//params.put("zone_id", selectedZoneModel.getZoneId());
params.put("country_id", "1");
params.put("zone_id", "1");
return params;
}
private void showCityDialog(){
final ArrayList<String> zoneNameList = new ArrayList<>();
for(CityModel zone : cityList){
zoneNameList.add(zone.getCity());
}
DialogHelper.showListDialog(zoneNameList, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
selectedCityModel = cityList.get(position);
cityPizzalinkDropdown.setText(selectedCityModel.getCity());
}
});
}
private void showCountryDialog(){
final ArrayList<String> countryNameList = new ArrayList<>();
for(CountryModel country : countryList){
countryNameList.add(country.getName());
}
DialogHelper.showListDialog(countryNameList, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
selectedCountryModel = countryList.get(position);
countryPizzalinkDropdown.setText(selectedCountryModel.getName());
}
});
}
private void showZoneDialog(){
final ArrayList<String> zoneNameList = new ArrayList<>();
for(ZoneModel zone : zoneList){
zoneNameList.add(zone.getName());
}
DialogHelper.showListDialog(zoneNameList, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
selectedZoneModel = zoneList.get(position);
zonePizzalinkDropdown.setText(selectedZoneModel.getName());
}
});
}
private void setTestFields(){
appEditTextList.get(0).getEditText().setText("testname");
appEditTextList.get(1).getEditText().setText("testsurname");
appEditTextList.get(2).getEditText().setText("1234567892");
appEditTextList.get(3).getEditText().setText("test5@test.com");
appEditTextList.get(4).getEditText().setText("test");
appEditTextList.get(5).getEditText().setText("test");
appEditTextList.get(6).getEditText().setText("test address 1");
appEditTextList.get(7).getEditText().setText("test postcode");
}
private synchronized void increaseActiveRequestCount(){
lock.lock();
try {
activeRequestCount++;
}finally {
lock.unlock();
}
}
private synchronized void decreaseActiveRequestCount(){
lock.lock();
try {
activeRequestCount--;
}finally {
lock.unlock();
}
}
}

View File

@@ -0,0 +1,439 @@
package ch.pizzacucina.android.activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;
import com.afollestad.materialdialogs.MaterialDialog;
import com.onesignal.OneSignal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.adapter.pager.CampaignBannerPagerAdapter;
import ch.pizzacucina.android.api.ApiConstants;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.NetworkHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.model.AppVersionModel;
import ch.pizzacucina.android.model.CampaignBannerModel;
import ch.pizzacucina.android.model.CategoryModel;
import ch.pizzacucina.android.model.StoreModel;
import ch.pizzacucina.android.model.cart.CartInfoModel;
import me.relex.circleindicator.CircleIndicator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class SplashActivity extends BaseActivity {
@BindView(R.id.postCodeTextView) TextView postCodeTextView;
@BindView(R.id.campaignsViewPager) ViewPager campaignsViewPager;
@BindView(R.id.viewPagerIndicator) CircleIndicator viewPagerIndicator;
@BindString(R.string.alert_invalid_post_code) String choosePostCodeAlert;
private ArrayList<StoreModel> storeList = new ArrayList<>();
private ArrayList<CampaignBannerModel> campaignBannerList = new ArrayList<>();
private StoreModel selectedStoreModel;
private CampaignBannerPagerAdapter campaignBannerPagerAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ButterKnife.bind(this);
//DisplayHelper.changeStatusColor();
if(NetworkHelper.isNetworkAvailable()){
registerNotificationTag();
getStoreList();
}
else{
DialogHelper.showNoNetworkDialog();
}
}
private void initCampaignViewPager(){
campaignBannerPagerAdapter = new CampaignBannerPagerAdapter(getSupportFragmentManager(), campaignBannerList);
campaignsViewPager.setAdapter(campaignBannerPagerAdapter);
viewPagerIndicator.setViewPager(campaignsViewPager);
viewPagerIndicator.setVisibility(View.VISIBLE);
}
@OnClick({R.id.choosePostCodeLayout, R.id.choosePostCodeButton})
protected void onClick(View view){
switch (view.getId()){
case R.id.choosePostCodeLayout:
showStoreListDialog();
break;
case R.id.choosePostCodeButton:
if(selectedStoreModel == null){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, choosePostCodeAlert);
}
else {
checkVersion();
}
break;
}
}
private void registerNotificationTag(){
if(SessionHelper.isFirstTime()) {
OneSignal.sendTag(
ApiConstants.ONESIGNAL_NOTIFICATION_TAG_KEY,
ApiConstants.ONESIGNAL_NOTIFICATION_TAG_VALUE);
SessionHelper.setIsFirstTime(false);
}
}
private void getStoreList(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<StoreModel>> call = ApiService.apiInterface.getStoreList();
call.enqueue(new Callback<ResponseArray<StoreModel>>() {
@Override
public void onResponse(Call<ResponseArray<StoreModel>> call, Response<ResponseArray<StoreModel>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess() && !response.body().getData().isEmpty()){
storeList.addAll(response.body().getData());
getCampaignBanners();
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<StoreModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void getCampaignBanners(){
Call<ResponseArray<CampaignBannerModel>> call = ApiService.apiInterface.getCampaignBanners();
call.enqueue(new Callback<ResponseArray<CampaignBannerModel>>() {
@Override
public void onResponse(Call<ResponseArray<CampaignBannerModel>> call, Response<ResponseArray<CampaignBannerModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess() && !response.body().getData().isEmpty()){
campaignBannerList.clear();
campaignBannerList.addAll(response.body().getData());
sortCampaignBannerList();
initCampaignViewPager();
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<CampaignBannerModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void showStoreListDialog(){
Collections.sort(storeList, new Comparator<StoreModel>() {
@Override
public int compare(StoreModel s1, StoreModel s2) {
return s1.getPostCode().compareTo(s2.getPostCode());
}
});
final ArrayList<String> postCodeList = new ArrayList<>();
for(StoreModel storeModel : storeList){
storeModel.checkNull();
postCodeList.add(storeModel.getPostCode() + "-" + storeModel.getCity());
}
DialogHelper.showStoreListDialog(postCodeList, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
selectedStoreModel = storeList.get(position);
postCodeTextView.setText(selectedStoreModel.getPostCode() + "-" + selectedStoreModel.getCity());
SessionHelper.setSelectedStore(selectedStoreModel);
ApiService.getInstance().reset();
}
});
}
private void checkVersion(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<AppVersionModel>> call = ApiService.apiInterface.checkUpdate(
SessionHelper.getSelectedStore().getStoreName(),
getCheckUpdateParams());
call.enqueue(new Callback<ResponseObject<AppVersionModel>>() {
@Override
public void onResponse(Call<ResponseObject<AppVersionModel>> call, Response<ResponseObject<AppVersionModel>> response) {
if(response.isSuccessful()){
if(response.body().isSuccess()){
getCategoryList();
}
else{
DialogHelper.hideLoadingDialog();
DialogHelper.showUpdateAppDialog(SplashActivity.this);
}
}
else{
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<AppVersionModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private HashMap<String, Object> getCheckUpdateParams(){
HashMap<String, Object> params = new HashMap<>();
params.put("application", ApiConstants.APP_TYPE_ID_ANDROID);
params.put("version", getAppVersionCode());
return params;
}
private int getAppVersionCode(){
PackageInfo pInfo = null;
try {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return 0;
}
return pInfo.versionCode;
}
private void getCategoryList(){
Call<ResponseArray<CategoryModel>> call = ApiService.apiInterface.getAllCategories(SessionHelper.getSelectedStore().getStoreName());
call.enqueue(new Callback<ResponseArray<CategoryModel>>() {
@Override
public void onResponse(Call<ResponseArray<CategoryModel>> call, Response<ResponseArray<CategoryModel>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
CategoryModel.checkNull(response.body().getData());
SharedPrefsHelper.saveCategoryList(response.body().getData());
getPizzaCategoryIds();
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<CategoryModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void getPizzaCategoryIds(){
Call<ResponseArray<Integer>> call = ApiService.apiInterface.getPizzaCategoryIds(SessionHelper.getSelectedStore().getStoreName());
call.enqueue(new Callback<ResponseArray<Integer>>() {
@Override
public void onResponse(Call<ResponseArray<Integer>> call, Response<ResponseArray<Integer>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
SharedPrefsHelper.savePizzaCategoryIdList(response.body().getData());
getIgnoredCategoryIds();
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<Integer>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void getIgnoredCategoryIds(){
Call<ResponseArray<Integer>> call = ApiService.apiInterface.getIgnoredCategoryIds(SessionHelper.getSelectedStore().getStoreName());
call.enqueue(new Callback<ResponseArray<Integer>>() {
@Override
public void onResponse(Call<ResponseArray<Integer>> call, Response<ResponseArray<Integer>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
SharedPrefsHelper.saveIgnoredCategoryIdList(response.body().getData());
checkCustomerToken();
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<Integer>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
/*
private void checkCustomerToken(){
if(SessionHelper.isCustomerLoggedIn()){
if(SessionHelper.getCustomerToken().isCustomerTokenAlive())
getCartItemCount();
else
refreshCustomerToken();
}
else
openActivity(LoginActivity.class);
}
*/
private void checkCustomerToken(){
if(SessionHelper.isCustomerLoggedIn()){
getCartItemCount();
}
else{
openActivity(LoginActivity.class);
}
}
private void openActivity(final Class<?> cls){
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(SplashActivity.this, cls));
DialogHelper.hideLoadingDialog();
finish();
}
}, 1000);
}
private void refreshCustomerToken(){
/*
Call<RefreshTokenResponseModel> call = ApiService.apiInterface.refreshCustomerToken(SessionManager.getCustomerToken().getRefreshToken());
call.enqueue(new Callback<RefreshTokenResponseModel>() {
@Override
public void onResponse(Call<RefreshTokenResponseModel> call, Response<RefreshTokenResponseModel> response) {
ApiService.getInstance().reset();
if(response.isSuccessful() && response.body().isSuccess()) {
SessionManager.saveCustomerToken(response.body().getCustomerToken(), Constants.PUSULA_CARD_MEMBER_TYPE_CUSTOMER);
getCartItemCount();
}
else{
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, "Bir hata oluştu. Lütfen daha sonra tekrar deneyin.");
}
}
@Override
public void onFailure(Call<RefreshTokenResponseModel> call, Throwable t) {
DialogHelper.hideLoadingDialog();
ApiService.getInstance().reset();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, "Bir hata oluştu. Lütfen daha sonra tekrar deneyin.");
}
});
*/
}
private void getCartItemCount(){
/*
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
*/
HashMap<String, Object> params = new HashMap<>();
if(SessionHelper.getSelectedCoupon() != null){
params.put("coupon", SessionHelper.getSelectedCoupon().getCode());
}
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
params);
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
@Override
public void onResponse(Call<ResponseObject<CartInfoModel>> call, Response<ResponseObject<CartInfoModel>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
SharedPrefsHelper.setCartItemCount(response.body().getData().getProducts().size());
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(response.body().getData().getCartTotalModel().getText()));
openActivity(MainActivity.class);
}
else {
DialogHelper.hideLoadingDialog();
//response.body().getErrorCode()
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void sortCampaignBannerList(){
ArrayList<CampaignBannerModel> tempList = new ArrayList<>();
for(CampaignBannerModel campaignBannerModel : campaignBannerList){
if(campaignBannerModel.isActive()){
tempList.add(campaignBannerModel);
}
}
campaignBannerList.clear();
campaignBannerList.addAll(tempList);
tempList.clear();
Collections.sort(campaignBannerList, new Comparator<CampaignBannerModel>() {
@Override
public int compare(CampaignBannerModel b1, CampaignBannerModel b2) {
return b1.getOrder().compareTo(b2.getOrder());
}
});
}
}

View File

@@ -0,0 +1,104 @@
package ch.pizzacucina.android.activity;
import android.os.Bundle;
import android.widget.Button;
import java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.ViewHelper;
import ch.pizzacucina.android.view.AppEditText;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class UpdatePasswordActivity extends BaseActivity {
@BindView(R.id.oldPasswordPizzalinkEditText)
AppEditText oldPasswordAppEditText;
@BindView(R.id.newPasswordPizzalinkEditText)
AppEditText newPasswordAppEditText;
@BindView(R.id.confirmNewPasswordPizzalinkEditText)
AppEditText confirmNewPasswordAppEditText;
@BindView(R.id.updatePasswordButton) Button updatePasswordButton;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_passwords_not_matched) String passwordsNotMatchedText;
@BindString(R.string.password_updated) String passwordUpdatedText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update_password);
ButterKnife.bind(this);
}
@OnClick(R.id.updatePasswordButton)
protected void onClick(){
ViewHelper.hideKeyboard();
if(checkFields())
updatePassword();
}
private boolean checkFields(){
if(oldPasswordAppEditText.isEmpty() ||
newPasswordAppEditText.isEmail() ||
confirmNewPasswordAppEditText.isEmpty()){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, fillAllFieldsText);
return false;
}
if(!newPasswordAppEditText.getText().equals(confirmNewPasswordAppEditText.getText())){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, passwordsNotMatchedText);
return false;
}
return true;
}
private void updatePassword(){
DialogHelper.showLoadingDialog();
Call<ResponseObject> call = ApiService.apiInterface.updatePassword(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_UPDATE_PASSWORD + SessionHelper.getCustomerToken().getToken(),
getUpdatePasswordRequestParams());
call.enqueue(new Callback<ResponseObject>() {
@Override
public void onResponse(Call<ResponseObject> call, Response<ResponseObject> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, passwordUpdatedText);
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private HashMap<String, Object> getUpdatePasswordRequestParams(){
HashMap<String, Object> params = new HashMap<>();
params.put("oldPassword", oldPasswordAppEditText.getText());
params.put("password", newPasswordAppEditText.getText());
params.put("confirm", confirmNewPasswordAppEditText.getText());
return params;
}
}

View File

@@ -0,0 +1,134 @@
package ch.pizzacucina.android.activity;
import android.support.annotation.NonNull;
import android.os.Bundle;
import android.widget.Button;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.model.UserModel;
import ch.pizzacucina.android.view.AppEditText;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class UpdateProfileActivity extends BaseActivity {
@BindView(R.id.firstnamePizzalinkEditText)
AppEditText firstnameAppEditText;
@BindView(R.id.lasstnamePizzalinkEditText)
AppEditText lasstnameAppEditText;
@BindView(R.id.telephonePizzalinkEditText)
AppEditText telephoneAppEditText;
@BindView(R.id.emailPizzalinkEditText)
AppEditText emailAppEditText;
@BindView(R.id.updateProfileButton) Button updateProfileButton;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_invalid_email) String validEmailText;
@BindString(R.string.profile_updated) String profileUpdatedText;
private UserModel userModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update_profile);
ButterKnife.bind(this);
getDataFromIntent();
setFields();
}
@OnClick(R.id.updateProfileButton)
public void onClick(){
if(checkFields())
updateProfile();
}
private void getDataFromIntent(){
userModel = (UserModel) getIntent().getSerializableExtra("userModel");
}
private void setFields(){
firstnameAppEditText.setText(userModel.getFirstname());
lasstnameAppEditText.setText(userModel.getLastname());
telephoneAppEditText.setText(userModel.getTelephone());
emailAppEditText.setText(userModel.getEmail());
}
private void updateProfile(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<UserModel>> call = ApiService.apiInterface.updateProfile(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_UPDATE_PROFILE + SessionHelper.getCustomerToken().getToken(),
getUpdateProfileParams());
call.enqueue(new Callback<ResponseObject<UserModel>>() {
@Override
public void onResponse(Call<ResponseObject<UserModel>> call, final Response<ResponseObject<UserModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
SessionHelper.saveCustomer(response.body().getData());
DialogHelper.showOneButtonDialogWithCallback(profileUpdatedText, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
setResult(RESULT_OK);
finish();
}
});
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<UserModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private HashMap<String, Object> getUpdateProfileParams(){
HashMap<String, Object> params = new HashMap<>();
params.put("firstname", firstnameAppEditText.getText());
params.put("lastname", lasstnameAppEditText.getText());
params.put("email", emailAppEditText.getText());
params.put("telephone", telephoneAppEditText.getText());
return params;
}
private boolean checkFields(){
if(firstnameAppEditText.isEmpty() ||
lasstnameAppEditText.isEmpty() ||
telephoneAppEditText.isEmpty() ||
emailAppEditText.isEmpty()){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, fillAllFieldsText);
return false;
}
if(!emailAppEditText.isEmail()){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, validEmailText);
return false;
}
return true;
}
}

View File

@@ -0,0 +1,31 @@
package ch.pizzacucina.android.adapter.pager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import java.util.ArrayList;
import ch.pizzacucina.android.fragment.CampaignBannerFragment;
import ch.pizzacucina.android.model.CampaignBannerModel;
public class CampaignBannerPagerAdapter extends FragmentPagerAdapter {
private ArrayList<CampaignBannerModel> campaignBannerList = new ArrayList<>();
public CampaignBannerPagerAdapter(FragmentManager fm,
ArrayList<CampaignBannerModel> campaignBannerList) {
super(fm);
this.campaignBannerList = campaignBannerList;
}
@Override
public Fragment getItem(int position) {
return CampaignBannerFragment.newInstance(campaignBannerList.get(position));
}
@Override
public int getCount() {
return campaignBannerList.size();
}
}

View File

@@ -0,0 +1,52 @@
package ch.pizzacucina.android.adapter.pager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import ch.pizzacucina.android.fragment.createOrder.CreateOrderResultFragment;
import ch.pizzacucina.android.fragment.createOrder.CreateOrderSummaryFragment;
import ch.pizzacucina.android.fragment.createOrder.PaymentMethodFragment;
import ch.pizzacucina.android.fragment.createOrder.ShippingAddressFragment;
import ch.pizzacucina.android.fragment.createOrder.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 CreateOrderSummaryFragment.newInstance();
case 4:
return CreateOrderResultFragment.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,192 @@
package ch.pizzacucina.android.adapter.recycler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.TextHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.cart.CartProductModel;
/**
* Created by cimenmus on 05/10/2017.
*/
public class CartRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_CART_PRODUCT = 0;
private final int HOLDER_SPACE = 1;
private ArrayList<CartProductModel> cartProductList = new ArrayList<>();
private RecyclerItemClickListener recyclerItemClickListener;
public static class CartProductViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.cartProductCountTextView) TextView cartProductCountTextView;
@BindView(R.id.cartProductCategoryNameTextView) TextView cartProductCategoryNameTextView;
@BindView(R.id.cartProductNameTextView) TextView cartProductNameTextView;
@BindView(R.id.cartProductTotalPriceTextView) TextView cartProductTotalPriceTextView;
@BindView(R.id.removeProductFromCartImageView) ImageView removeProductFromCartImageView;
@BindView(R.id.cartProductInfoTextView) TextView cartProductInfoTextView;
public CartProductViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
removeProductFromCartImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(removeProductFromCartImageView, getAdapterPosition());
}
});
}
}
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
public SpaceViewHolder(final View view) {
super(view);
}
}
@Override
public int getItemViewType(int position) {
if(position == cartProductList.size())
return HOLDER_SPACE;
return HOLDER_CART_PRODUCT;
}
public CartRecyclerAdapter(ArrayList<CartProductModel> cartProductList,
RecyclerItemClickListener recyclerItemClickListener){
this.cartProductList = cartProductList;
this.recyclerItemClickListener = recyclerItemClickListener;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
RecyclerView.ViewHolder viewHolder;
View view;
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
switch (viewType){
case HOLDER_CART_PRODUCT:
view = inflater.inflate(R.layout.row_cart, viewGroup, false);
viewHolder = new CartProductViewHolder(view, recyclerItemClickListener);
break;
case HOLDER_SPACE:
view = inflater.inflate(R.layout.row_space, viewGroup, false);
viewHolder = new SpaceViewHolder(view);
break;
default:
view = inflater.inflate(R.layout.row_cart, viewGroup, false);
viewHolder = new CartProductViewHolder(view, recyclerItemClickListener);
break;
}
return viewHolder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
switch (holder.getItemViewType()){
case HOLDER_CART_PRODUCT :
CartProductViewHolder cartProductViewHolder = (CartProductViewHolder) holder;
cartProductViewHolder.cartProductCountTextView.setText(cartProductList.get(position).getQuantity() + " x ");
cartProductViewHolder.cartProductCategoryNameTextView.setText(cartProductList.get(position).getModel());
cartProductViewHolder.cartProductNameTextView.setText(cartProductList.get(position).getName());
cartProductViewHolder.cartProductTotalPriceTextView.setText(PriceHelper.roundFractions(cartProductList.get(position).getTotal()));
setCartInfoText(cartProductViewHolder.cartProductInfoTextView, cartProductList.get(position));
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return cartProductList.size() + 1 ;
}
private void setCartInfoText(TextView textView, CartProductModel cartProductModel){
if(cartProductModel.getOption() == null || cartProductModel.getOption().size() == 0){
textView.setVisibility(View.GONE);
return;
}
textView.setVisibility(View.VISIBLE);
TextHelper.setTextFromHTML(textView, getCartInfoText(cartProductModel));
}
private String getCartInfoText(CartProductModel cartProductModel){
StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < cartProductModel.getOption().size(); i++){
if(!stringBuilder.toString().contains(cartProductModel.getOption().get(i).getName())){
if(!stringBuilder.toString().isEmpty()){
stringBuilder.append("<br/>");
}
stringBuilder
.append("<b>")
.append("<u>")
.append(cartProductModel.getOption().get(i).getName())
.append("</u>")
.append("</b>")
.append("<br/>")
.append("<br/>");
}
stringBuilder
.append(cartProductModel.getOption().get(i).getValue())
.append("<br/>");
}
return stringBuilder.toString().trim();
}
/*
private String getCartInfoText(CartProductModel cartProductModel){
StringBuilder stringBuilder = new StringBuilder();
for(CartProductOptionModel cartProductOptionModel : cartProductModel.getOption()){
if(!cartProductOptionModel.getType().toLowerCase().equals("checkbox")){
stringBuilder.append(cartProductOptionModel.getValue())
.append("\n");
}
}
// stringBuilder.append("\n");
for(CartProductOptionModel cartProductOptionModel : cartProductModel.getOption()){
if(cartProductOptionModel.getType().toLowerCase().equals("checkbox")){
stringBuilder.append(cartProductOptionModel.getValue())
.append("\n");
}
}
return stringBuilder.toString().trim();
}
*/
}

View File

@@ -0,0 +1,141 @@
package ch.pizzacucina.android.adapter.recycler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.helper.ImageLoadHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.TextHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.menu.MenuProductModel;
/**
* Created by cimenmus on 20/09/2017.
*/
public class MenuProductRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_MENU_PRODUCT = 0;
private final int HOLDER_SPACE = 1;
private ArrayList<MenuProductModel> menuProductList = new ArrayList<>();
private RecyclerItemClickListener recyclerItemClickListener;
private boolean isDescriptionVisible;
public static class MenuProductViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.productNameTextView) TextView productNameTextView;
@BindView(R.id.productImageView) ImageView productImageView;
@BindView(R.id.productIngredientsLayout) RelativeLayout productIngredientsLayout;
@BindView(R.id.productIngredientsTextView) TextView productIngredientsTextView;
@BindView(R.id.productPriceTextView) TextView productPriceTextView;
public MenuProductViewHolder(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 == menuProductList.size())
return HOLDER_SPACE;
return HOLDER_MENU_PRODUCT;
}
public MenuProductRecyclerAdapter(ArrayList<MenuProductModel> menuProductList,
boolean isDescriptionVisible,
RecyclerItemClickListener recyclerItemClickListener){
this.menuProductList = menuProductList;
this.recyclerItemClickListener = recyclerItemClickListener;
this.isDescriptionVisible = isDescriptionVisible;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
RecyclerView.ViewHolder viewHolder;
View view;
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
switch (viewType){
case HOLDER_MENU_PRODUCT:
view = inflater.inflate(R.layout.row_menu_product, viewGroup, false);
viewHolder = new MenuProductViewHolder(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_menu_product, viewGroup, false);
viewHolder = new MenuProductViewHolder(view, recyclerItemClickListener);
break;
}
return viewHolder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
switch (holder.getItemViewType()){
case HOLDER_MENU_PRODUCT :
MenuProductViewHolder menuProductViewHolder = (MenuProductViewHolder) holder;
ImageLoadHelper.loadImage(menuProductViewHolder.productImageView, menuProductList.get(position).getImageURL());
TextHelper.setTextFromHTML(menuProductViewHolder.productNameTextView, menuProductList.get(position).getName());
menuProductViewHolder.productPriceTextView.setText(
PriceHelper.getPriceWithCurreny(menuProductList.get(position).getPrice()));
TextHelper.setTextFromHTML(menuProductViewHolder.productIngredientsTextView, menuProductList.get(position).getDescription());
if(isDescriptionVisible){
menuProductViewHolder.productIngredientsLayout.setVisibility(View.VISIBLE);
TextHelper.setTextFromHTML(menuProductViewHolder.productIngredientsTextView, menuProductList.get(position).getDescription());
}
else {
menuProductViewHolder.productIngredientsLayout.setVisibility(View.GONE);
}
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return menuProductList.size() + 1 ;
}
}

View File

@@ -0,0 +1,116 @@
package ch.pizzacucina.android.adapter.recycler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.AddressModel;
/**
* Created by cimenmus on 24.10.2017.
*/
public class MyAddressesRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_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.addressTextView) TextView addressTextView;
@BindView(R.id.deleteAddressImageView) ImageView deleteAddressImageView;
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
deleteAddressImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(deleteAddressImageView, 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_ADDRESS;
}
public MyAddressesRecyclerAdapter(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_ADDRESS:
view = inflater.inflate(R.layout.row_my_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_my_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_ADDRESS :
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
orderViewHolder.addressTextView.setText(addressList.get(position).getAddress());
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return addressList.size() + 1 ;
}
}

View File

@@ -0,0 +1,164 @@
package ch.pizzacucina.android.adapter.recycler;
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.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.CategoryModel;
/**
* Created by cimenmus on 02/10/2017.
*/
public class NavigationMenuRecyclerAdapter extends RecyclerView.Adapter<NavigationMenuRecyclerAdapter.ViewHolder> {
private ArrayList<CategoryModel> categoryList;
private RecyclerItemClickListener recyclerItemClickListener;
public static class ViewHolder extends RecyclerView.ViewHolder{
@BindView(R.id.categoryNameItem) TextView categoryNameItem;
public ViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
}
});
}
}
public NavigationMenuRecyclerAdapter(ArrayList<CategoryModel> categoryList, RecyclerItemClickListener recyclerItemClickListener){
this.categoryList = categoryList;
this.recyclerItemClickListener = recyclerItemClickListener;
}
@Override
public NavigationMenuRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View root = LayoutInflater.from(BaseActivity.currentActivity).inflate(R.layout.row_category, viewGroup, false);
return new NavigationMenuRecyclerAdapter.ViewHolder(root, recyclerItemClickListener);
}
@Override
public void onBindViewHolder(NavigationMenuRecyclerAdapter.ViewHolder holder, int position) {
holder.categoryNameItem.setText(categoryList.get(position).getName());
}
@Override
public int getItemCount() {
return categoryList.size();
}
}
/*
public class NavigationMenuRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_CATEGORY = 0;
private final int HOLDER_SPACE = 1;
private ArrayList<CategoryModel> categoryList;
private RecyclerItemClickListener recyclerItemClickListener;
public static class CategoryViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.categoryNameItem) TextView categoryNameItem;
public CategoryViewHolder(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 == categoryList.size())
return HOLDER_SPACE;
return HOLDER_CATEGORY;
}
public NavigationMenuRecyclerAdapter(ArrayList<CategoryModel> categoryList,
RecyclerItemClickListener recyclerItemClickListener){
this.categoryList = categoryList;
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_CATEGORY:
view = inflater.inflate(R.layout.row_category, viewGroup, false);
viewHolder = new CategoryViewHolder(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_category, viewGroup, false);
viewHolder = new CategoryViewHolder(view, recyclerItemClickListener);
break;
}
return viewHolder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
switch (holder.getItemViewType()){
case HOLDER_CATEGORY :
CategoryViewHolder categoryViewHolder = (CategoryViewHolder) holder;
categoryViewHolder.categoryNameItem.setText(categoryList.get(position).getName());
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return categoryList.size() + 1 ;
}
}
*/

View File

@@ -0,0 +1,140 @@
package ch.pizzacucina.android.adapter.recycler;
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.pizzacucina.android.R;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.history.OrderHistoryModel;
/**
* Created by cimenmus on 04/10/2017.
*/
public class OrderHistoryRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_ORDER = 0;
private final int HOLDER_SPACE = 1;
private ArrayList<OrderHistoryModel> orderHistoryList = new ArrayList<>();
private RecyclerItemClickListener recyclerItemClickListener;
public static class OrderViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.orderDateTextView) TextView orderDateTextView;
@BindView(R.id.orderTotalTextView) TextView orderTotalTextView;
@BindView(R.id.repeatOrderTextView) TextView repeatOrderTextView;
//@BindView(R.id.orderStatusTextView) TextView orderStatusTextView;
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(recyclerItemClickListener != null){
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
}
}
});
repeatOrderTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(recyclerItemClickListener != null){
recyclerItemClickListener.onItemClick(repeatOrderTextView, getAdapterPosition());
}
}
});
}
}
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
public SpaceViewHolder(final View view) {
super(view);
}
}
@Override
public int getItemViewType(int position) {
if(position == orderHistoryList.size())
return HOLDER_SPACE;
return HOLDER_ORDER;
}
public OrderHistoryRecyclerAdapter(ArrayList<OrderHistoryModel> orderHistoryList,
RecyclerItemClickListener recyclerItemClickListener){
this.orderHistoryList = orderHistoryList;
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_ORDER:
view = inflater.inflate(R.layout.row_order_history, 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_order_history, 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_ORDER :
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
orderViewHolder.orderDateTextView.setText(orderHistoryList.get(position).getFormattedCreateDate());
orderViewHolder.orderTotalTextView.setText(PriceHelper.roundFractions(orderHistoryList.get(position).getTotalString()));
//orderViewHolder.orderStatusTextView.setText(orderHistoryList.get(position).getStatus());
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return orderHistoryList.size() + 1 ;
}
private String createOrderInfoText(OrderHistoryModel orderHistoryModel){
return new StringBuilder()
.append(orderHistoryModel.getFormattedCreateDate())
.append("\n\n")
.append(orderHistoryModel.getStatus())
.toString();
}
}

View File

@@ -0,0 +1,53 @@
package ch.pizzacucina.android.adapter.recycler;
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.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.model.cart.CartTotalModel;
public class OrderPriceRecyclerAdapter extends RecyclerView.Adapter<OrderPriceRecyclerAdapter.ViewHolder> {
private ArrayList<CartTotalModel> cartTotalList;
public static class ViewHolder extends RecyclerView.ViewHolder{
@BindView(R.id.totalNameTextView) TextView totalNameTextView;
@BindView(R.id.totalPriceTextView) TextView totalPriceTextView;
public ViewHolder(final View view) {
super(view);
ButterKnife.bind(this, view);
}
}
public OrderPriceRecyclerAdapter(ArrayList<CartTotalModel> cartTotalList){
this.cartTotalList = cartTotalList;
}
@Override
public OrderPriceRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View root = LayoutInflater.from(BaseActivity.currentActivity).inflate(R.layout.row_price_total, viewGroup, false);
return new OrderPriceRecyclerAdapter.ViewHolder(root);
}
@Override
public void onBindViewHolder(OrderPriceRecyclerAdapter.ViewHolder holder, int position) {
holder.totalNameTextView.setText(cartTotalList.get(position).getTitle());
holder.totalPriceTextView.setText(cartTotalList.get(position).getText());
}
@Override
public int getItemCount() {
return cartTotalList.size();
}
}

View File

@@ -0,0 +1,118 @@
package ch.pizzacucina.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 java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.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_4dp, 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).getTitle());
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,79 @@
package ch.pizzacucina.android.adapter.recycler;
import android.support.v7.widget.AppCompatCheckBox;
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.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.menu.MenuProductOptionValueModel;
/**
* Created by cimenmus on 08/10/2017.
*/
public class ProductCheckboxOptionsRecyclerAdapter extends RecyclerView.Adapter<ProductCheckboxOptionsRecyclerAdapter.ViewHolder> {
private ArrayList<MenuProductOptionValueModel> productOptionValueList;
private RecyclerItemClickListener recyclerItemClickListener;
public static class ViewHolder extends RecyclerView.ViewHolder{
@BindView(R.id.productOptionCheckBox) AppCompatCheckBox productOptionCheckBox;
@BindView(R.id.optionPriceDescriptionTextView) TextView optionPriceDescriptionTextView;
public ViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
}
});
}
}
public ProductCheckboxOptionsRecyclerAdapter(ArrayList<MenuProductOptionValueModel> productOptionValueList){
this.productOptionValueList = productOptionValueList;
}
public ProductCheckboxOptionsRecyclerAdapter(ArrayList<MenuProductOptionValueModel> productOptionValueList,
RecyclerItemClickListener recyclerItemClickListener){
this.productOptionValueList = productOptionValueList;
this.recyclerItemClickListener = recyclerItemClickListener;
}
@Override
public ProductCheckboxOptionsRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View root = LayoutInflater.from(BaseActivity.currentActivity).inflate(R.layout.row_option_checkbox, viewGroup, false);
return new ProductCheckboxOptionsRecyclerAdapter.ViewHolder(root, recyclerItemClickListener);
}
@Override
public void onBindViewHolder(ProductCheckboxOptionsRecyclerAdapter.ViewHolder holder, int position) {
holder.productOptionCheckBox.setChecked(productOptionValueList.get(position).isSelected());
holder.productOptionCheckBox.setText(productOptionValueList.get(position).getName());
holder.optionPriceDescriptionTextView.setText(PriceHelper.getProductOptionPriceText(productOptionValueList.get(position)));
}
@Override
public int getItemCount() {
return productOptionValueList.size();
}
public void setRecyclerItemClickListener(RecyclerItemClickListener recyclerItemClickListener){
this.recyclerItemClickListener = recyclerItemClickListener;
}
}

View File

@@ -0,0 +1,100 @@
package ch.pizzacucina.android.adapter.recycler;
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.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.TextHelper;
import ch.pizzacucina.android.model.cart.CartProductModel;
public class ProductOnOrderSummaryRecyclerAdapter extends RecyclerView.Adapter<ProductOnOrderSummaryRecyclerAdapter.ViewHolder> {
private ArrayList<CartProductModel> cartProductList;
public static class ViewHolder extends RecyclerView.ViewHolder{
@BindView(R.id.productCountTextView) TextView productCountTextView;
@BindView(R.id.productNameTextView) TextView productNameTextView;
@BindView(R.id.productPropertiesTextView) TextView productPropertiesTextView;
@BindView(R.id.productPriceTextView) TextView productPriceTextView;
public ViewHolder(final View view) {
super(view);
ButterKnife.bind(this, view);
}
}
public ProductOnOrderSummaryRecyclerAdapter(ArrayList<CartProductModel> cartProductList){
this.cartProductList = cartProductList;
}
@Override
public ProductOnOrderSummaryRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View root = LayoutInflater.from(BaseActivity.currentActivity).inflate(R.layout.row_product_on_order_summary, viewGroup, false);
return new ProductOnOrderSummaryRecyclerAdapter.ViewHolder(root);
}
@Override
public void onBindViewHolder(ProductOnOrderSummaryRecyclerAdapter.ViewHolder holder, int position) {
holder.productCountTextView.setText(cartProductList.get(position).getQuantity());
holder.productNameTextView.setText(cartProductList.get(position).getName());
holder.productPriceTextView.setText(PriceHelper.roundFractions(cartProductList.get(position).getTotal()));
setCartInfoText(holder.productPropertiesTextView, cartProductList.get(position));
}
@Override
public int getItemCount() {
return cartProductList.size();
}
private void setCartInfoText(TextView textView, CartProductModel cartProductModel){
if(cartProductModel.getOption() == null || cartProductModel.getOption().size() == 0){
textView.setVisibility(View.GONE);
return;
}
textView.setVisibility(View.VISIBLE);
TextHelper.setTextFromHTML(textView, getCartInfoText(cartProductModel));
}
private String getCartInfoText(CartProductModel cartProductModel){
StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < cartProductModel.getOption().size(); i++){
if(!stringBuilder.toString().contains(cartProductModel.getOption().get(i).getName())){
/*
if(!stringBuilder.toString().isEmpty()){
stringBuilder.append("<br/>");
}
*/
stringBuilder
.append("<b>")
.append("<u>")
.append(cartProductModel.getOption().get(i).getName())
.append("</u>")
.append("</b>")
//.append("<br/>")
.append("<br/>");
}
stringBuilder
.append(cartProductModel.getOption().get(i).getValue())
.append("<br/>");
}
return stringBuilder.toString().trim();
}
}

View File

@@ -0,0 +1,80 @@
package ch.pizzacucina.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.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.menu.MenuProductOptionValueModel;
/**
* Created by cimenmus on 08/10/2017.
*/
public class ProductRadioOptionsRecyclerAdapter extends RecyclerView.Adapter<ProductRadioOptionsRecyclerAdapter.ViewHolder> {
private ArrayList<MenuProductOptionValueModel> productOptionValueList;
private RecyclerItemClickListener recyclerItemClickListener;
public static class ViewHolder extends RecyclerView.ViewHolder{
@BindView(R.id.productOptionRadioButton) AppCompatRadioButton productOptionRadioButton;
@BindView(R.id.optionPriceDescriptionTextView) TextView optionPriceDescriptionTextView;
public ViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
}
});
}
}
public ProductRadioOptionsRecyclerAdapter(ArrayList<MenuProductOptionValueModel> productOptionValueList){
this.productOptionValueList = productOptionValueList;
}
public ProductRadioOptionsRecyclerAdapter(ArrayList<MenuProductOptionValueModel> productOptionValueList,
RecyclerItemClickListener recyclerItemClickListener){
this.productOptionValueList = productOptionValueList;
this.recyclerItemClickListener = recyclerItemClickListener;
}
@Override
public ProductRadioOptionsRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View root = LayoutInflater.from(BaseActivity.currentActivity).inflate(R.layout.row_option_radio, viewGroup, false);
return new ProductRadioOptionsRecyclerAdapter.ViewHolder(root, recyclerItemClickListener);
}
@Override
public void onBindViewHolder(ProductRadioOptionsRecyclerAdapter.ViewHolder holder, int position) {
holder.productOptionRadioButton.setChecked(productOptionValueList.get(position).isSelected());
holder.productOptionRadioButton.setText(productOptionValueList.get(position).getName());
holder.optionPriceDescriptionTextView.setText(PriceHelper.getProductOptionPriceText(productOptionValueList.get(position)));
}
@Override
public int getItemCount() {
return productOptionValueList.size();
}
public void setRecyclerItemClickListener(RecyclerItemClickListener recyclerItemClickListener){
this.recyclerItemClickListener = recyclerItemClickListener;
}
}

View File

@@ -0,0 +1,118 @@
package ch.pizzacucina.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 java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.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,122 @@
package ch.pizzacucina.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.pizzacucina.android.R;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.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(PriceHelper.roundFractions(shippingMethodList.get(position).getPriceText()));
orderViewHolder.shipmentMethodRadioButton.setText(shippingMethodList.get(position).getTitle());
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

@@ -0,0 +1,53 @@
package ch.pizzacucina.android.api;
public class ApiConstants {
public static final int API_READ_TIMEOUT = 30;
public static final int API_CONNECT_TIMEOUT = 10;
public static final String API_PATH = "http://pizzamaxx.ch/";
//public static final String API_PATH = "http://pizzaleu.ddns.net/";
public static final String APP_TYPE_ID_ANDROID = "2";
public static final int APP_ERROR_CODE_AUTHORIZATION = 1;
public static final int PRODUCT_ID_WUNSCHPIZZA = 56;
public static final int PRODUCT_ID_ABEND_MENU = 733;
public static final int PRODUCT_ID_MITTAGS_MENU = 732;
public static final String CAMPAIGN_CODE_PIZZAPASS = "PIZZAPASS";
public static final String CAMPAIGN_CODE_KEBAPPASS = "KEBAPPASS";
public static final String PAYMENT_METHOD_CODE_CREDIT_DEBIT_CARD = "braintree"; // Credit / Debit Card
public static final String PAYMENT_METHOD_CODE_BANK_CASH = "cod"; // Bar
public static final String PAYMENT_METHOD_CODE_TRANSFER = "bank_transfer"; // Kreditkarten-Kartenzahlung
public static final String PAYMENT_METHOD_CODE_TWINT = "twintcw_twint"; // TWINT
public static final String PAYMENT_METHOD_CODE_PAYPAL = "pp_standard";
public static final String PAYMENT_METHOD_CODE_POST_FINANCE_CARD = "postfinancecw_postfinancecard";
public static final String PAYMENT_METHOD_CODE_ANDROID_PAY = "android_pay";
public static final String PAYMENT_METHOD_CODE_APPLE_PAY = "apple_pay";
public static final String DATATRANS_MERCHANT_ID_TEST = "1100004450"; // Taken from Datatrans sample app
//public static final String DATATRANS_MERCHANT_ID_TEST = "1100020808"; // taken from Datatrans sandbox Demo Pusula Media GmbH
public static final String DATATRANS_REFERENCE_NUMBER_TEST = "968927"; // Taken from Datatrans sample app
public static final String DATATRANS_SIGNATURE_TEST = "30916165706580013"; // Taken from Datatrans sample app
public static final String SHIPPING_METHOD_CODE_FREE_SHIPPING = "free.free";
public static final String SHIPPING_METHOD_CODE_PICK_UP_FROM_STORE = "pickup.pickup";
public static final String CART_SUBTOTAL = "zwischensumme";
public static final String CART_COMMISSION = "zahlungsgebühr";
public static final String CART_TOTAL = "total";
public static final String OPTION_ID_ABEND_AND_MITTAGS_MENU_PIZZA_SELECTION = "73";
public static final String PRODUCT_OPTION_ID_ABEND_MENU_PIZZA_SELECTION = "869";
public static final String PRODUCT_OPTION_ID_MITTAGS_MENU_OPTIONS = "872";
public static final String ONESIGNAL_NOTIFICATION_TAG_KEY = "notificationAllowed";
public static final String ONESIGNAL_NOTIFICATION_TAG_VALUE = "true";
public static final String PAYMENT_WEBVIEW_URL_POSTFINANCE_TWINT = "https://pizza-cucina.ch/pizzacucina/index.php?route=mobile/service/postFinancePayment&order_id=";
public static final String PAYMENT_WEBVIEW_REDIRECT_URL_POSTFINANCE_TWINT_SUCCESS = "postFinancePaymentIsSuccess";
public static final String PAYMENT_WEBVIEW_REDIRECT_URL_POSTFINANCE_TWINT_FAIL = "postFinancePaymentIsFailed";
public static final String PAYMENT_WEBVIEW_MAIN_PAGE_HTTP = "http://www.pizza-cucina.ch/";
public static final String PAYMENT_WEBVIEW_MAIN_PAGE_HTTPS = "https://www.pizza-cucina.ch/";
}

View File

@@ -0,0 +1,55 @@
package ch.pizzacucina.android.api;
public class ApiEndPoints {
private static final String PREFIX = "/index.php?route=mobile/service/";
private static final String SUFFIX = "&is_mobile=1";
public static final String API_GET_STORE_LIST = "pizza/servicemagazabelirle.php";
public static final String API_GET_CAMPAIGN_BANNERS = "pizzacucina/" + PREFIX + "getCampaignBanners" + SUFFIX;
public static final String API_GET_ALL_CATEGORIES = PREFIX + "getAllCategories" + SUFFIX;
public static final String API_GET_IGNORED_CATEGORY_IDS= PREFIX + "getIgnoredCategory" + SUFFIX;
public static final String API_GET_PIZZA_CATEGORY_IDS= PREFIX + "getPizzaCategories" + SUFFIX;
public static final String API_REGISTER = PREFIX + "signUp" + SUFFIX;
public static final String API_LOGIN = PREFIX + "login" + SUFFIX;
public static final String API_LOGOUT = PREFIX + "logout" + SUFFIX;
public static final String API_GET_ORDER_HISTORY = PREFIX + "getOrders" + SUFFIX;
public static final String API_GET_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_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;
public static final String API_CHECK_UPDATE = PREFIX + "checkUpdate" + SUFFIX;
public static final String API_FORGOT_PASSWORD = PREFIX + "forgotPassword" + SUFFIX;
public static final String API_GET_CITY_LIST = PREFIX + "getCities" + SUFFIX;
public static final String API_GET_COUNTRY_LIST = PREFIX + "getCountries" + SUFFIX;
public static final String API_GET_ZONE_LIST = PREFIX + "getZones" + SUFFIX;
public static final String API_GET_CUSTOMER_PROFILE = PREFIX + "getCustomerInfo" + SUFFIX;
public static final String API_GET_STORE_INFO = PREFIX + "getStoreInfo" + SUFFIX;
public static final String API_CHECK_CAMPAIGN_PIZZAPASS = PREFIX + "detectPizzaPassCampaign" + SUFFIX + "&token=";
public static final String API_CHECK_CAMPAIGN_KEBAPPASS = PREFIX + "detectKebapPassCampaign" + SUFFIX + "&token=";
public static final String API_CHECK_DELIVERY_TIME = PREFIX + "checkDeliveryTimeService" + SUFFIX;
public static final String API_GET_DELIVERY_TIME_OF_STORE = PREFIX + "getDeliveryTimeForStore" + SUFFIX;
public static final String API_GET_CART_PRODUCTS = PREFIX + "getBasketProducts" + SUFFIX + "&token=";
//addProductsToBasketYeni
public static final String API_ADD_PRODUCTS_TO_BASKET = PREFIX + "addProductsToBasket" + SUFFIX + "&token=";
public static final String API_ADD_NEW_ADDRESS = PREFIX + "addAddress" + SUFFIX + "&token=";
public static final String API_DELETE_ADDRESS = PREFIX + "deleteAddress" + SUFFIX + "&token=";
public static final String API_CREATE_ORDER = PREFIX + "addOrder" + SUFFIX + "&token=";
public static final String API_UPDATE_PASSWORD = PREFIX + "passwordUpdate" + SUFFIX + "&token=";
public static final String API_UPDATE_PROFILE = PREFIX + "updateCustomerInfo" + SUFFIX + "&token=";
public static final String API_REMOVE_RPODUCT_FORM_CART = PREFIX + "removeProductFromBasket" + SUFFIX + "&token=";
public static final String API_GET_ORDER_PRODUCT_LIST = PREFIX + "getOrderProducts" + SUFFIX + "&token=";
public static final String API_CHECK_COUPON = PREFIX + "checkCoupon" + SUFFIX + "&token=";
public static final String API_CREATE_BRAINTREE_PAYMENT = PREFIX + "checkBrainTreePayment" + SUFFIX + "&token=";
public static final String API_REPEAT_ORDER = PREFIX + "reOrder" + SUFFIX + "&token=";
public static final String API_CHECK_ORDER_PRICE = PREFIX + "checkOrderPrice" + SUFFIX + "&token=";
public static final String API_CREATE_BRAINTREE_PAYMENT_TOKEN = PREFIX + "createPaymentToken" + SUFFIX + "&token=";
public static final String API_GET_DATATRANS_INFO = PREFIX + "getDatatransInfo" + SUFFIX + "&token=";
public static final String API_CREATE_DATATRANS_PAYMENT = PREFIX + "checkDatatransPayment" + SUFFIX + "&token=";
}

View File

@@ -0,0 +1,43 @@
package ch.pizzacucina.android.api;
public class ApiError {
private boolean success;
private int error_code;
private String message;
private int statusCode;
public ApiError() {}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public int getError_code() {
return error_code;
}
public void setError_code(int error_code) {
this.error_code = error_code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
}

View File

@@ -0,0 +1,71 @@
package ch.pizzacucina.android.api;
import android.content.Intent;
import java.lang.annotation.Annotation;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.LoginActivity;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Response;
public class ApiErrorUtils {
public static void parseError(Response<?> response) {
Converter<ResponseBody, ApiError> converter = ApiService.retrofit.responseBodyConverter(ApiError.class, new Annotation[0]);
ApiError error = new ApiError();
error.setStatusCode(response.code());
BaseResponse baseResponse = (BaseResponse) response.body();
if(baseResponse != null){
if(baseResponse.getErrorCode() == ApiConstants.APP_ERROR_CODE_AUTHORIZATION){
SharedPrefsHelper.clearCustomerInfo();
SharedPrefsHelper.clearCustomerToken();
SharedPrefsHelper.setCustomerLoggedIn(false);
BaseActivity.currentActivity.startActivity(new Intent(BaseActivity.currentActivity, LoginActivity.class));
BaseActivity.currentActivity.finishAffinity();
return;
}
if(baseResponse.getMessage() != null && !baseResponse.getMessage().isEmpty()){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, baseResponse.getMessage());
return;
}
}
try {
error = converter.convert(response.errorBody());
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, error.getMessage());
} catch (Exception e) {
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, BaseActivity.currentActivity.getString(R.string.something_went_wrong));
}
}
public static void parseErrorWithoutAuthorizationErrorControl(Response<?> response) {
Converter<ResponseBody, ApiError> converter = ApiService.retrofit.responseBodyConverter(ApiError.class, new Annotation[0]);
ApiError error = new ApiError();
error.setStatusCode(response.code());
BaseResponse baseResponse = (BaseResponse) response.body();
if (baseResponse != null && baseResponse.getMessage() != null && !baseResponse.getMessage().isEmpty()) {
DialogHelper.showAlertDialog(BaseActivity.currentActivity, baseResponse.getMessage());
return;
}
try {
error = converter.convert(response.errorBody());
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, error.getMessage());
} catch (Exception e) {
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, BaseActivity.currentActivity.getString(R.string.something_went_wrong));
}
}
}

View File

@@ -0,0 +1,393 @@
package ch.pizzacucina.android.api;
import java.util.HashMap;
import ch.pizzacucina.android.model.AddNewAddressResponseModel;
import ch.pizzacucina.android.model.AddProductToBasketResponseModel;
import ch.pizzacucina.android.model.AddressModel;
import ch.pizzacucina.android.model.AppVersionModel;
import ch.pizzacucina.android.model.CampaignBannerModel;
import ch.pizzacucina.android.model.CampaignModel;
import ch.pizzacucina.android.model.CheckCouponModel;
import ch.pizzacucina.android.model.CountryModel;
import ch.pizzacucina.android.model.DeleteAddressResponseModel;
import ch.pizzacucina.android.model.PaymentMethodsResponseModel;
import ch.pizzacucina.android.model.PaymentTokenModel;
import ch.pizzacucina.android.model.RemoveProductFromCartResponseModel;
import ch.pizzacucina.android.model.ShippingMethodModel;
import ch.pizzacucina.android.model.StoreInfoModel;
import ch.pizzacucina.android.model.CityModel;
import ch.pizzacucina.android.model.StoreModel;
import ch.pizzacucina.android.model.StoreShiftModel;
import ch.pizzacucina.android.model.ZoneModel;
import ch.pizzacucina.android.model.cart.CartInfoModel;
import ch.pizzacucina.android.model.CategoryModel;
import ch.pizzacucina.android.model.history.OrderHistoryModel;
import ch.pizzacucina.android.model.UserModel;
import ch.pizzacucina.android.model.history.OrderHistoryProductModel;
import ch.pizzacucina.android.model.menu.MenuProductModel;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;
/**
* Created by cimenmus on 04/02/2017.
*/
public interface ApiInterface {
@GET("{storeName}" + ApiEndPoints.API_GET_ALL_CATEGORIES)
Call<ResponseArray<CategoryModel>> getAllCategories(@Path("storeName") String storeName);
@GET("{storeName}" + ApiEndPoints.API_GET_IGNORED_CATEGORY_IDS)
Call<ResponseArray<Integer>> getIgnoredCategoryIds(@Path("storeName") String storeName);
@GET("{storeName}" + ApiEndPoints.API_GET_PIZZA_CATEGORY_IDS)
Call<ResponseArray<Integer>> getPizzaCategoryIds(@Path("storeName") String storeName);
@FormUrlEncoded
@POST("{storeName}" + ApiEndPoints.API_REGISTER)
Call<ResponseObject<UserModel>> register(@Path("storeName") String storeName,
@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST("{storeName}" + ApiEndPoints.API_LOGIN)
Call<ResponseObject<UserModel>> login(@Path("storeName") String storeName,
@Field("email") String email,
@Field("password") String password);
@FormUrlEncoded
@POST("{storeName}" + ApiEndPoints.API_LOGOUT)
Call<ResponseObject> logout(@Path("storeName") String storeName,
@Field("token") String customerToken);
@GET("{storeName}" + ApiEndPoints.API_GET_ORDER_HISTORY)
Call<ResponseArray<OrderHistoryModel>> getOrderHistory(@Path("storeName") String storeName,
@Query("token") String token);
/*
// OK
@POST
Call<ResponseObject<CartInfoModel>> getCartProducts(@Url String url);
// OK
@FormUrlEncoded
@POST
Call<ResponseObject<CartInfoModel>> getCartProductsForCommission(@Url String url,
@Field("payment_method") String paymentMethodCode,
@Field("shipping_method") String shippingMethodCode);
@FormUrlEncoded
@POST
Call<ResponseObject<CartInfoModel>> getCartProductsWithCoupon(@Url String url,
@FieldMap HashMap<String, Object> body);
*/
@FormUrlEncoded
@POST
Call<ResponseObject<CartInfoModel>> getCartProducts(@Url String url,
@FieldMap HashMap<String, Object> body);
@GET("{storeName}" + ApiEndPoints.API_GET_CLEAR_CART)
Call<ResponseObject> clearCart(@Path("storeName") String storeName,
@Query("token") String token);
@GET("{storeName}" + ApiEndPoints.API_GET_PRODUCTS_BY_CATEGORY)
Call<ResponseArray<MenuProductModel>> getProductsByCategory(@Path("storeName") String storeName,
@Query("category_id") String categoryId);
@FormUrlEncoded
@POST("{storeName}" + ApiEndPoints.API_GET_PRODUCT)
Call<ResponseArray<MenuProductModel>> getProductById(@Path("storeName") String storeName,
@Field("product_id") int productId);
// * Bu projedeki post servisler bizden form-data bekliyor. Bu serviste @FormUrlEncoded yapınca ve
// * body'i @FieldMap HashMap<String, Object> body olarak verince, body içindeki alanlar
// * encode ediliyor, mesela body içindeki "[" karakteri "%5D" ye falan dönüşüyor, dolayısı ile servis bunları okuyamıyor.
// * Bu sebeple body olarak RequestBody verdim ve servisi çağırırken bod içindeki alanları FormBody olarak ekledim.
// OK
@POST
Call<ResponseObject<AddProductToBasketResponseModel>> addProductsToBasket(@Url String url,
@Body RequestBody body);
@GET("{storeName}" + ApiEndPoints.API_GET_SHIPPING_METHODS)
Call<ResponseArray<ShippingMethodModel>> getShippingMethods(@Path("storeName") String storeName,
@Query("token") String token);
@GET("{storeName}" + ApiEndPoints.API_GET_CUSTOMER_ADDRESSES)
Call<ResponseArray<AddressModel>> getCustomerAddresses(@Path("storeName") String storeName,
@Query("token") String token);
@FormUrlEncoded
@POST
Call<ResponseObject<AddNewAddressResponseModel>> addNewAddress(@Url String url,
@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject<DeleteAddressResponseModel>> deleteAddress(@Url String url,
@Field("address_id") String addressId);
@GET("{storeName}" + ApiEndPoints.API_GET_PAYMENT_METHODS)
Call<ResponseObject<PaymentMethodsResponseModel>> getPaymentMethods(@Path("storeName") String storeName,
@Query("token") String token);
@FormUrlEncoded
@POST
Call<ResponseObject<Integer>> createOrder(@Url String url, @FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST("{storeName}" + ApiEndPoints.API_CHECK_UPDATE)
Call<ResponseObject<AppVersionModel>> checkUpdate(@Path("storeName") String storeName,
@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST("{storeName}" + ApiEndPoints.API_FORGOT_PASSWORD)
Call<ResponseObject> forgotPassword(@Path("storeName") String storeName,
@Field("email") String emailAddress);
@GET("{storeName}" + ApiEndPoints.API_GET_CITY_LIST)
Call<ResponseArray<CityModel>> getCityList(@Path("storeName") String storeName);
@GET("{storeName}" + ApiEndPoints.API_GET_COUNTRY_LIST)
Call<ResponseArray<CountryModel>> getCountryList(@Path("storeName") String storeName);
@FormUrlEncoded
@POST("{storeName}" + ApiEndPoints.API_GET_ZONE_LIST)
Call<ResponseArray<ZoneModel>> getZoneList(@Path("storeName") String storeName,
@Field("country_id") String countryId);
@GET("{storeName}" + ApiEndPoints.API_GET_CUSTOMER_PROFILE)
Call<ResponseObject<UserModel>> getCustomerProfile(@Path("storeName") String storeName,
@Query("token") String token);
@FormUrlEncoded
@POST
Call<ResponseObject> updatePassword(@Url String url,
@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject<UserModel>> updateProfile(@Url String url,
@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject<RemoveProductFromCartResponseModel>> removeProductFromCart(@Url String url,
@FieldMap HashMap<String, Object> body);
@GET("{storeName}" + ApiEndPoints.API_GET_STORE_INFO)
Call<ResponseObject<StoreInfoModel>> getStoreInfo(@Path("storeName") String storeName);
@FormUrlEncoded
@POST
Call<ResponseArray<OrderHistoryProductModel>> getOrderProductList(@Url String url,
@Field("order_id") String orderId);
@FormUrlEncoded
@POST
Call<ResponseObject<CheckCouponModel>> checkCoupon(@Url String url,
@Field("coupon") String couponCode);
@GET("{storeName}" + ApiEndPoints.API_CHECK_CAMPAIGN_PIZZAPASS)
Call<ResponseObject<CampaignModel>> checkPizzapassCampaign(@Path("storeName") String storeName,
@Query("token") String token);
@GET("{storeName}" + ApiEndPoints.API_CHECK_CAMPAIGN_KEBAPPASS)
Call<ResponseObject<CampaignModel>> checkKebapPassCampaign(@Path("storeName") String storeName,
@Query("token") String token);
@GET("{storeName}" + ApiEndPoints.API_CHECK_DELIVERY_TIME)
Call<ResponseObject<Boolean>> checkDeliveryTime(@Path("storeName") String storeName,
@Query("shipping_method_code") String shippingMethodCode);
@FormUrlEncoded
@POST("{storeName}" + ApiEndPoints.API_CHECK_DELIVERY_TIME)
Call<ResponseObject<Boolean>> checkDeliveryTimeWithDateAndTime(@Path("storeName") String storeName,
@Field("delivery_date") String deliveryDateAndTime,
@Field("shipping_method_code") String shippingMethodCode);
@FormUrlEncoded
@POST
Call<ResponseObject> createBraintreePayment(@Url String url,
@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject> repeatOrder(@Url String url,
@FieldMap HashMap<String, Object> body);
@GET(ApiEndPoints.API_GET_STORE_LIST)
Call<ResponseArray<StoreModel>> getStoreList();
@GET("{storeName}" + ApiEndPoints.API_GET_DELIVERY_TIME_OF_STORE)
Call<ResponseObject<StoreShiftModel>> getDeliveryTimeOfStore(@Path("storeName") String storeName,
@Query("shipping_method_code") String shippingMethodCode);
@FormUrlEncoded
@POST
Call<ResponseObject> checkOrderPrice(@Url String url,
@FieldMap HashMap<String, Object> body);
@GET
Call<ResponseObject<PaymentTokenModel>> createBraintreePaymentToken(@Url String url);
@GET(ApiEndPoints.API_GET_CAMPAIGN_BANNERS)
Call<ResponseArray<CampaignBannerModel>> getCampaignBanners();
/*
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
Call<ResponseArray<CategoryModel>> getAllCategories(@Path("id") int id);
@GET(ApiEndPoints.API_GET_IGNORED_CATEGORY_IDS)
Call<ResponseArray<Integer>> getIgnoredCategoryIds();
@GET(ApiEndPoints.API_GET_PIZZA_CATEGORY_IDS)
Call<ResponseArray<Integer>> getPizzaCategoryIds();
@FormUrlEncoded
@POST(ApiEndPoints.API_REGISTER)
Call<ResponseObject<UserModel>> register(@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST(ApiEndPoints.API_LOGIN)
Call<ResponseObject<UserModel>> login(@Field("email") String email, @Field("password") String password);
@FormUrlEncoded
@POST(ApiEndPoints.API_LOGOUT)
Call<ResponseObject> logout(@Field("token") String customerToken);
@GET(ApiEndPoints.API_GET_ORDER_HISTORY)
Call<ResponseArray<OrderHistoryModel>> getOrderHistory(@Query("token") String token);
@POST
Call<ResponseObject<CartInfoModel>> getCartProducts(@Url String url);
@FormUrlEncoded
@POST
Call<ResponseObject<CartInfoModel>> getCartProductsForCommission(@Url String url,
@Field("payment_method") String paymentMethodCode,
@Field("shipping_method") String shippingMethodCode);
@GET(ApiEndPoints.API_GET_CLEAR_CART)
Call<ResponseObject> clearCart(@Query("token") String token);
@GET(ApiEndPoints.API_GET_PRODUCTS_BY_CATEGORY)
Call<ResponseArray<MenuProductModel>> getProductsByCategory(@Query("category_id") String categoryId);
@FormUrlEncoded
@POST(ApiEndPoints.API_GET_PRODUCT)
Call<ResponseArray<MenuProductModel>> getProductById(@Field("product_id") int productId);
// * Bu projedeki post servisler bizden form-data bekliyor. Bu serviste @FormUrlEncoded yapınca ve
// * body'i @FieldMap HashMap<String, Object> body olarak verince, body içindeki alanlar
// * encode ediliyor, mesela body içindeki "[" karakteri "%5D" ye falan dönüşüyor, dolayısı ile servis bunları okuyamıyor.
// * Bu sebeple body olarak RequestBody verdim ve servisi çağırırken bod içindeki alanları FormBody olarak ekledim.
@POST
Call<ResponseObject<AddProductToBasketResponseModel>> addProductsToBasket(@Url String url,
@Body RequestBody 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);
@FormUrlEncoded
@POST
Call<ResponseObject<AddNewAddressResponseModel>> addNewAddress(@Url String url,
@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject<DeleteAddressResponseModel>> deleteAddress(@Url String url,
@Field("address_id") String addressId);
@GET(ApiEndPoints.API_GET_PAYMENT_METHODS)
Call<ResponseObject<PaymentMethodsResponseModel>> getPaymentMethods(@Query("token") String token);
@FormUrlEncoded
@POST
Call<ResponseObject<Integer>> createOrder(@Url String url, @FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST(ApiEndPoints.API_CHECK_UPDATE)
Call<ResponseObject<AppVersionModel>> checkUpdate(@FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST(ApiEndPoints.API_FORGOT_PASSWORD)
Call<ResponseObject> forgotPassword(@Field("email") String emailAddress);
@GET(ApiEndPoints.API_GET_CITY_LIST)
Call<ResponseArray<CityModel>> getCityList();
@GET(ApiEndPoints.API_GET_COUNTRY_LIST)
Call<ResponseArray<CountryModel>> getCountryList();
@FormUrlEncoded
@POST(ApiEndPoints.API_GET_ZONE_LIST)
Call<ResponseArray<ZoneModel>> getZoneList(@Field("country_id") String countryId);
@GET(ApiEndPoints.API_GET_CUSTOMER_PROFILE)
Call<ResponseObject<UserModel>> getCustomerProfile(@Query("token") String token);
@FormUrlEncoded
@POST
Call<ResponseObject> updatePassword(@Url String url, @FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject<UserModel>> updateProfile(@Url String url, @FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject<RemoveProductFromCartResponseModel>> removeProductFromCart(@Url String url,
@FieldMap HashMap<String, Object> body);
@GET(ApiEndPoints.API_GET_STORE_INFO)
Call<ResponseObject<StoreInfoModel>> getStoreInfo();
@FormUrlEncoded
@POST
Call<ResponseArray<OrderHistoryProductModel>> getOrderProductList(@Url String url,
@Field("order_id") String orderId);
@FormUrlEncoded
@POST
Call<ResponseObject<CheckCouponModel>> checkCoupon(@Url String url, @Field("coupon") String couponCode);
@GET(ApiEndPoints.API_CHECK_CAMPAIGN_PIZZAPASS)
Call<ResponseObject<CampaignModel>> checkPizzapassCampaign(@Query("token") String token);
@GET(ApiEndPoints.API_CHECK_CAMPAIGN_KEBAPPASS)
Call<ResponseObject<CampaignModel>> checkKebapPassCampaign(@Query("token") String token);
@GET(ApiEndPoints.API_CHECK_DELIVERY_TIME)
Call<ResponseObject<Boolean>> checkDeliveryTime();
@FormUrlEncoded
@POST(ApiEndPoints.API_CHECK_DELIVERY_TIME)
Call<ResponseObject<Boolean>> checkDeliveryTimeWithDateAndTime(@Field("delivery_date") String deliveryDateAndTime);
@FormUrlEncoded
@POST
Call<ResponseObject> createPayment(@Url String url, @FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject> repeatOrder(@Url String url, @FieldMap HashMap<String, Object> body);
@GET(ApiEndPoints.API_GET_STORE_LIST)
Call<ResponseArray<StoreModel>> getStoreList();
*/
}

View File

@@ -0,0 +1,69 @@
package ch.pizzacucina.android.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import ch.pizzacucina.android.BuildConfig;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ApiService {
private static ApiService apiService = new ApiService();
public static ApiInterface apiInterface;
public static Retrofit retrofit;
private ApiService() { reset();}
public static ApiService getInstance() {
return apiService;
}
public void reset() {
Gson gson = new GsonBuilder()
.setLenient()
.create();
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
builder.readTimeout(ApiConstants.API_READ_TIMEOUT, TimeUnit.SECONDS);
builder.connectTimeout(ApiConstants.API_CONNECT_TIMEOUT, TimeUnit.SECONDS);
builder.addInterceptor(new Interceptor() {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request.Builder builder = chain.request().newBuilder();
builder.addHeader("Content-Type", "application/json");
Request request = builder.build();
return chain.proceed(request);
}
});
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); // set your desired log level
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
if(BuildConfig.DEBUG){
builder.addInterceptor(logging);
}
OkHttpClient client = builder.build();
retrofit = new Retrofit.Builder()
.baseUrl(ApiConstants.API_PATH)
.addConverterFactory(GsonConverterFactory.create(gson))
.client(client)
.build();
apiInterface = retrofit.create(ApiInterface.class);
}
}

View File

@@ -0,0 +1,28 @@
package ch.pizzacucina.android.api;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
/**
* Created by cimenmus on 22.10.2017.
*/
public class BaseResponse implements Serializable {
@SerializedName("success") private boolean success;
@SerializedName("message") private String message;
@SerializedName("error_code") private int errorCode;
public boolean isSuccess() {
return success;
}
public String getMessage() {
return message;
}
public int getErrorCode() {
return errorCode;
}
}

View File

@@ -0,0 +1,19 @@
package ch.pizzacucina.android.api;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Created by cimenmus on 05/10/2017.
*/
public class ResponseArray<T> extends BaseResponse implements Serializable {
@SerializedName("data") private ArrayList<T> data;
public ArrayList<T> getData() {
return data;
}
}

View File

@@ -0,0 +1,18 @@
package ch.pizzacucina.android.api;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
/**
* Created by cimenmus on 05/10/2017.
*/
public class ResponseObject<T> extends BaseResponse implements Serializable {
@SerializedName("data") private T data;
public T getData() {
return data;
}
}

View File

@@ -0,0 +1,20 @@
package ch.pizzacucina.android.fragment;
import android.support.v4.app.Fragment;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.MainActivity;
/**
* Created by cimenmus on 18/09/2017.
*/
public class BaseFragment extends Fragment {
public void setPizzalinkToolbarFields(boolean showHamburgerIcon, String title){
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
if(mainActivity == null)
return;
mainActivity.setPizzalinkToolbarFields(showHamburgerIcon, title);
}
}

View File

@@ -0,0 +1,53 @@
package ch.pizzacucina.android.fragment;
import android.os.Bundle;
import android.support.v7.widget.AppCompatImageView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.helper.ImageLoadHelper;
import ch.pizzacucina.android.model.CampaignBannerModel;
public class CampaignBannerFragment extends BaseFragment {
@BindView(R.id.campaignBannerImageView) AppCompatImageView campaignBannerImageView;
public static final String FRAGMENT_NAME = "campaignFragment";
private CampaignBannerModel campaignBannerModel;
public CampaignBannerFragment() {}
public static CampaignBannerFragment newInstance(CampaignBannerModel campaignBannerModel) {
Bundle args = new Bundle();
args.putSerializable("campaignBannerModel", campaignBannerModel);
CampaignBannerFragment fragment = new CampaignBannerFragment();
fragment.setArguments(args);
return fragment;
}
@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_campaign_banner, container, false);
ButterKnife.bind(this, view);
getDataFromArguments();
initViews();
return view;
}
private void getDataFromArguments(){
campaignBannerModel = (CampaignBannerModel) getArguments().getSerializable("campaignBannerModel");
}
private void initViews(){
ImageLoadHelper.loadImage(campaignBannerImageView, campaignBannerModel.getImageUrl());
}
}

View File

@@ -0,0 +1,751 @@
package ch.pizzacucina.android.fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
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 android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import butterknife.BindColor;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.CampaignProductListActivity;
import ch.pizzacucina.android.activity.CreateOrderActivity;
import ch.pizzacucina.android.activity.MainActivity;
import ch.pizzacucina.android.adapter.recycler.CartRecyclerAdapter;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.CampaignModel;
import ch.pizzacucina.android.model.RemoveProductFromCartResponseModel;
import ch.pizzacucina.android.model.cart.CartInfoModel;
import ch.pizzacucina.android.model.cart.CartProductModel;
import ch.pizzacucina.android.model.menu.MenuProductModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by cimenmus on 18/09/2017.
*/
public class CartFragment extends BaseFragment {
@BindView(R.id.cartFragmentMainLayout) RelativeLayout cartFragmentMainLayout;
@BindView(R.id.noProductsOnCartTextView) TextView noProductsOnCartTextView;
@BindView(R.id.cartRecyclerView) RecyclerView cartRecyclerView;
@BindView(R.id.cartInfoLayout) LinearLayout cartInfoLayout;
@BindView(R.id.cartTotalLabelTextView) TextView cartTotalLabelTextView;
@BindView(R.id.cartProductTotalTextView) TextView cartProductTotalTextView;
@BindView(R.id.continueCartButton) Button continueCartButton;
@BindView(R.id.clearCartButton) Button clearCartButton;
@BindString(R.string.bottom_nav_menu_item_cart) String fragmentTitle;
@BindString(R.string.alert_remove_prdocut_from_cart) String removeProdcutFromCartAlert;
@BindString(R.string.product_removed_from_cart) String productRemovedFromCartText;
@BindString(R.string.alert_clear_cart) String clearCartAlertText;
@BindString(R.string.minimum_order_price_alert_part_1) String minimumOrderPriceAlertPart1Text;
@BindString(R.string.minimum_order_price_alert_part_2) String minimumOrderPriceAlertPart2Text;
@BindString(R.string.something_went_wrong) String genericErrorText;
@BindColor(R.color.actvity_default_background_color_1) int grayColor;
@BindColor(R.color.white) int whiteColor;
public static final java.lang.String FRAGMENT_NAME = "cartFragment";
private int REQUEST_CODE_CAMPAIGN_PRODUCT_LIST = 7847;
private String pizzapassCampaignCategoryId = "";
private String kebappassCampaignCategoryId = "";
private CartInfoModel cartInfoModel;
private ArrayList<CartProductModel> cartProductList = new ArrayList<>();
private CartRecyclerAdapter cartRecyclerAdapter;
public CartFragment() {}
public static CartFragment newInstance() {
return new CartFragment();
}
@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_cart, container, false);
ButterKnife.bind(this, view);
initViews();
return view;
}
@Override
public void onResume() {
super.onResume();
getCartProducts();
}
/*
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE_CAMPAIGN_PRODUCT_LIST && resultCode == RESULT_OK){
BaseActivity.setCurrentActivity(createOrderActivity);
getCartProducts();
}
}
*/
@OnClick({R.id.clearCartButton, R.id.continueCartButton})
protected void onClick(View view){
switch (view.getId()){
case R.id.clearCartButton:
DialogHelper.showTwoButtonsDialog(BaseActivity.currentActivity, clearCartAlertText,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
clearCart();
}
}, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
});
break;
case R.id.continueCartButton:
// without minimum price control for store. minimum price is contorlled by addOrder2() service.
if(!pizzapassCampaignCategoryId.isEmpty()){
getCampaignProductsForPizzapassOnContinueButtonClicked();
}
else if(!kebappassCampaignCategoryId.isEmpty()){
getCampaignProductsForKebappassOnContinueButtonClicked();
}
else {
openCreateOrderActivity();
}
break;
// with minimum price control for store
/*
Double storeMinimumPrice = PriceHelper.stringToDouble(SessionHelper.getSelectedStore().getMinimumPrice());
Double cartCurrentPrice = PriceHelper.stringToDouble(PriceHelper.removeCurrencyFromPrice(cartInfoModel.getCartTotalModel().getText()));
if(cartCurrentPrice >= storeMinimumPrice){
if(!pizzapassCampaignCategoryId.isEmpty()){
getCampaignProductsForPizzapassOnContinueButtonClicked();
}
else if(!kebappassCampaignCategoryId.isEmpty()){
getCampaignProductsForKebappassOnContinueButtonClicked();
}
else {
openCreateOrderActivity();
}
}
else {
String dialogText =
new StringBuilder()
.append(minimumOrderPriceAlertPart1Text)
.append(" ")
.append(SessionHelper.getSelectedStore().getMinimumPrice())
.append(" ")
.append(minimumOrderPriceAlertPart2Text)
.toString();
DialogHelper.showAlertDialog(
BaseActivity.currentActivity,
dialogText);
}
break;
*/
}
}
private void initViews(){
setPizzalinkToolbarFields(false, fragmentTitle);
initRecyclerView();
}
private void getCartProducts(){
DialogHelper.showLoadingDialog();
/*
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
*/
HashMap<String, Object> params = new HashMap<>();
if(SessionHelper.getSelectedCoupon() != null){
params.put("coupon", SessionHelper.getSelectedCoupon().getCode());
}
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
params);
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
@Override
public void onResponse(Call<ResponseObject<CartInfoModel>> call, Response<ResponseObject<CartInfoModel>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
cartInfoModel = response.body().getData();
cartInfoModel.checkNull();
SharedPrefsHelper.setCartItemCount(cartInfoModel.getProducts().size());
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(cartInfoModel.getCartTotalModel().getText()));
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
mainActivity.updateBadge();
mainActivity.setCartTotalLayoutVisibility(false);
setCartTotalFields();
fillAndNotifyAdapter();
if(cartInfoModel.getProducts().isEmpty()){
DialogHelper.hideLoadingDialog();
}
else {
checkPizzapassCampaign();
}
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void clearCart(){
DialogHelper.showLoadingDialog();
Call<ResponseObject> call = ApiService.apiInterface.clearCart(
SessionHelper.getSelectedStore().getStoreName(),
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseObject>() {
@Override
public void onResponse(Call<ResponseObject> call, Response<ResponseObject> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() && response.body().isSuccess()){
cartProductList.clear();
cartRecyclerAdapter.notifyDataSetChanged();
setCartLayoutsVisibility();
SharedPrefsHelper.setCartItemCount(0);
SharedPrefsHelper.setCartTotalPrice("0");
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
mainActivity.setCartItemCount();
}
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseObject> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyAdapter(){
CartProductModel.checkNull(cartInfoModel.getProducts());
cartProductList.clear();
cartProductList.addAll(cartInfoModel.getProducts());
sortCartProducts();
cartRecyclerAdapter.notifyDataSetChanged();
setCartLayoutsVisibility();
}
private void setCartTotalFields(){
cartTotalLabelTextView.setText(cartInfoModel.getCartTotalModel().getTitle().toUpperCase(Locale.GERMAN));
cartProductTotalTextView.setText(PriceHelper.roundFractions(cartInfoModel.getCartTotalModel().getText()));
}
private void initRecyclerView(){
cartRecyclerAdapter = new CartRecyclerAdapter(cartProductList, new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, final int position) {
DialogHelper.showTwoButtonsDialog(BaseActivity.currentActivity, removeProdcutFromCartAlert,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
removeProductFromCart(position);
}
}, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
});
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
cartRecyclerView.setLayoutManager(layoutManager);
cartRecyclerView.setAdapter(cartRecyclerAdapter);
}
private void setCartLayoutsVisibility(){
if(cartProductList.size() > 0){
noProductsOnCartTextView.setVisibility(View.GONE);
//cartFragmentMainLayout.setBackgroundColor(grayColor);
cartRecyclerView.setVisibility(View.VISIBLE);
cartInfoLayout.setVisibility(View.VISIBLE);
}
else {
cartRecyclerView.setVisibility(View.GONE);
cartInfoLayout.setVisibility(View.GONE);
//cartFragmentMainLayout.setBackgroundColor(whiteColor);
noProductsOnCartTextView.setVisibility(View.VISIBLE);
}
}
private void removeProductFromCart(final int position){
DialogHelper.showLoadingDialog();
Call<ResponseObject<RemoveProductFromCartResponseModel>> call =
ApiService.apiInterface.removeProductFromCart(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_REMOVE_RPODUCT_FORM_CART + SessionHelper.getCustomerToken().getToken(),
getRemoveProductFromCartRequestParams(cartProductList.get(position).getCartId()));
call.enqueue(new Callback<ResponseObject<RemoveProductFromCartResponseModel>>() {
@Override
public void onResponse(Call<ResponseObject<RemoveProductFromCartResponseModel>> call, Response<ResponseObject<RemoveProductFromCartResponseModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
cartProductList.remove(position);
getCartItemCount();
/*
DialogHelper.showOneButtonDialogWithCallback(productRemovedFromCartText, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
SharedPrefsHelper.setCartItemCount(cartProductList.size());
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
mainActivity.setCartItemCount();
mainActivity.reopenCartFragment();
}
});
*/
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<RemoveProductFromCartResponseModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private HashMap<String, Object> getRemoveProductFromCartRequestParams(String cartProductId){
HashMap<String, Object> params = new HashMap<>();
params.put("key", cartProductId);
return params;
}
private void getCartItemCount(){
/*
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
*/
HashMap<String, Object> params = new HashMap<>();
if(SessionHelper.getSelectedCoupon() != null){
params.put("coupon", SessionHelper.getSelectedCoupon().getCode());
}
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
params);
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
@Override
public void onResponse(Call<ResponseObject<CartInfoModel>> call, final Response<ResponseObject<CartInfoModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
DialogHelper.showOneButtonDialogWithDismissListener(
productRemovedFromCartText,
new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
SharedPrefsHelper.setCartItemCount(response.body().getData().getProducts().size());
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(response.body().getData().getCartTotalModel().getText()));
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
mainActivity.setCartItemCount();
mainActivity.reopenCartFragment();
}
}
);
}
}
@Override
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
}
});
}
private void sortCartProducts(){
ArrayList<CartProductModel> tempCartProductList = new ArrayList<>();
// find margherita products
ArrayList<CartProductModel> margheritaPizzaCartProductModelList = new ArrayList<>(Collections2.filter(
cartProductList,
new Predicate<CartProductModel>() {
@Override
public boolean apply(CartProductModel cartProductModel) {
return cartProductModel.getName().toLowerCase().equals("margherita");
}
}
));
// remove margherita products from cartProductList
if(!margheritaPizzaCartProductModelList.isEmpty()){
cartProductList.removeAll(margheritaPizzaCartProductModelList);
}
// sort cartProductList alphebetically
Collections.sort(cartProductList, new Comparator<CartProductModel>() {
@Override
public int compare(CartProductModel cpm1, CartProductModel cpm2) {
return cpm1.getName().compareTo(cpm2.getName());
}
});
// add margherita products to temp tempCartProductList
if(!margheritaPizzaCartProductModelList.isEmpty()){
tempCartProductList.addAll(margheritaPizzaCartProductModelList);
}
tempCartProductList.addAll(cartProductList);
cartProductList.clear();
cartProductList.addAll(tempCartProductList);
}
private void checkPizzapassCampaign(){
ApiService
.apiInterface
.checkPizzapassCampaign(
SessionHelper.getSelectedStore().getStoreName(),
SessionHelper.getCustomerToken().getToken())
.enqueue(new Callback<ResponseObject<CampaignModel>>() {
@Override
public void onResponse(Call<ResponseObject<CampaignModel>> call, Response<ResponseObject<CampaignModel>> response) {
if(response.isSuccessful() &&
response.body() != null){
if(response.body().isSuccess()){
if(response.body().getData() == null){
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
else {
pizzapassCampaignCategoryId = response.body().getData().getCategoryId();
getCampaignProducts(response.body().getData(), true);
}
}
else {
checkKebappassCampaign();
}
}
else{
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<CampaignModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void showPizzapassCampaignDialog(final CampaignModel campaignModel){
DialogHelper.showTwoButtonsDialog(
campaignModel.getName(),
campaignModel.getDescription(),
R.string.accept_campaign,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent campaignIntent = new Intent(BaseActivity.currentActivity, CampaignProductListActivity.class);
campaignIntent.putExtra("campaignModel", campaignModel);
startActivityForResult(campaignIntent, REQUEST_CODE_CAMPAIGN_PRODUCT_LIST);
}
},
R.string.decline_campaign,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
DialogHelper.showLoadingDialog();
checkKebappassCampaign();
}
},
false
);
}
private void checkKebappassCampaign(){
ApiService
.apiInterface
.checkKebapPassCampaign(
SessionHelper.getSelectedStore().getStoreName(),
SessionHelper.getCustomerToken().getToken())
.enqueue(new Callback<ResponseObject<CampaignModel>>() {
@Override
public void onResponse(Call<ResponseObject<CampaignModel>> call, Response<ResponseObject<CampaignModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body() != null){
if(response.body().isSuccess()){
if(response.body().getData() == null){
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
else {
kebappassCampaignCategoryId = response.body().getData().getCategoryId();
getCampaignProducts(response.body().getData(), false);
}
}
/*
if(response.body().isSuccess() && !SessionHelper.isUserUsedKebappassCampaign()){
if(response.body().getData() == null){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
else {
response.body().getData().checkNull();
showKebappassCampaignDialog(response.body().getData());
}
}
*/
}
else{
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<CampaignModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void showKebappassCampaignDialog(final CampaignModel campaignModel){
DialogHelper.showTwoButtonsDialog(
campaignModel.getName(),
campaignModel.getDescription(),
R.string.accept_campaign,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent campaignIntent = new Intent(BaseActivity.currentActivity, CampaignProductListActivity.class);
campaignIntent.putExtra("campaignModel", campaignModel);
startActivityForResult(campaignIntent, REQUEST_CODE_CAMPAIGN_PRODUCT_LIST);
}
},
R.string.decline_campaign,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
}
},
false
);
}
private void getCampaignProducts(final CampaignModel campaignModel, final boolean isForPizzapass){
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductsByCategory(
SessionHelper.getSelectedStore().getStoreName(),
campaignModel.getCategoryId());
call.enqueue(new Callback<ResponseArray<MenuProductModel>>() {
@Override
public void onResponse(Call<ResponseArray<MenuProductModel>> call, Response<ResponseArray<MenuProductModel>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()) {
if(isBasketContainsCampaignProduct(response.body().getData())){
if(isForPizzapass){
checkKebappassCampaign();
}
else {
DialogHelper.hideLoadingDialog();
}
}
else {
DialogHelper.hideLoadingDialog();
if(isForPizzapass){
showPizzapassCampaignDialog(campaignModel);
}
else {
showKebappassCampaignDialog(campaignModel);
}
}
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<MenuProductModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void getCampaignProductsForPizzapassOnContinueButtonClicked(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductsByCategory(
SessionHelper.getSelectedStore().getStoreName(),
pizzapassCampaignCategoryId);
call.enqueue(new Callback<ResponseArray<MenuProductModel>>() {
@Override
public void onResponse(Call<ResponseArray<MenuProductModel>> call, Response<ResponseArray<MenuProductModel>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()) {
cartInfoModel.setPizzapassCampaignUsed(isBasketContainsCampaignProduct(response.body().getData()));
if(!kebappassCampaignCategoryId.isEmpty()){
getCampaignProductsForKebappassOnContinueButtonClicked();
}
else {
DialogHelper.hideLoadingDialog();
openCreateOrderActivity();
}
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<MenuProductModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void getCampaignProductsForKebappassOnContinueButtonClicked(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductsByCategory(
SessionHelper.getSelectedStore().getStoreName(),
kebappassCampaignCategoryId);
call.enqueue(new Callback<ResponseArray<MenuProductModel>>() {
@Override
public void onResponse(Call<ResponseArray<MenuProductModel>> call, Response<ResponseArray<MenuProductModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()) {
cartInfoModel.setKebappassCampaignUsed(isBasketContainsCampaignProduct(response.body().getData()));
openCreateOrderActivity();
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<MenuProductModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private boolean isBasketContainsCampaignProduct(ArrayList<MenuProductModel> campaignProductsList){
boolean isContains = false;
outerLoop:for(CartProductModel cartProductModel : cartProductList) {
for(MenuProductModel campaignProductModel : campaignProductsList){
if(cartProductModel.getProductId().equals(campaignProductModel.getId())){
isContains = true;
break outerLoop;
}
}
}
return isContains;
}
private void openCreateOrderActivity(){
Intent continueCartIntent = new Intent(BaseActivity.currentActivity, CreateOrderActivity.class);
continueCartIntent.putExtra("cartInfoModel", cartInfoModel);
startActivity(continueCartIntent);
}
}

View File

@@ -0,0 +1,159 @@
package ch.pizzacucina.android.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.MainActivity;
import ch.pizzacucina.android.activity.ProductDetailsActivity;
import ch.pizzacucina.android.adapter.recycler.MenuProductRecyclerAdapter;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.CategoryModel;
import ch.pizzacucina.android.model.menu.MenuProductModel;
import ch.pizzacucina.android.view.GridSpacesItemDecoration;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static android.app.Activity.RESULT_OK;
/**
* Created by cimenmus on 02/10/2017.
*/
public class MenuFragment extends BaseFragment {
@BindView(R.id.menuProductRecyclerView) RecyclerView menuProductRecyclerView;
public static final String FRAGMENT_NAME = "menuFragment";
private int REQUEST_CODE_PRODUCT_PROPERTIES = 3765;
private ArrayList<MenuProductModel> menuProductList = new ArrayList<>();
private MenuProductRecyclerAdapter menuProductRecyclerAdapter;
private CategoryModel categoryModel;
public MenuFragment() {}
public static MenuFragment newInstance(CategoryModel categoryModel) {
Bundle bundle = new Bundle();
bundle.putSerializable("categoryModel", categoryModel);
MenuFragment fragment = new MenuFragment();
fragment.setArguments(bundle);
return fragment;
}
@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_menu, container, false);
ButterKnife.bind(this, view);
getDataFromArguments();
initViews();
getProductsByCategory();
return view;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE_PRODUCT_PROPERTIES &&
resultCode == RESULT_OK &&
getActivity() != null &&
getActivity() instanceof MainActivity){
BaseActivity.currentActivity = (MainActivity)getActivity();
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
mainActivity.setCartItemCount();
}
}
private void getDataFromArguments(){
categoryModel = (CategoryModel) getArguments().getSerializable("categoryModel");
}
private void initViews(){
setPizzalinkToolbarFields(true, categoryModel.getName());
initRecyclerView();
}
private void initRecyclerView(){
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
menuProductRecyclerView.setLayoutManager(layoutManager);
menuProductRecyclerAdapter = new MenuProductRecyclerAdapter(
menuProductList,
categoryModel.isDescriptionVisible(),
new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductDetailsActivity.class);
productPropertiesIntent.putExtra("menuProductModel", menuProductList.get(position));
startActivityForResult(productPropertiesIntent, REQUEST_CODE_PRODUCT_PROPERTIES);
}
});
menuProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(2, 16, true));
menuProductRecyclerView.setAdapter(menuProductRecyclerAdapter);
}
private void getProductsByCategory(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductsByCategory(
SessionHelper.getSelectedStore().getStoreName(),
categoryModel.getCategoryIdString());
call.enqueue(new Callback<ResponseArray<MenuProductModel>>() {
@Override
public void onResponse(Call<ResponseArray<MenuProductModel>> call, Response<ResponseArray<MenuProductModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess())
fillAndNotifyProductList(response.body().getData());
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseArray<MenuProductModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyProductList(ArrayList<MenuProductModel> productList){
MenuProductModel.checkNull(productList);
menuProductList.clear();
menuProductList.addAll(productList);
sortProductsByName();
menuProductRecyclerAdapter.notifyDataSetChanged();
}
private void sortProductsByName(){
Collections.sort(menuProductList, new Comparator<MenuProductModel>() {
@Override
public int compare(MenuProductModel product1, MenuProductModel product2) {
return product1.getName().compareTo(product2.getName());
}
});
}
}

View File

@@ -0,0 +1,225 @@
package ch.pizzacucina.android.fragment;
import android.content.Intent;
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 java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.MainActivity;
import ch.pizzacucina.android.activity.OrderHistoryDetailsActivity;
import ch.pizzacucina.android.adapter.recycler.OrderHistoryRecyclerAdapter;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.history.OrderHistoryModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by cimenmus on 20/09/2017.
*/
public class OrderHistoryFragment extends BaseFragment {
@BindView(R.id.orderHistoryRecyclerView) RecyclerView orderHistoryRecyclerView;
@BindString(R.string.bottom_nav_menu_item_history) String fragmentTitle;
public static final java.lang.String FRAGMENT_NAME = "historyFragment";
private ArrayList<OrderHistoryModel> orderHistoryList = new ArrayList<>();
private OrderHistoryRecyclerAdapter orderHistoryRecyclerAdapter;
public OrderHistoryFragment() {}
public static OrderHistoryFragment newInstance() {
return new OrderHistoryFragment();
}
@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_history, container, false);
ButterKnife.bind(this, view);
initViews();
getOrderHistory();
return view;
}
private void initViews(){
setPizzalinkToolbarFields(false, fragmentTitle);
initRecyclerView();
}
private void initRecyclerView(){
orderHistoryRecyclerAdapter = new OrderHistoryRecyclerAdapter(orderHistoryList, new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
switch (view.getId()){
case R.id.repeatOrderTextView:
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);
orderHistoryRecyclerView.setLayoutManager(layoutManager);
orderHistoryRecyclerView.setAdapter(orderHistoryRecyclerAdapter);
}
// "cP1sbSmwc6GEE7fCy6du7KqRbkR7bY1q"
/*
private void getOrderHistory(){
DialogHelper.showLoadingDialog();
HashMap<String, Object> params = new HashMap<>();
params.put("token", SessionHelper.getCustomerToken().getToken());
Call<OrderHistoryResponseModel> call = ApiService.apiInterface.getOrderHistory(SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<OrderHistoryResponseModel>() {
@Override
public void onResponse(Call<OrderHistoryResponseModel> call, Response<OrderHistoryResponseModel> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body() != null &&
response.body().isSuccess()){
fillAndNotifyOrderHistoryList(response.body().getData());
}
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<OrderHistoryResponseModel> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
*/
private void getOrderHistory(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<OrderHistoryModel>> call = ApiService.apiInterface.
getOrderHistory(
SessionHelper.getSelectedStore().getStoreName(),
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseArray<OrderHistoryModel>>() {
@Override
public void onResponse(Call<ResponseArray<OrderHistoryModel>> call, Response<ResponseArray<OrderHistoryModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess())
fillAndNotifyOrderHistoryList(response.body().getData());
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseArray<OrderHistoryModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyOrderHistoryList(ArrayList<OrderHistoryModel> orderList){
OrderHistoryModel.checkNull(orderList);
orderHistoryList.clear();
orderHistoryList.addAll(orderList);
orderHistoryRecyclerAdapter.notifyDataSetChanged();
}
private void clearCart(final String orderId){
DialogHelper.showLoadingDialog();
Call<ResponseObject> call = ApiService.apiInterface.clearCart(
SessionHelper.getSelectedStore().getStoreName(),
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.setUserUsedKebappassCampaign(false);
MainActivity mainActivity = (MainActivity) BaseActivity.currentActivity;
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(
"/" + SessionHelper.getSelectedStore().getStoreName() + 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) BaseActivity.currentActivity;
mainActivity.openFragmentAt(2);
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
}

View File

@@ -0,0 +1,168 @@
package ch.pizzacucina.android.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.GridLayoutManager;
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.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.MainActivity;
import ch.pizzacucina.android.activity.ProductDetailsActivity;
import ch.pizzacucina.android.adapter.recycler.MenuProductRecyclerAdapter;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.CategoryModel;
import ch.pizzacucina.android.model.menu.MenuProductModel;
import ch.pizzacucina.android.view.GridSpacesItemDecoration;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static android.app.Activity.RESULT_OK;
/**
* Created by cimenmus on 19/09/2017.
*/
public class ProductFragment extends BaseFragment {
@BindView(R.id.customProductRecyclerView) RecyclerView customProductRecyclerView;
public static final String FRAGMENT_NAME = "productFragment";
private int REQUEST_CODE_PRODUCT_PROPERTIES = 3768;
private ArrayList<MenuProductModel> productList = new ArrayList<>();
private MenuProductRecyclerAdapter menuProductRecyclerAdapter;
private CategoryModel categoryModel;
public ProductFragment() {}
public static ProductFragment newInstance(CategoryModel categoryModel) {
Bundle bundle = new Bundle();
bundle.putSerializable("categoryModel", categoryModel);
ProductFragment fragment = new ProductFragment();
fragment.setArguments(bundle);
return fragment;
}
@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_product, container, false);
ButterKnife.bind(this, view);
getDataFromArguments();
initViews();
getProductById();
return view;
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
FragmentActivity fragmentActivity = getActivity();
if(requestCode == REQUEST_CODE_PRODUCT_PROPERTIES &&
resultCode == RESULT_OK &&
fragmentActivity instanceof MainActivity){
MainActivity mainActivity = (MainActivity) fragmentActivity;
BaseActivity.setCurrentActivity(mainActivity);
BaseActivity.setCurrentActivity((MainActivity) fragmentActivity);
mainActivity.setCartItemCount();
}
}
private void getDataFromArguments(){
categoryModel = (CategoryModel) getArguments().getSerializable("categoryModel");
}
private void initViews(){
setPizzalinkToolbarFields(true, categoryModel.getName());
initRecyclerView();
}
private void initRecyclerView(){
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
customProductRecyclerView.setLayoutManager(layoutManager);
menuProductRecyclerAdapter = new MenuProductRecyclerAdapter(
productList,
categoryModel.isDescriptionVisible(),
new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductDetailsActivity.class);
productPropertiesIntent.putExtra("menuProductModel", productList.get(position));
startActivityForResult(productPropertiesIntent, REQUEST_CODE_PRODUCT_PROPERTIES);
}
});
customProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(2, 16, true));
customProductRecyclerView.setAdapter(menuProductRecyclerAdapter);
}
private void getProductById(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductById(
SessionHelper.getSelectedStore().getStoreName(),
getProductIdByCategory());
call.enqueue(new Callback<ResponseArray<MenuProductModel>>() {
@Override
public void onResponse(Call<ResponseArray<MenuProductModel>> call, Response<ResponseArray<MenuProductModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess())
setProductFields(response.body().getData());
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseArray<MenuProductModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void setProductFields(ArrayList<MenuProductModel> prdctLst){
if(prdctLst == null || prdctLst.size() == 0)
return;
MenuProductModel.checkNull(prdctLst);
productList.clear();
productList.addAll(prdctLst);
menuProductRecyclerAdapter.notifyDataSetChanged();
}
private int getProductIdByCategory(){
String productIdString = "";
if(categoryModel.isSpecialCategory()){
productIdString = categoryModel.getSpecialProductId();
}
int productIdInt;
try{
productIdInt = Integer.valueOf(productIdString);
}catch (Exception e){
productIdInt = 0;
}
return productIdInt;
}
private void sortProductsByName(){
}
}

View File

@@ -0,0 +1,296 @@
package ch.pizzacucina.android.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.onesignal.OneSignal;
import org.json.JSONException;
import org.json.JSONObject;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.MyAddressesActivity;
import ch.pizzacucina.android.activity.SplashActivity;
import ch.pizzacucina.android.activity.UpdatePasswordActivity;
import ch.pizzacucina.android.activity.UpdateProfileActivity;
import ch.pizzacucina.android.api.ApiConstants;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.NetworkHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.model.UserModel;
import ch.pizzacucina.android.view.AppInfoView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static android.app.Activity.RESULT_OK;
/**
* Created by cimenmus on 18/09/2017.
*/
public class ProfileFragment extends BaseFragment {
@BindView(R.id.pizzapassCountPizzalinkInfoLayout) AppInfoView pizzapassCountPizzalinkInfoLayout;
@BindView(R.id.kebappassCountPizzalinkInfoLayout) AppInfoView kebappassCountPizzalinkInfoLayout;
@BindView(R.id.firstnamePizzalinkInfoLayout) AppInfoView firstnamePizzalinkInfoLayout;
@BindView(R.id.lastnamePizzalinkInfoLayout) AppInfoView lastnamePizzalinkInfoLayout;
@BindView(R.id.emailPizzalinkInfoLayout) AppInfoView emailPizzalinkInfoLayout;
@BindView(R.id.phonePizzalinkInfoLayout) AppInfoView phonePizzalinkInfoLayout;
@BindView(R.id.enableNotificationsSwitch) SwitchCompat enableNotificationsSwitch;
@BindString(R.string.bottom_nav_menu_item_profile) String fragmentTitle;
@BindString(R.string.alert_logout) String logoutAlertText;
@BindString(R.string.something_went_wrong) String genericErrorText;
public static final java.lang.String FRAGMENT_NAME = "profileFragment";
private int REQUEST_CODE_UPDATE_PROFILE = 2563;
private UserModel userModel;
public ProfileFragment() {}
public static ProfileFragment newInstance() {
return new ProfileFragment();
}
@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_profile, container, false);
ButterKnife.bind(this, view);
initViews();
getCustomerProfile();
getNotificationStatus();
return view;
}
@OnClick({R.id.myAddressesLayout, R.id.updatePasswordLayout,
R.id.updateProfileLayout, R.id.changePostCodeLayout,
R.id.logoutLayout})
public void onClick(View view){
switch (view.getId()){
case R.id.myAddressesLayout:
startActivity(new Intent(BaseActivity.currentActivity, MyAddressesActivity.class));
break;
case R.id.updateProfileLayout:
Intent updateProfileIntent = new Intent(BaseActivity.currentActivity, UpdateProfileActivity.class);
updateProfileIntent.putExtra("userModel", userModel);
startActivityForResult(updateProfileIntent, REQUEST_CODE_UPDATE_PROFILE);
break;
case R.id.updatePasswordLayout:
startActivity(new Intent(BaseActivity.currentActivity, UpdatePasswordActivity.class));
break;
case R.id.changePostCodeLayout:
BaseActivity.currentActivity.startActivity(new Intent(BaseActivity.currentActivity, SplashActivity.class));
BaseActivity.currentActivity.finishAffinity();
break;
case R.id.logoutLayout:
DialogHelper.showTwoButtonsDialog(BaseActivity.currentActivity, logoutAlertText,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
logOutOnWeb();
}
}, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
});
break;
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE_UPDATE_PROFILE &&
resultCode == RESULT_OK){
userModel = SessionHelper.getUser();
pizzapassCountPizzalinkInfoLayout.setText(userModel.getPizzapassCount());
kebappassCountPizzalinkInfoLayout.setText(userModel.getKebappassCount());
firstnamePizzalinkInfoLayout.setText(userModel.getFirstname());
lastnamePizzalinkInfoLayout.setText(userModel.getLastname());
emailPizzalinkInfoLayout.setText(userModel.getEmail());
phonePizzalinkInfoLayout.setText(userModel.getTelephone());
}
}
private void initViews(){
setPizzalinkToolbarFields(false, fragmentTitle);
enableNotificationsSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
setNotificationStatus();
}
});
}
private void getNotificationStatus(){
OneSignal.getTags(new OneSignal.GetTagsHandler() {
@Override
public void tagsAvailable(final JSONObject tags) {
BaseActivity.currentActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
if(tags != null &&
!tags.toString().isEmpty() &&
tags.toString().contains(ApiConstants.ONESIGNAL_NOTIFICATION_TAG_KEY)){
enableNotificationsSwitch.setChecked(true);
}
else {
enableNotificationsSwitch.setChecked(false);
}
}
});
}
});
}
private void setNotificationStatus(){
if(!NetworkHelper.isNetworkAvailable()){
DialogHelper.showNoNetworkDialog();
return;
}
DialogHelper.showLoadingDialog();
if(enableNotificationsSwitch.isChecked()) {
JSONObject tags = new JSONObject();
try {
tags.put(ApiConstants.ONESIGNAL_NOTIFICATION_TAG_KEY, ApiConstants.ONESIGNAL_NOTIFICATION_TAG_VALUE);
OneSignal.sendTags(tags, new OneSignal.ChangeTagsUpdateHandler() {
@Override
public void onSuccess(JSONObject tags) {
DialogHelper.hideLoadingDialog();
}
@Override
public void onFailure(OneSignal.SendTagsError error) {
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
});
}
catch (JSONException e){
e.printStackTrace();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
}
else {
OneSignal.deleteTag(
ApiConstants.ONESIGNAL_NOTIFICATION_TAG_KEY,
new OneSignal.ChangeTagsUpdateHandler() {
@Override
public void onSuccess(JSONObject tags) {
DialogHelper.hideLoadingDialog();
}
@Override
public void onFailure(OneSignal.SendTagsError error) {
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
}
);
}
}
private void getCustomerProfile(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<UserModel>> call = ApiService.apiInterface.getCustomerProfile(
SessionHelper.getSelectedStore().getStoreName(),
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseObject<UserModel>>() {
@Override
public void onResponse(Call<ResponseObject<UserModel>> call, Response<ResponseObject<UserModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
setFields(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<UserModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void setFields(UserModel user){
user.checkNull();
userModel = user;
SessionHelper.saveCustomer(userModel);
pizzapassCountPizzalinkInfoLayout.setText(userModel.getPizzapassCount());
kebappassCountPizzalinkInfoLayout.setText(userModel.getKebappassCount());
firstnamePizzalinkInfoLayout.setText(userModel.getFirstname());
lastnamePizzalinkInfoLayout.setText(userModel.getLastname());
emailPizzalinkInfoLayout.setText(userModel.getEmail());
phonePizzalinkInfoLayout.setText(userModel.getTelephone());
}
private void logOutOnWeb(){
DialogHelper.showLoadingDialog();
Call<ResponseObject> call = ApiService.apiInterface.logout(
SessionHelper.getSelectedStore().getStoreName(),
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseObject>() {
@Override
public void onResponse(Call<ResponseObject> call, Response<ResponseObject> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() && response.body().isSuccess())
logoutLocally();
else
ApiErrorUtils.parseError(response);
}
@Override
public void onFailure(Call<ResponseObject> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void logoutLocally(){
SharedPrefsHelper.clearCustomerInfo();
SharedPrefsHelper.clearCustomerToken();
SharedPrefsHelper.setCustomerLoggedIn(false);
SharedPrefsHelper.clearSelectedStore();
ApiService.getInstance().reset();
BaseActivity.currentActivity.startActivity(new Intent(BaseActivity.currentActivity, SplashActivity.class));
BaseActivity.currentActivity.finishAffinity();
}
}

View File

@@ -0,0 +1,125 @@
package ch.pizzacucina.android.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.model.StoreInfoModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by cimenmus on 18/09/2017.
*/
public class StoreInfoFragment extends BaseFragment {
@BindView(R.id.storeInfoWebView) WebView storeInfoWebView;
@BindString(R.string.bottom_nav_menu_item_info) String fragmentTitle;
public static final java.lang.String FRAGMENT_NAME = "infoFragment";
public StoreInfoFragment() {}
public static StoreInfoFragment newInstance() {
return new StoreInfoFragment();
}
@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_store_info, container, false);
ButterKnife.bind(this, view);
initViews();
getStoreInfo();
return view;
}
private void initViews(){
setPizzalinkToolbarFields(false, "");
}
private void getStoreInfo(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<StoreInfoModel>> call = ApiService.apiInterface.getStoreInfo(SessionHelper.getSelectedStore().getStoreName());
call.enqueue(new Callback<ResponseObject<StoreInfoModel>>() {
@Override
public void onResponse(Call<ResponseObject<StoreInfoModel>> call, Response<ResponseObject<StoreInfoModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.isSuccessful()){
initWebView(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<StoreInfoModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void initWebView(StoreInfoModel storeInfoModel) {
storeInfoModel.checkNull();
setPizzalinkToolbarFields(false, storeInfoModel.getTitle());
storeInfoWebView.setVerticalScrollBarEnabled(false);
storeInfoWebView.getSettings().setJavaScriptEnabled(true);
storeInfoWebView.loadDataWithBaseURL("", createFixedHTML(storeInfoModel.getContent()), "text/html", "UTF-8", "");
}
private String createFixedHTML(String html){
// bunu kullanırsan, layout dosyasındaki yorum satırını aktif yap
String header = "<head><style>img{display: inline; height: auto; max-width: 100%;} html, body { width:100%; height: 100%; margin: 0px; padding: 0px;}</style></head>";
//String header = "<head><style>img{display: inline; height: auto; max-width: 100%;} html, body { width:98%; height: 100%; margin-left: 4px; padding: 0px;}</style></head>";
//html = removeHs(html);
/*
String header = "<head>" +
" <meta http-equiv='content-type' content='text/html;'" +
" charset='UTF-8'>" +
" <style type='text/css'>" +
" " +
" @font-face {" +
" font-family: 'myfont';" +
" src: url('file:///android_asset/Resources/fonts/dosismedium.ttf');format('truetype'); " +
" }" +
" body { font-family:'myfont'; font-size: medium;}" +
" " +
" img{display: inline; height: auto; max-width: 100%;}" +
" </style>" +
" </head>";
*/
return "<html>" + header + "<body>" + html + "</body></html>";
}
}

View File

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

View File

@@ -0,0 +1,150 @@
package ch.pizzacucina.android.fragment.createOrder;
import android.os.Bundle;
import android.support.v7.widget.AppCompatRadioButton;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.CreateOrderActivity;
import ch.pizzacucina.android.api.ApiConstants;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
import ch.pizzacucina.android.model.cart.CartProductModel;
import ch.pizzacucina.android.view.AppEditText;
/**
* Created by cimenmus on 28.10.2017.
*/
public class CreateOrderNoteFragment extends CreateOrderBaseFragment {
@BindView(R.id.orderNotePizzalinkEditText)
AppEditText orderNoteAppEditText;
@BindView(R.id.slicePizzaLayout) LinearLayout slicePizzaLayout;
@BindView(R.id.yesRadioButton) AppCompatRadioButton yesRadioButton;
@BindView(R.id.noRadioButton) AppCompatRadioButton noRadioButton;
public static final java.lang.String FRAGMENT_NAME = "createOrderNoteFragment";
private CreateOrderActivity createOrderActivity;
public CreateOrderNoteFragment() {}
public static CreateOrderNoteFragment newInstance() {
return new CreateOrderNoteFragment();
}
@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_create_order_note, container, false);
ButterKnife.bind(this, view);
initViews();
return view;
}
@OnClick({R.id.yesLayout, R.id.noLayout,
R.id.previousTextView, R.id.nextTextView})
protected void onClick(View view){
switch (view.getId()){
case R.id.yesLayout:
yesRadioButton.setChecked(true);
noRadioButton.setChecked(false);
break;
case R.id.noLayout:
noRadioButton.setChecked(true);
yesRadioButton.setChecked(false);
break;
case R.id.previousTextView:
createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
break;
case R.id.nextTextView:
/*
if(isCartContainsAnyPizza(createOrderActivity.getCartInfo().getProducts())){
if(yesRadioButton.isChecked()){
createOrderActivity.setSlicePizza(true);
}
else {
createOrderActivity.setSlicePizza(false);
}
}
*/
createOrderActivity.setOrderNote(orderNoteAppEditText.getText());
createOrderActivity.onNextClicked(FRAGMENT_NAME);
break;
}
}
private void initViews(){
createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
/*
if(isCartContainsAnyPizza(createOrderActivity.getCartInfo().getProducts())){
slicePizzaLayout.setVisibility(View.VISIBLE);
if(createOrderActivity.getSlicePizza() != null){
if(createOrderActivity.getSlicePizza()){
yesRadioButton.setChecked(true);
noRadioButton.setChecked(false);
}
else {
noRadioButton.setChecked(true);
yesRadioButton.setChecked(false);
}
}
}
*/
int hintResId = R.string.order_note_title_for_free_shipping;
if(createOrderActivity.getSelectedShippingMethod().getCode().equals(ApiConstants.SHIPPING_METHOD_CODE_PICK_UP_FROM_STORE)){
hintResId = R.string.order_note_title_for_self_pickup;
}
orderNoteAppEditText.setHint(hintResId);
if(createOrderActivity.getOrderNote() != null){
orderNoteAppEditText.setText(createOrderActivity.getOrderNote());
}
}
private boolean isCartContainsAnyPizza(ArrayList<CartProductModel> cartProductList){
boolean containsAnyPizza = false;
outerloop:
for(CartProductModel cartProductModel : cartProductList){
if(SharedPrefsHelper.readPizzaCategoryIdList().contains(Integer.valueOf(cartProductModel.getProductId()))){
containsAnyPizza = true;
break;
}
for(String categoryId : cartProductModel.getCategoryList()){
if(SharedPrefsHelper.readPizzaCategoryIdList().contains(Integer.valueOf(categoryId))){
containsAnyPizza = true;
break outerloop;
}
}
}
return containsAnyPizza;
}
}
/*
StringBuilder stringBuilder = new StringBuilder();
if(SharedPrefsHelper.isCartContainsAnyPizza()){
stringBuilder.append(slicePizzaText).append(" : ");
if(yesRadioButton.isChecked()){
stringBuilder.append(yesText);
}
else {
stringBuilder.append(noText);
}
stringBuilder.append("<br/>");
}
stringBuilder.append(orderNotePizzalinkEditText.getText());
createOrderActivity.setOrderNote(stringBuilder.toString());
*/

View File

@@ -0,0 +1,59 @@
package ch.pizzacucina.android.fragment.createOrder;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.BindString;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.CreateOrderActivity;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
/**
* Created by cimenmus on 17/10/2017.
*/
public class CreateOrderResultFragment extends CreateOrderBaseFragment {
@BindString(R.string.done_order) String doneOrderText;
public static final java.lang.String FRAGMENT_NAME = "orderResultFragment";
public CreateOrderResultFragment() {}
public static CreateOrderResultFragment newInstance() {
return new CreateOrderResultFragment();
}
@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_create_order_result, container, false);
ButterKnife.bind(this, view);
initViews();
return view;
}
@OnClick( R.id.nextTextView)
protected void onClick(){
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
createOrderActivity.onNextClicked(FRAGMENT_NAME);
}
private void initViews(){
SharedPrefsHelper.setCartItemCount(0);
SharedPrefsHelper.setCartTotalPrice("0");
SessionHelper.clearSelectedCoupon();
previousTextView.setVisibility(View.GONE);
nextTextView.setText(doneOrderText);
}
}

View File

@@ -0,0 +1,312 @@
package ch.pizzacucina.android.fragment.createOrder;
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 android.widget.EditText;
import java.util.ArrayList;
import java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.CreateOrderActivity;
import ch.pizzacucina.android.adapter.recycler.PaymentMethodsRecyclerAdapter;
import ch.pizzacucina.android.api.ApiEndPoints;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseObject;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.CheckCouponModel;
import ch.pizzacucina.android.model.PaymentMethodModel;
import ch.pizzacucina.android.model.PaymentMethodsResponseModel;
import ch.pizzacucina.android.model.cart.CartInfoModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by cimenmus on 17/10/2017.
*/
public class PaymentMethodFragment extends CreateOrderBaseFragment {
@BindView(R.id.paymentMethodsRecyclerView) RecyclerView paymentMethodsRecyclerView;
@BindView(R.id.couponCodeEditText) EditText couponCodeEditText;
@BindString(R.string.app_name) String appName;
@BindString(R.string.alert_choose_payment_method) String choosePaymentMethodText;
@BindString(R.string.coupon_is_not_active) String couponIsNotActiveText;
@BindString(R.string.coupon_used_dialog_title) String couponUsedDialogTitle;
@BindString(R.string.coupon_used_dialog_content_part_1) String couponUsedDialogContentPart1;
@BindString(R.string.coupon_used_dialog_content_part_2) String couponUsedDialogContentPart2;
private ArrayList<PaymentMethodModel> paymentMethodList = new ArrayList<>();
private PaymentMethodsRecyclerAdapter paymentMethodsRecyclerAdapter;
private CheckCouponModel couponModel;
private PaymentMethodModel selectedPaymentMethod;
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();
return view;
}
@OnClick({R.id.previousTextView, R.id.nextTextView})
protected void onClick(View view){
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
switch (view.getId()){
case R.id.previousTextView:
createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
break;
case R.id.nextTextView:
if(selectedPaymentMethod == null){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, choosePaymentMethodText);
break;
}
if(couponCodeEditText.getText().toString().isEmpty()){
SessionHelper.clearSelectedCoupon();
createOrderActivity.setSelectedPaymentMethod(selectedPaymentMethod);
createOrderActivity.onNextClicked(FRAGMENT_NAME);
}
else {
createOrderActivity.setCouponCode(couponCodeEditText.getText().toString());
checkCoupon();
}
break;
}
}
private void initViews(){
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
if(createOrderActivity.getCouponCode() != null){
couponCodeEditText.setText(createOrderActivity.getCouponCode());
}
initRecyclerView();
}
private void getPaymentMethods(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<PaymentMethodsResponseModel>> call = ApiService.apiInterface.getPaymentMethods(
SessionHelper.getSelectedStore().getStoreName(),
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseObject<PaymentMethodsResponseModel>>() {
@Override
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().getPaymentMethodsList());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<PaymentMethodsResponseModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyAdapter(ArrayList<PaymentMethodModel> paymentMethodModels){
PaymentMethodModel.checkNull(paymentMethodModels);
for(PaymentMethodModel paymentMethodModel : paymentMethodModels){
if(paymentMethodModel.getPaymentMethodType() == PaymentMethodModel.PaymentMethodType.APPLE_PAY){
paymentMethodModels.remove(paymentMethodModel);
break;
}
}
for(PaymentMethodModel paymentMethodModel : paymentMethodModels){
if(paymentMethodModel.getPaymentMethodType() == PaymentMethodModel.PaymentMethodType.ANDROID_PAY){
paymentMethodModels.remove(paymentMethodModel);
break;
}
}
for(PaymentMethodModel paymentMethodModel : paymentMethodModels){
if(paymentMethodModel.getPaymentMethodType() == PaymentMethodModel.PaymentMethodType.TWINT){
paymentMethodModels.remove(paymentMethodModel);
break;
}
}
/*
// dummy //
PaymentMethodModel paypal = new PaymentMethodModel();
paypal.setCode(ApiConstants.PAYMENT_METHOD_CODE_PAYPAL);
paypal.setTitle("PAYPAL");
paypal.setSortOrder("0");
paymentMethodModels.add(paypal);
*/
/*
// dummy //
PaymentMethodModel androidPay = new PaymentMethodModel();
androidPay.setCode(ApiConstants.PAYMENT_METHOD_CODE_ANDROID_PAY);
androidPay.setTitle("Android Pay");
androidPay.setSortOrder("0");
paymentMethodModels.add(androidPay);
*/
PaymentMethodModel.sort(paymentMethodModels);
paymentMethodList.clear();
paymentMethodList.addAll(paymentMethodModels);
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
if(paymentMethodList.size() != 0){
if(createOrderActivity.getSelectedPaymentMethod() == null){
paymentMethodList.get(0).setSelected(true);
selectedPaymentMethod = paymentMethodList.get(0);
}
else {
for(PaymentMethodModel paymentMethodModel : paymentMethodModels){
if(paymentMethodModel.getCode().equals(createOrderActivity.getSelectedPaymentMethod().getCode())){
paymentMethodModel.setSelected(true);
selectedPaymentMethod = paymentMethodModel;
break;
}
}
}
}
createOrderActivity.setPaymentMethodList(paymentMethodList);
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);
selectedPaymentMethod = paymentMethodList.get(position);
paymentMethodsRecyclerAdapter.notifyDataSetChanged();
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
paymentMethodsRecyclerView.setLayoutManager(layoutManager);
paymentMethodsRecyclerView.setAdapter(paymentMethodsRecyclerAdapter);
}
private void checkCoupon(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<CheckCouponModel>> call =
ApiService.apiInterface.checkCoupon(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_CHECK_COUPON + SessionHelper.getCustomerToken().getToken(),
couponCodeEditText.getText().toString());
call.enqueue(new Callback<ResponseObject<CheckCouponModel>>() {
@Override
public void onResponse(Call<ResponseObject<CheckCouponModel>> call, Response<ResponseObject<CheckCouponModel>> response) {
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
couponModel = response.body().getData();
couponModel.setStoreName(SessionHelper.getSelectedStore().getStoreName());
couponModel.checkNull();
if(couponModel.isActive()){
SessionHelper.saveSelectedCoupon(couponModel);
DialogHelper.showDialogWithPositiveButton(
couponUsedDialogTitle,
BaseActivity.currentActivity,
couponUsedDialogContentPart1 + " " + couponModel.getName() + " " + couponUsedDialogContentPart2);
getCartProducts();
}
else {
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, couponIsNotActiveText);
}
}
else {
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<CheckCouponModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void getCartProducts(){
/*
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProductsWithCoupon(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
couponModel.getCode());
*/
HashMap<String, Object> params = new HashMap<>();
params.put("coupon", couponModel.getCode());
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
"/" + SessionHelper.getSelectedStore().getStoreName() + ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken(),
params);
call.enqueue(new Callback<ResponseObject<CartInfoModel>>() {
@Override
public void onResponse(Call<ResponseObject<CartInfoModel>> call, Response<ResponseObject<CartInfoModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
CartInfoModel cartInfoModel = response.body().getData();
cartInfoModel.checkNull();
createOrderActivity.setCartInfoSafeForCampaigns(cartInfoModel);
createOrderActivity.setSelectedPaymentMethod(selectedPaymentMethod);
createOrderActivity.onNextClicked(FRAGMENT_NAME);
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
}

View File

@@ -0,0 +1,226 @@
package ch.pizzacucina.android.fragment.createOrder;
import android.content.Intent;
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 android.widget.Button;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.AddAddressActivity;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.CreateOrderActivity;
import ch.pizzacucina.android.adapter.recycler.ShippingAddressesRecyclerAdapter;
import ch.pizzacucina.android.api.ApiConstants;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.AddressModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static android.app.Activity.RESULT_OK;
/**
* Created by cimenmus on 17/10/2017.
*/
public class ShippingAddressFragment extends CreateOrderBaseFragment {
@BindView(R.id.shippingAddressesRecyclerView) RecyclerView shippingAddressesRecyclerView;
@BindView(R.id.addNewAddressButton) Button addNewAddressButton;
@BindString(R.string.alert_choose_shipping_address) String chooseShippingAddressText;
private ArrayList<AddressModel> addressList = new ArrayList<>();
private ShippingAddressesRecyclerAdapter shippingAddressesRecyclerAdapter;
private AddressModel selectedAddress;
private int REQUEST_CODE_ADD_NEW_ADDRESS = 2350;
private boolean needToSortAddresses;
private String newAddressId = "";
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;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE_ADD_NEW_ADDRESS &&
resultCode == RESULT_OK){
newAddressId = data.getStringExtra("newAddressId");
getCustomerShippingAddresses();
}
}
@OnClick({R.id.addNewAddressButton, R.id.previousTextView, R.id.nextTextView})
protected void onClick(View view){
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
switch (view.getId()){
case R.id.addNewAddressButton:
Intent addNewAddressIntent = new Intent(BaseActivity.currentActivity,
AddAddressActivity.class);
startActivityForResult(addNewAddressIntent, REQUEST_CODE_ADD_NEW_ADDRESS);
break;
case R.id.previousTextView:
createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
break;
case R.id.nextTextView:
if(selectedAddress == null){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, chooseShippingAddressText);
return;
}
createOrderActivity.setSelectedShippingAddress(selectedAddress);
createOrderActivity.onNextClicked(FRAGMENT_NAME);
break;
}
}
private void initViews(){
initRecyclerView();
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
if(createOrderActivity.getSelectedShippingMethod().getCode().toLowerCase().equals(ApiConstants.SHIPPING_METHOD_CODE_PICK_UP_FROM_STORE)){
addNewAddressButton.setText(R.string.add_new_shipping_address_for_self_pick_up);
}
else {
addNewAddressButton.setText(R.string.add_new_shipping_address_for_free_shipping);
}
}
private void getCustomerShippingAddresses(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<AddressModel>> call = ApiService.apiInterface.getCustomerAddresses(
SessionHelper.getSelectedStore().getStoreName(),
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);
if(addressList.size() != 0){
sortAddresses();
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
if(!newAddressId.isEmpty()){
for(AddressModel addressModel : addressModels){
if(addressModel.getId().equals(newAddressId)){
addressModel.setSelected(true);
selectedAddress = addressModel;
createOrderActivity.setSelectedShippingAddress(addressModel);
break;
}
}
}
else if(createOrderActivity.getSelectedShippingAddress() == null){
addressList.get(0).setSelected(true);
selectedAddress = addressList.get(0);
}
else {
for(AddressModel addressModel : addressModels){
if(addressModel.getId().equals(createOrderActivity.getSelectedShippingAddress().getId())){
addressModel.setSelected(true);
selectedAddress = addressModel;
break;
}
}
}
}
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);
selectedAddress = addressList.get(position);
shippingAddressesRecyclerAdapter.notifyDataSetChanged();
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
shippingAddressesRecyclerView.setLayoutManager(layoutManager);
shippingAddressesRecyclerView.setAdapter(shippingAddressesRecyclerAdapter);
}
private void sortAddresses(){
Collections.sort(
addressList,
new Comparator<AddressModel>() {
@Override
public int compare(AddressModel a1, AddressModel a2) {
try {
int id1 = Integer.parseInt(a1.getId());
int id2 = Integer.parseInt(a2.getId());
return id2 - id1;
}catch (Exception e){
return a2.getId().compareTo(a1.getId());
}
}
}
);
}
}

View File

@@ -0,0 +1,163 @@
package ch.pizzacucina.android.fragment.createOrder;
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 android.widget.TextView;
import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.CreateOrderActivity;
import ch.pizzacucina.android.adapter.recycler.ShippingMethodsRecyclerAdapter;
import ch.pizzacucina.android.api.ApiErrorUtils;
import ch.pizzacucina.android.api.ApiService;
import ch.pizzacucina.android.api.ResponseArray;
import ch.pizzacucina.android.helper.DialogHelper;
import ch.pizzacucina.android.helper.PriceHelper;
import ch.pizzacucina.android.helper.SessionHelper;
import ch.pizzacucina.android.interfaces.RecyclerItemClickListener;
import ch.pizzacucina.android.model.ShippingMethodModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by cimenmus on 17/10/2017.
*/
public class ShippingMethodFragment extends CreateOrderBaseFragment {
@BindView(R.id.shipmentMethodInfoTextView) TextView shipmentMethodInfoTextView;
@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 ShippingMethodModel selectedShippingMethodModel;
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();
return view;
}
@OnClick(R.id.nextTextView)
protected void onClick(){
if(selectedShippingMethodModel == null){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, chooseShippingMethodText);
return;
}
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
createOrderActivity.setSelectedShippingMethod(selectedShippingMethodModel);
createOrderActivity.onNextClicked(FRAGMENT_NAME);
}
private void initViews(){
String shipmentMethodInfoText =
getString(R.string.shipping_method_info) +
" " +
PriceHelper.getPriceWithCurreny(SessionHelper.getSelectedStore().getMinimumPrice());
shipmentMethodInfoTextView.setText(shipmentMethodInfoText);
initRecyclerView();
previousTextView.setVisibility(View.GONE);
}
private void getShippingMethods(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<ShippingMethodModel>> call = ApiService.apiInterface.getShippingMethods(
SessionHelper.getSelectedStore().getStoreName(),
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);
if(shippingMethodList.size() != 0){
CreateOrderActivity createOrderActivity = (CreateOrderActivity) BaseActivity.currentActivity;
if(createOrderActivity.getSelectedShippingMethod() == null){
shippingMethodList.get(0).setSelected(true);
selectedShippingMethodModel = shippingMethodList.get(0);
}
else {
for(ShippingMethodModel shippingMethodModel : shippingMethodModels){
if(shippingMethodModel.getCode().equals(createOrderActivity.getSelectedShippingMethod().getCode())){
shippingMethodModel.setSelected(true);
selectedShippingMethodModel = shippingMethodModel;
break;
}
}
}
}
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);
selectedShippingMethodModel = shippingMethodList.get(position);
shippingMethodsRecyclerAdapter.notifyDataSetChanged();
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
shippingMethodsRecyclerView.setLayoutManager(layoutManager);
shippingMethodsRecyclerView.setAdapter(shippingMethodsRecyclerAdapter);
}
}

View File

@@ -0,0 +1,78 @@
package ch.pizzacucina.android.helper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
/**
* Created by cimenmus on 04/10/2017.
*/
public class DateTimeHelper {
public static long getMillisFromDateString(String dateString){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = null;
try {
Date date = formatter.parse(dateString);
calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.getTimeInMillis();
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public static String getFormattedDateFromDateString(String dateString){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = null;
try {
Date date = formatter.parse(dateString);
calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.DAY_OF_MONTH) + " " +
getMonthName(calendar.get(Calendar.MONTH)) + " " +
calendar.get(Calendar.YEAR);
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
private static String getMonthName(int monthIndex){
switch (monthIndex){
case 0:
return BaseActivity.currentActivity.getString(R.string.month_name_january);
case 1:
return BaseActivity.currentActivity.getString(R.string.month_name_february);
case 2:
return BaseActivity.currentActivity.getString(R.string.month_name_march);
case 3:
return BaseActivity.currentActivity.getString(R.string.month_name_april);
case 4:
return BaseActivity.currentActivity.getString(R.string.month_name_may);
case 5:
return BaseActivity.currentActivity.getString(R.string.month_name_jun);
case 6:
return BaseActivity.currentActivity.getString(R.string.month_name_july);
case 7:
return BaseActivity.currentActivity.getString(R.string.month_name_august);
case 8:
return BaseActivity.currentActivity.getString(R.string.month_name_september);
case 9:
return BaseActivity.currentActivity.getString(R.string.month_name_october);
case 10:
return BaseActivity.currentActivity.getString(R.string.month_name_november);
case 11:
return BaseActivity.currentActivity.getString(R.string.month_name_december);
default:
return "";
}
}
}

View File

@@ -0,0 +1,397 @@
package ch.pizzacucina.android.helper;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.activity.LoginActivity;
import ch.pizzacucina.android.activity.RegisterActivity;
public class DialogHelper {
private static MaterialDialog loadingDialog;
public static void showDialogWithPositiveButton(Context context, String message) {
showDialogWithPositiveButton("", context, message);
}
public static void showDialogWithPositiveButton(String title, Context context, String message) {
if(title.isEmpty())
title = context.getString(R.string.app_name);
new MaterialDialog.Builder(context)
.title(title)
.content(message)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.ok)
.positiveColor(ContextCompat.getColor(context, R.color.colorPrimary))
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
//BaseActivity.currentActivity.onBackPressed();
dialog.dismiss();
}
})
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showAlertDialog(Context context, String content) {
if(context == null)
return;
new MaterialDialog.Builder(context)
.title(R.string.alert)
.content(content)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.ok)
.positiveColor(ContextCompat.getColor(context, R.color.colorPrimary))
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showFailedDialog() {
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(R.string.alert)
.content(BaseActivity.currentActivity.getString(R.string.failed))
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.ok)
.positiveColor(ContextCompat.getColor(BaseActivity.currentActivity, R.color.colorPrimary))
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showNoNetworkDialog() {
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(R.string.alert)
.content(BaseActivity.currentActivity.getString(R.string.no_network_message))
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.ok)
.positiveColor(ContextCompat.getColor(BaseActivity.currentActivity, R.color.colorPrimary))
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
BaseActivity.currentActivity.finishAffinity();
}
})
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showLoadingDialog(){
if(loadingDialog != null && loadingDialog.isShowing())
return;
loadingDialog = new MaterialDialog.Builder(BaseActivity.currentActivity)
.content(BaseActivity.currentActivity.getString(R.string.loading))
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.cancelable(false)
.progress(true, 0)
.progressIndeterminateStyle(true)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void hideLoadingDialog(){
if(loadingDialog != null && loadingDialog.isShowing()){
loadingDialog.dismiss();
loadingDialog = null;
}
}
public static void showTwoButtonsDialog(Context context, String message,
MaterialDialog.SingleButtonCallback positiveButtonCallback,
MaterialDialog.SingleButtonCallback negativeButtonCallback){
showTwoButtonsDialog(
context,
message,
R.string.ok,
positiveButtonCallback,
R.string.cancel,
negativeButtonCallback);
}
public static void showTwoButtonsDialog(Context context,
String message,
int positiveTextResId,
MaterialDialog.SingleButtonCallback positiveButtonCallback,
int negativeTextResId,
MaterialDialog.SingleButtonCallback negativeButtonCallback){
new MaterialDialog.Builder(context)
.title(R.string.alert)
.content(message)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(positiveTextResId)
.onPositive(positiveButtonCallback)
.negativeText(negativeTextResId)
.onNegative(negativeButtonCallback)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showTwoButtonsDialog(String title,
String message,
int positiveTextResId,
MaterialDialog.SingleButtonCallback positiveButtonCallback,
int negativeTextResId,
MaterialDialog.SingleButtonCallback negativeButtonCallback){
showTwoButtonsDialog(
title,
message,
positiveTextResId,
positiveButtonCallback,
negativeTextResId,
negativeButtonCallback,
true);
}
public static void showTwoButtonsDialog(String title,
String message,
int positiveTextResId,
MaterialDialog.SingleButtonCallback positiveButtonCallback,
int negativeTextResId,
MaterialDialog.SingleButtonCallback negativeButtonCallback,
boolean isCancelable){
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(title)
.content(message)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(positiveTextResId)
.onPositive(positiveButtonCallback)
.negativeText(negativeTextResId)
.onNegative(negativeButtonCallback)
.cancelable(isCancelable)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showTwoButtonsDialog(String title,
String message,
int positiveTextResId,
MaterialDialog.SingleButtonCallback positiveButtonCallback,
int negativeTextResId,
MaterialDialog.SingleButtonCallback negativeButtonCallback,
boolean isCancelable,
boolean isButtonTextSmallCaps){
MaterialDialog materialDialog =
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(title)
.content(message)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(positiveTextResId)
.onPositive(positiveButtonCallback)
.negativeText(negativeTextResId)
.onNegative(negativeButtonCallback)
.cancelable(isCancelable)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.build();
materialDialog.getActionButton(DialogAction.POSITIVE).setAllCaps(!isButtonTextSmallCaps);
materialDialog.getActionButton(DialogAction.NEGATIVE).setAllCaps(!isButtonTextSmallCaps);
materialDialog.getActionButton(DialogAction.NEUTRAL).setAllCaps(!isButtonTextSmallCaps);
materialDialog.show();
}
public static void showNeedToLoginDialog(int messageResourceId){
MaterialDialog dialog = new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(R.string.alert)
.content(BaseActivity.currentActivity.getString(messageResourceId))
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.button_login)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent loginIntent = new Intent(BaseActivity.currentActivity, LoginActivity.class);
loginIntent.putExtra("showBackIcon", true);
BaseActivity.currentActivity.startActivity(loginIntent);
}
})
.negativeText(R.string.register_text)
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
BaseActivity.currentActivity.startActivity(new Intent(BaseActivity.currentActivity, RegisterActivity.class));
}
})
.neutralText(R.string.cancel_all_caps)
//.onNeutral()
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.build();
dialog.getActionButton(DialogAction.POSITIVE).setTextSize(12);
dialog.getActionButton(DialogAction.NEGATIVE).setTextSize(12);
dialog.getActionButton(DialogAction.NEUTRAL).setTextSize(12);
dialog.show();
}
public static void showUpdateAppDialog(Context context) {
new MaterialDialog.Builder(context)
.title(R.string.alert)
.content(R.string.alert_update_app)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.update_app)
.positiveColor(ContextCompat.getColor(context, R.color.colorPrimary))
.cancelable(false)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=ch.pizzacucina.android"));
BaseActivity.currentActivity.startActivity(intent);
BaseActivity.currentActivity.finishAffinity();
}
})
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showOneButtonDialogWithCallback(String message,
MaterialDialog.SingleButtonCallback singleButtonCallback){
showOneButtonDialogWithCallback(message, singleButtonCallback, true);
}
public static void showOneButtonDialogWithCallback(String message,
MaterialDialog.SingleButtonCallback singleButtonCallback,
boolean cancelable){
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(R.string.app_name)
.content(message)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.ok)
.onPositive(singleButtonCallback)
.cancelable(cancelable)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showOneButtonDialogWithCallback(String title,
String message,
String positiveButtonText,
MaterialDialog.SingleButtonCallback singleButtonCallback,
boolean cancelable,
boolean isButtonTextSmallCaps){
MaterialDialog materialDialog =
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(title)
.content(message)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(positiveButtonText)
.onPositive(singleButtonCallback)
.cancelable(cancelable)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.build();
materialDialog.getActionButton(DialogAction.POSITIVE).setAllCaps(!isButtonTextSmallCaps);
materialDialog.getActionButton(DialogAction.NEGATIVE).setAllCaps(!isButtonTextSmallCaps);
materialDialog.getActionButton(DialogAction.NEUTRAL).setAllCaps(!isButtonTextSmallCaps);
materialDialog.show();
}
public static void showOneButtonDialogWithDismissListener(String message,
DialogInterface.OnDismissListener dismissListener){
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(R.string.app_name)
.content(message)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.ok)
.dismissListener(dismissListener)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
/*
public static void showPasswordResetDialog(final Context context) {
new MaterialDialog.Builder(context)
.title(R.string.app_name)
.content(R.string.password_reset)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.ok)
.positiveColor(ContextCompat.getColor(context, R.color.colorPrimary))
.cancelable(false)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent(context, LoginActivity.class);
BaseActivity.currentActivity.startActivity(intent);
BaseActivity.currentActivity.finishAffinity();
}
})
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showProfileUpdatedDialog(MaterialDialog.SingleButtonCallback singleButtonCallback) {
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(R.string.app_name)
.content(R.string.profile_updated)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.positiveText(R.string.ok)
.cancelable(false)
.onPositive(singleButtonCallback)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
*/
public static void showListDialog(ArrayList<String> itemList, MaterialDialog.ListCallback listCallback){
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(R.string.choose)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.items(itemList)
.itemsCallback(listCallback)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showStoreListDialog(ArrayList<String> itemList,
MaterialDialog.ListCallback listCallback){
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(R.string.choose_store)
.titleColorRes(R.color.red)
.contentColorRes(R.color.black)
.items(itemList)
.itemsCallback(listCallback)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
}

View File

@@ -0,0 +1,44 @@
package ch.pizzacucina.android.helper;
import android.annotation.TargetApi;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
public class DisplayHelper {
public static int getScreenWidthInPixel(){
DisplayMetrics displayMetrics = BaseActivity.currentActivity.getResources().getDisplayMetrics();
return displayMetrics.widthPixels;
}
public static int getScreenHeightInPixel(){
DisplayMetrics displayMetrics = BaseActivity.currentActivity.getResources().getDisplayMetrics();
return displayMetrics.heightPixels;
}
public static int dpToPx(int dp) {
DisplayMetrics displayMetrics = BaseActivity.currentActivity.getResources().getDisplayMetrics();
return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
}
public static int pxToDp(int px) {
DisplayMetrics displayMetrics = BaseActivity.currentActivity.getResources().getDisplayMetrics();
return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void changeStatusColor() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return;
Window window = BaseActivity.currentActivity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(BaseActivity.currentActivity, R.color.main_black));
}
}

View File

@@ -0,0 +1,25 @@
package ch.pizzacucina.android.helper;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
import ch.pizzacucina.android.activity.BaseActivity;
public class ImageLoadHelper {
public static void loadImage(ImageView imageView, String url){
if(url == null || url.isEmpty())
url = "empty";
Picasso.with(BaseActivity.currentActivity)
.load(url)
//.placeholder(R.drawable.placeholder)
//.placeholder(R.drawable.progress_animation)
//.error(R.drawable.placeholder)
//.resize(500, 0)
//.onlyScaleDown()
.into(imageView);
}
}

View File

@@ -0,0 +1,27 @@
package ch.pizzacucina.android.helper;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import ch.pizzacucina.android.activity.BaseActivity;
public class NetworkHelper {
public static boolean isNetworkAvailable(){
ConnectivityManager connectivityManager = (ConnectivityManager) BaseActivity.currentActivity.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo == null)
return false;
else if (!activeNetworkInfo.isConnected())
return false;
else if (!activeNetworkInfo.isAvailable())
return false;
return true;
}
}

View File

@@ -0,0 +1,18 @@
package ch.pizzacucina.android.helper;
import java.util.regex.Pattern;
public class PasswordHelper {
public static final Pattern EMAIL_ADDRESS_PATTERN = Pattern.compile(
"[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +
"\\@" +
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
"(" +
"\\." +
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
")+"
);
public static final Pattern PASSWORD_PATTERN = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$");
}

View File

@@ -0,0 +1,141 @@
package ch.pizzacucina.android.helper;
import java.util.ArrayList;
import ch.pizzacucina.android.R;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.model.menu.MenuProductModel;
import ch.pizzacucina.android.model.menu.MenuProductOptionValueModel;
/**
* Created by cimenmus on 12/10/2017.
*/
public class PriceHelper {
public static String getPriceWithCurreny(String price){
price = roundFractions(price);
return BaseActivity.currentActivity.getString(R.string.chf) + " " + price;
}
public static String getPriceWithCurreny(Double price){
String priceString = roundFractions(String.valueOf(price));
return BaseActivity.currentActivity.getString(R.string.chf) + " " + priceString;
}
public static String getPriceWithCurrenyAndFractions(Double price){
return BaseActivity.currentActivity.getString(R.string.chf) + " " + price;
}
public static String removeCurrencyFromPrice(String priceWithCurreny){
/*
try {
String currencyText = BaseActivity.currentActivity.getString(R.string.chf);
String priceWithoutCurrency = priceWithCurreny.replace(currencyText, "");
priceWithoutCurrency = priceWithoutCurrency.trim();
return priceWithoutCurrency;
}catch (Exception e){
return priceWithCurreny.trim();
}
*/
String currencyText = BaseActivity.currentActivity.getString(R.string.chf);
String priceWithoutCurrency = priceWithCurreny.replace(currencyText, "");
priceWithoutCurrency = priceWithoutCurrency.trim();
return priceWithoutCurrency;
}
public static String calculatePriceAfterCountChanged(String oldPriceString, int oldCount, int newCount){
Double oldPrice = stringToDouble(removeCurrencyFromPrice(oldPriceString));
Double productOldPrice = oldPrice / oldCount;
Double productNewPrice = productOldPrice * newCount;
return getPriceWithCurreny(productNewPrice);
}
public static String calculatePriceAfterRadioOptionValueChanged(int count,
MenuProductModel menuProductModel,
MenuProductOptionValueModel menuProductOptionValueModel){
Double productPrice = stringToDouble(menuProductModel.getPrice());
switch (menuProductOptionValueModel.getPrice_prefix()){
case "+":
productPrice += stringToDouble(menuProductOptionValueModel.getPrice());
break;
case "-":
productPrice -= stringToDouble(menuProductOptionValueModel.getPrice());
break;
}
return getPriceWithCurreny(productPrice * count);
}
public static String calculatePriceAfterCheckboxOptionValueChanged(int count,
MenuProductModel menuProductModel,
ArrayList<MenuProductOptionValueModel> menuProductOptionValueModelList){
Double productPrice = stringToDouble(menuProductModel.getPrice());
for(MenuProductOptionValueModel menuProductOptionValueModel : menuProductOptionValueModelList){
if(menuProductOptionValueModel.isSelected()){
switch (menuProductOptionValueModel.getPrice_prefix()){
case "+":
productPrice += stringToDouble(menuProductOptionValueModel.getPrice());
break;
case "-":
productPrice -= stringToDouble(menuProductOptionValueModel.getPrice());
break;
}
}
}
return getPriceWithCurreny(productPrice * count);
}
public static String getProductOptionPriceText(MenuProductOptionValueModel productOptionValueModel){
return new StringBuilder()
.append(productOptionValueModel.getPrice_prefix())
.append(" ")
.append(BaseActivity.currentActivity.getString(R.string.chf))
.append(" ")
.append(roundFractions(productOptionValueModel.getPrice()))
.toString();
}
public static Double stringToDouble(String string){
string = addFractions(string);
Double dbl = Double.valueOf(string);
return Math.floor(dbl * 100) / 100;
}
public static String roundFractions(String price){
if(price.equals("0")){
price = "0.-";
}
if(price.endsWith(".0")){
price = price.replace(".0", ".-");
}
else if(price.endsWith(".00")){
price = price.replace(".00", ".-");
}
else if(price.endsWith(".000")){
price = price.replace(".000", ".-");
}
else if(price.endsWith(".0000")){
price = price.replace(".0000", ".-");
}
return price;
}
private static String addFractions(String price){
if(price.endsWith(".-")){
price = price.replace(".-", ".00");
}
return price;
}
}

View File

@@ -0,0 +1,103 @@
package ch.pizzacucina.android.helper;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import ch.pizzacucina.android.model.CheckCouponModel;
import ch.pizzacucina.android.model.CustomerTokenModel;
import ch.pizzacucina.android.model.StoreModel;
import ch.pizzacucina.android.model.UserModel;
/**
* Created by cimenmus on 11/09/2017.
*/
public class SessionHelper {
public static void saveCustomer(UserModel user){
SharedPrefsHelper.saveUser(user);
}
public static UserModel getUser(){
return SharedPrefsHelper.getUser();
}
public static void clearCustomerInfo(){
SharedPrefsHelper.clearCustomerInfo();
}
public static void saveCustomerToken(CustomerTokenModel customerToken){
SharedPrefsHelper.saveCustomerToken(customerToken);
}
public static CustomerTokenModel getCustomerToken(){
return SharedPrefsHelper.getCustomerToken();
}
public static void clearCustomerToken(){
SharedPrefsHelper.clearCustomerToken();
}
public static void setCustomerLoggedIn(boolean loggedId){
SharedPrefsHelper.setCustomerLoggedIn(loggedId);
}
public static boolean isCustomerLoggedIn(){
return SharedPrefsHelper.isCustomerLoggedIn() &&
SharedPrefsHelper.getCustomerToken().getStoreOfToken().getStoreName().toLowerCase().equals(
SharedPrefsHelper.getSelectedStore().getStoreName().toLowerCase());
}
public static void setSelectedStore(StoreModel storeModel){
SharedPrefsHelper.saveSelectedStore(storeModel);
}
public static StoreModel getSelectedStore(){
StoreModel selectedStore = SharedPrefsHelper.getSelectedStore();
return selectedStore;
//return SharedPrefsHelper.getSelectedStore();
}
public static void setIsFirstTime(boolean isFirstTime){
SharedPrefsHelper.setIsFirstTime(isFirstTime);
}
public static boolean isFirstTime(){
return SharedPrefsHelper.isFirstTime();
}
public static void logOut(){
setCustomerLoggedIn(false);
clearCustomerToken();
clearCustomerInfo();
}
public static void saveSelectedCoupon(CheckCouponModel couponModel){
SharedPrefsHelper.saveSelectedCoupon(couponModel);
}
public static CheckCouponModel getSelectedCoupon(){
return SharedPrefsHelper.getSelectedCoupon();
}
public static void clearSelectedCoupon(){
SharedPrefsHelper.clearSelectedCoupon();
}
public static Calendar getTokenDeathDate(String tokenDeathTime){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = null;
try {
Date date = formatter.parse(tokenDeathTime);
calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar;
} catch (ParseException e) {
e.printStackTrace();
return calendar;
}
}
}

View File

@@ -0,0 +1,274 @@
package ch.pizzacucina.android.helper;
import android.content.SharedPreferences;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import ch.pizzacucina.android.activity.BaseActivity;
import ch.pizzacucina.android.model.CategoryModel;
import ch.pizzacucina.android.model.CheckCouponModel;
import ch.pizzacucina.android.model.CustomerTokenModel;
import ch.pizzacucina.android.model.StoreModel;
import ch.pizzacucina.android.model.UserModel;
import static android.content.Context.MODE_PRIVATE;
/**
* Created by cimenmus on 25/06/2017.
*/
public class SharedPrefsHelper {
private static final String SHARED_PREFS_NAME = "ch.pizzalink.android.preferences.";
private static final String PREF_KEY_CATEGORY_LIST = SHARED_PREFS_NAME + "categoryList";
private static final String PREF_KEY_IGNORED_CATEGORY_ID_LIST = SHARED_PREFS_NAME + "ignoredCategoryIdList";
private static final String PREF_KEY_PIZZA_CATEGORY_ID_LIST = SHARED_PREFS_NAME + "pizzaCategoryIdList";
private static final String PREF_KEY_USER = SHARED_PREFS_NAME + "user";
private static final String PREF_KEY_CUSTOMER_TOKEN = SHARED_PREFS_NAME + "customerToken";
private static final String PREF_KEY_USER_LOG_IN_STATUS = SHARED_PREFS_NAME + "userLoginStatus";
private static final String PREF_KEY_CART_ITEM_COUNT = SHARED_PREFS_NAME + "cartItemCount";
private static final String PREF_KEY_CART_TOTAL_PRICE = SHARED_PREFS_NAME + "cartTotalPrice";
private static final String PREF_KEY_USER_SELECTED_STORE = SHARED_PREFS_NAME + "selectedStore";
private static final String PREF_KEY_IS_FIRST_TIME = SHARED_PREFS_NAME + "isFirstTime";
private static final String PREF_KEY_SELECTED_COUPON = SHARED_PREFS_NAME + "selectedCoupon";
private static SharedPreferences sharedPreferences =
BaseActivity.currentActivity
.getSharedPreferences(SHARED_PREFS_NAME, MODE_PRIVATE);
private static SharedPreferences.Editor editor = sharedPreferences.edit();
private static Gson gson = new Gson();
public static void saveCategoryList(ArrayList<CategoryModel> categoryList){
String categoriesJsonString = gson.toJson(categoryList, new TypeToken<ArrayList<CategoryModel>>() {}.getType());
editor.putString(PREF_KEY_CATEGORY_LIST, categoriesJsonString);
editor.apply();
}
public static ArrayList<CategoryModel> readCategoryList(){
Type categoryListType = new TypeToken<ArrayList<CategoryModel>>(){}.getType();
return gson.fromJson(sharedPreferences.getString(PREF_KEY_CATEGORY_LIST, ""), categoryListType);
}
public static void saveIgnoredCategoryIdList(ArrayList<Integer> ignoredCategoryIdList){
String ignoredCategoryIdsJsonString = gson.toJson(ignoredCategoryIdList, new TypeToken<ArrayList<Integer>>() {}.getType());
editor.putString(PREF_KEY_IGNORED_CATEGORY_ID_LIST, ignoredCategoryIdsJsonString);
editor.apply();
}
public static ArrayList<Integer> readIgnoredCategoryIdList(){
Type ignoredCategoryIdListType = new TypeToken<ArrayList<Integer>>(){}.getType();
return gson.fromJson(sharedPreferences.getString(PREF_KEY_IGNORED_CATEGORY_ID_LIST, ""), ignoredCategoryIdListType);
}
public static void savePizzaCategoryIdList(ArrayList<Integer> pizzaCategoryIdList){
String ignoredCategoryIdsJsonString = gson.toJson(pizzaCategoryIdList, new TypeToken<ArrayList<Integer>>() {}.getType());
editor.putString(PREF_KEY_PIZZA_CATEGORY_ID_LIST, ignoredCategoryIdsJsonString);
editor.apply();
}
public static ArrayList<Integer> readPizzaCategoryIdList(){
Type pizzaCategoryIdList = new TypeToken<ArrayList<Integer>>(){}.getType();
return gson.fromJson(sharedPreferences.getString(PREF_KEY_PIZZA_CATEGORY_ID_LIST, ""), pizzaCategoryIdList);
}
public static void saveUser(UserModel user){
editor.putString(PREF_KEY_USER, gson.toJson(user));
editor.apply();
}
public static UserModel getUser(){
return gson.fromJson(sharedPreferences.getString(PREF_KEY_USER, ""), UserModel.class);
}
public static void clearCustomerInfo(){
editor.remove(PREF_KEY_USER);
editor.remove(PREF_KEY_CUSTOMER_TOKEN);
editor.remove(PREF_KEY_CART_ITEM_COUNT);
editor.remove(PREF_KEY_CART_TOTAL_PRICE);
editor.remove(PREF_KEY_SELECTED_COUPON);
editor.apply();
}
public static void saveCustomerToken(CustomerTokenModel customerToken){
editor.putString(PREF_KEY_CUSTOMER_TOKEN, gson.toJson(customerToken));
editor.apply();
}
public static CustomerTokenModel getCustomerToken(){
return gson.fromJson(sharedPreferences.getString(PREF_KEY_CUSTOMER_TOKEN, ""), CustomerTokenModel.class);
}
public static void clearCustomerToken(){
editor.remove(PREF_KEY_CUSTOMER_TOKEN);
editor.apply();
}
public static void setCustomerLoggedIn(boolean loggedId){
editor.putBoolean(PREF_KEY_USER_LOG_IN_STATUS, loggedId);
editor.apply();
}
public static boolean isCustomerLoggedIn(){
return sharedPreferences.getBoolean(PREF_KEY_USER_LOG_IN_STATUS, false);
}
public static void setCartItemCount(int cartItemCount){
editor.putInt(PREF_KEY_CART_ITEM_COUNT, cartItemCount);
editor.apply();
}
public static int getCartItemCount(){
return sharedPreferences.getInt(PREF_KEY_CART_ITEM_COUNT, 0);
}
public static String getCartTotalPrice(){
return sharedPreferences.getString(PREF_KEY_CART_TOTAL_PRICE, "0");
}
public static void setCartTotalPrice(String cartTotalPrice){
editor.putString(PREF_KEY_CART_TOTAL_PRICE, cartTotalPrice);
editor.apply();
}
public static void saveSelectedStore(StoreModel storeModel){
editor.putString(PREF_KEY_USER_SELECTED_STORE, gson.toJson(storeModel));
editor.apply();
}
public static StoreModel getSelectedStore(){
StoreModel selectedStoreModel = gson.fromJson(sharedPreferences.getString(PREF_KEY_USER_SELECTED_STORE, ""), StoreModel.class);
if(selectedStoreModel == null){
selectedStoreModel = new StoreModel();
}
return selectedStoreModel;
}
public static void clearSelectedStore(){
editor.remove(PREF_KEY_USER_SELECTED_STORE);
editor.apply();
}
public static void setIsFirstTime(boolean isFirstTime){
editor.putBoolean(PREF_KEY_IS_FIRST_TIME, isFirstTime);
editor.apply();
}
public static boolean isFirstTime(){
return sharedPreferences.getBoolean(PREF_KEY_IS_FIRST_TIME, true);
}
public static void saveSelectedCoupon(CheckCouponModel couponModel){
editor.putString(PREF_KEY_SELECTED_COUPON, gson.toJson(couponModel));
editor.apply();
}
public static CheckCouponModel getSelectedCoupon(){
CheckCouponModel selectedCouponModel = gson.fromJson(sharedPreferences.getString(PREF_KEY_SELECTED_COUPON, ""), CheckCouponModel.class);
if(selectedCouponModel != null &&
selectedCouponModel.getStoreName().toLowerCase().equals(SessionHelper.getSelectedStore().getStoreName().toLowerCase())){
return selectedCouponModel;
}
else {
return null;
}
}
public static void clearSelectedCoupon(){
editor.remove(PREF_KEY_SELECTED_COUPON);
editor.apply();
}
/*
public static void saveCategoryList(ArrayList<Category> cats){
ArrayList<Category> categories = new ArrayList<>();
for(Category category : cats){
if(category.getName().toLowerCase().contains("&amp;"))
category.setName(category.getName().replaceAll("(?i)&amp;", "&"));
if(!(category.getId().equals("1370") || category.getName().toLowerCase().equals("Uncategorized")))
categories.add(category);
}
sortCategories(categories);
String categoriesJsonString = gson.toJson(categories, new TypeToken<ArrayList<Category>>() {}.getType());
editor.putString(PREF_KEY_CATEGORY_LIST, categoriesJsonString);
editor.apply();
}
public static List<Category> readCategoryList(){
Type categoryListType = new TypeToken<ArrayList<Category>>(){}.getType();
return gson.fromJson(sharedPreferences.getString(PREF_KEY_CATEGORY_LIST, ""), categoryListType);
}
public static void saveAuthorList(ArrayList<Author> authors){
String authorsJsonString = gson.toJson(authors, new TypeToken<ArrayList<Author>>() {}.getType());
editor.putString(PREF_KEY_AUTHOR_LIST, authorsJsonString);
editor.apply();
}
public static List<Author> readAuthorList(){
Type authorListType = new TypeToken<ArrayList<Author>>(){}.getType();
return gson.fromJson(sharedPreferences.getString(PREF_KEY_AUTHOR_LIST, ""), authorListType);
}
public static void saveMagazineList(ArrayList<Magazine> magazines){
String magazinesJsonString = gson.toJson(magazines, new TypeToken<ArrayList<Magazine>>() {}.getType());
editor.putString(PREF_KEY_MAGAZINE_LIST, magazinesJsonString);
editor.apply();
}
public static List<Magazine> readMagazineList(){
Type magazineListType = new TypeToken<ArrayList<Magazine>>(){}.getType();
return gson.fromJson(sharedPreferences.getString(PREF_KEY_MAGAZINE_LIST, ""), magazineListType);
}
private static void sortCategories(ArrayList<Category> categories){
ArrayList<Category> sortedCategories = new ArrayList<>();
for(int i = 0; i < 5; i++){
sortedCategories.add(categories.get(i));
}
for(Category category : categories){
if(category.getName().toLowerCase(new Locale("tr", "TR")).equals("isviçre haberleri")) {
sortedCategories.add(category);
break;
}
}
for(Category category : categories){
if(category.getName().toLowerCase(new Locale("tr", "TR")).equals("türkiyeden haberler")) {
sortedCategories.add(category);
break;
}
}
for(Category category : categories){
if(!sortedCategories.contains(category))
sortedCategories.add(category);
}
categories.clear();
categories.addAll(sortedCategories);
sortedCategories.clear();
}
*/
}

View File

@@ -0,0 +1,41 @@
package ch.pizzacucina.android.helper;
import android.text.Html;
import android.widget.TextView;
public class TextHelper {
public static String parseDate(String pureDate, boolean shouldShowTime){
if(pureDate == null || pureDate.trim().isEmpty())
return "";
// 2017-03-07 11:00:00.000000 9:0:0
String[] pureDateArray = pureDate.split(" ");
String date = pureDateArray[0];
String[] dateArray = date.split("-");
String year = dateArray[0];
String month = dateArray[1];
String day = dateArray[2];
if(!shouldShowTime)
return day + "." + month + "." + year;
String time = pureDateArray[1];
time = time.substring(0, 5);
return day + "." + month + "." + year + " " + "Saat " + time;
}
@SuppressWarnings("deprecation")
public static void setTextFromHTML(TextView textView, String html) {
if (android.os.Build.VERSION.SDK_INT >= 24)
textView.setText(Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY));
else
textView.setText(Html.fromHtml(html));
}
}

View File

@@ -0,0 +1,38 @@
package ch.pizzacucina.android.helper;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import ch.pizzacucina.android.activity.BaseActivity;
/**
* Created by cimenmus on 25/06/2017.
*/
public class ViewHelper {
public static void toogleKeyboard() {
InputMethodManager imm = (InputMethodManager) BaseActivity.currentActivity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); // hide
} else {
imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY); // show
}
}
public static void hideKeyboard() {
View view = BaseActivity.currentActivity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) BaseActivity.currentActivity.
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
public static void showKeyboard() {
InputMethodManager imm = (InputMethodManager) BaseActivity.currentActivity.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY); // show
}
}

View File

@@ -0,0 +1,11 @@
package ch.pizzacucina.android.interfaces;
import android.support.v7.widget.AppCompatCheckBox;
/**
* Created by cimenmus on 25/09/2017.
*/
public interface CheckBoxChangedListener {
public void onCheckedChanged(AppCompatCheckBox appCompatCheckBox, int position);
}

View File

@@ -0,0 +1,12 @@
package ch.pizzacucina.android.interfaces;
import android.view.View;
/**
* Created by cimenmus on 12/09/2017.
*/
public interface DialogButtonClickListener {
public void onButtonClick(View view);
}

View File

@@ -0,0 +1,11 @@
package ch.pizzacucina.android.interfaces;
import android.view.View;
/**
* Created by cimenmus on 12/09/2017.
*/
public interface RecyclerItemClickListener {
public void onItemClick(View view , int position);
}

View File

@@ -0,0 +1,21 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by cimenmus on 26.10.2017.
*/
public class AddNewAddressResponseModel {
@Expose @SerializedName("address_id") private String addressId;
public String getAddressId() {
return addressId;
}
public void setAddressId(String addressId) {
this.addressId = addressId;
}
}

View File

@@ -0,0 +1,31 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by cimenmus on 13/10/2017.
*/
public class AddProductToBasketResponseModel {
@Expose @SerializedName("success") private String successMessage;
@Expose @SerializedName("option") private String errorMessage;
//@Expose @SerializedName("parameter") private String errorMessage;
public String getSuccessMessage() {
return successMessage;
}
public void setSuccessMessage(String successMessage) {
this.successMessage = successMessage;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}

View File

@@ -0,0 +1,47 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
* Created by cimenmus on 29.11.2017.
*/
public class AddToBasketOptionModel{
@SerializedName("optionId")
@Expose
private String optionId;
@SerializedName("selectedOptionValues")
@Expose
private ArrayList<String> selectedOptionValues;
public AddToBasketOptionModel(String optionId, ArrayList<String> selectedOptionValues) {
this.optionId = optionId;
this.selectedOptionValues = selectedOptionValues;
}
public AddToBasketOptionModel(String optionId, String selectedOptionValue) {
this.optionId = optionId;
this.selectedOptionValues = new ArrayList<>();
selectedOptionValues.add(selectedOptionValue);
}
public String getOptionId() {
return optionId;
}
public void setOptionId(String optionId) {
this.optionId = optionId;
}
public ArrayList<String> getSelectedOptionValueList() {
return selectedOptionValues;
}
public void setSelectedOptionValueList(ArrayList<String> selectedOptionValues) {
this.selectedOptionValues = selectedOptionValues;
}
}

View File

@@ -0,0 +1,59 @@
package ch.pizzacucina.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,33 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by cimenmus on 22.10.2017.
*/
public class AppVersionModel {
@Expose
@SerializedName("application")
private String appType;
private int version;
public String getAppType() {
return appType;
}
public void setAppType(String appType) {
this.appType = appType;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
}

View File

@@ -0,0 +1,47 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class CampaignBannerModel implements Serializable {
@Expose
@SerializedName("title")
private String title;
@Expose
@SerializedName("image")
private String imageUrl;
@Expose
@SerializedName("order")
private String order;
@Expose
@SerializedName("status")
private boolean active;
public String getTitle() {
return title;
}
public String getImageUrl() {
if(imageUrl == null){
imageUrl = "";
}
return imageUrl;
}
public String getOrder() {
if(order == null){
order = "0";
}
return order;
}
public boolean isActive() {
return active;
}
}

View File

@@ -0,0 +1,177 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class CampaignModel implements Serializable {
@Expose
@SerializedName("campaign_id")
private String id;
@Expose
@SerializedName("campaign_code")
private String code;
@Expose
@SerializedName("campaign_name")
private String name;
@Expose
@SerializedName("campaign_description")
private String description;
@Expose
@SerializedName("campaign_type")
private String type;
@Expose
@SerializedName("campaign_product_count")
private String productCount;
@Expose
@SerializedName("campaign_minimum_price")
private String minimumPrice;
@Expose
@SerializedName("campaign_source_category_id")
private String sourceCategoryId;
@Expose
@SerializedName("campaign_category_id")
private String categoryId;
@Expose
@SerializedName("campaign_product_id")
private String productId;
@Expose
@SerializedName("is_enabled")
private String isEnabled;
public void checkNull(){
if(id == null){
id = "";
}
if(code == null){
code = "";
}
if(name == null){
name = "";
}
if(description == null){
description = "";
}
if(type == null){
type = "";
}
if(productCount == null){
productCount = "";
}
if(minimumPrice == null){
minimumPrice = "";
}
if(sourceCategoryId == null){
sourceCategoryId = "";
}
if(categoryId == null){
categoryId = "";
}
if(productId == null){
productId = "";
}
if(isEnabled == null){
isEnabled = "";
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getProductCount() {
return productCount;
}
public void setProductCount(String productCount) {
this.productCount = productCount;
}
public String getMinimumPrice() {
return minimumPrice;
}
public void setMinimumPrice(String minimumPrice) {
this.minimumPrice = minimumPrice;
}
public String getSourceCategoryId() {
return sourceCategoryId;
}
public void setSourceCategoryId(String sourceCategoryId) {
this.sourceCategoryId = sourceCategoryId;
}
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getIsEnabled() {
return isEnabled;
}
public void setIsEnabled(String isEnabled) {
this.isEnabled = isEnabled;
}
}

View File

@@ -0,0 +1,112 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.ArrayList;
import ch.pizzacucina.android.helper.SharedPrefsHelper;
/**
* Created by cimenmus on 26/09/2017.
*/
public class CategoryModel implements Serializable{
@Expose
@SerializedName("category_id")
private int id;
@Expose
@SerializedName("name")
private String name;
@Expose
@SerializedName("is_special")
private boolean specialCategory;
@Expose
@SerializedName("is_default")
private boolean isDefault;
@Expose
@SerializedName("product_id")
private String specialProductId;
@Expose
@SerializedName("children")
private ArrayList<CategoryModel> subCategoryList;
public void checkNull(){
if(name == null)
name = "";
}
public static void checkNull(ArrayList<CategoryModel> categoryList){
for (CategoryModel categoryModel : categoryList){
categoryModel.checkNull();
if(categoryModel.getSubCategoryList() != null &&
categoryModel.getSubCategoryList().size() > 0){
for(CategoryModel subCategoryModel : categoryModel.subCategoryList){
subCategoryModel.checkNull();
}
}
}
}
public boolean isDescriptionVisible(){
return !SharedPrefsHelper.readIgnoredCategoryIdList().contains(id);
}
public String getCategoryIdString(){
return String.valueOf(id);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ArrayList<CategoryModel> getSubCategoryList() {
return subCategoryList;
}
public void setSubCategoryList(ArrayList<CategoryModel> subCategoryList) {
this.subCategoryList = subCategoryList;
}
public boolean isSpecialCategory() {
return specialCategory;
}
public void setSpecialCategory(boolean specialCategory) {
this.specialCategory = specialCategory;
}
public String getSpecialProductId() {
if(specialProductId == null){
specialProductId = "";
}
return specialProductId;
}
public void setSpecialProductId(String specialProductId) {
this.specialProductId = specialProductId;
}
public boolean isDefault() {
return isDefault;
}
}

View File

@@ -0,0 +1,289 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
/**
* Created by cimenmus on 6.02.2018.
*/
public class CheckCouponModel {
@Expose
@SerializedName("coupon_id")
private String couponId;
@Expose
@SerializedName("product")
private ArrayList<String> productIdList;
@Expose
@SerializedName("date_start")
private String startDate;
@Expose
@SerializedName("date_end")
private String endDate;
@Expose
@SerializedName("uses_total")
private String totalUsageCount;
@Expose
@SerializedName("uses_customer")
private String userUsageCount;
@Expose
@SerializedName("date_added")
private String addedDate;
private String code;
private String name;
private String type;
private String discount;
private String shipping;
private String total;
private String status;
private String storeName;
public void checkNull(){
if(couponId == null){
couponId = "";
}
if(startDate == null){
startDate = "1970-01-01";
}
if(endDate == null){
endDate = "1970-01-01";
}
if(totalUsageCount == null){
totalUsageCount = "";
}
if(userUsageCount == null){
userUsageCount = "";
}
if(addedDate == null){
addedDate = "";
}
if(code == null){
code = "";
}
if(name == null){
name = "";
}
if(type == null){
type = "";
}
if(discount == null){
discount = "";
}
if(shipping == null){
shipping = "";
}
if(total == null){
total = "";
}
if(status == null){
status = "";
}
if(productIdList == null){
productIdList = new ArrayList<>();
}
if(storeName == null){
storeName = "";
}
}
public enum CouponDiscountType {
FIXED,
PERCENT
}
public CouponDiscountType getCouponDiscountType(){
if(type.toLowerCase().equals("f")){
return CouponDiscountType.FIXED;
}
else {
return CouponDiscountType.PERCENT;
}
}
public boolean isActive(){
return status.equals("1") && isCouponUsable();
}
private boolean isCouponUsable(){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendarEnd = null;
Calendar calendarNow = Calendar.getInstance();
try {
Date dateEnd = formatter.parse(endDate);
calendarEnd = Calendar.getInstance();
calendarEnd.setTime(dateEnd);
if(calendarEnd.get(Calendar.YEAR) > calendarNow.get(Calendar.YEAR)){
return true;
}
if(calendarEnd.get(Calendar.MONTH) > calendarNow.get(Calendar.MONTH)){
return true;
}
if(calendarEnd.get(Calendar.DAY_OF_MONTH) >= calendarNow.get(Calendar.DAY_OF_MONTH)){
return true;
}
return false;
} catch (ParseException e) {
e.printStackTrace();
return false;
}
}
public String getCouponId() {
return couponId;
}
public void setCouponId(String couponId) {
this.couponId = couponId;
}
public ArrayList<String> getProductIdList() {
return productIdList;
}
public void setProductIdList(ArrayList<String> productIdList) {
this.productIdList = productIdList;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getTotalUsageCount() {
return totalUsageCount;
}
public void setTotalUsageCount(String totalUsageCount) {
this.totalUsageCount = totalUsageCount;
}
public String getUserUsageCount() {
return userUsageCount;
}
public void setUserUsageCount(String userUsageCount) {
this.userUsageCount = userUsageCount;
}
public String getAddedDate() {
return addedDate;
}
public void setAddedDate(String addedDate) {
this.addedDate = addedDate;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDiscount() {
return discount;
}
public void setDiscount(String discount) {
this.discount = discount;
}
public String getShipping() {
return shipping;
}
public void setShipping(String shipping) {
this.shipping = shipping;
}
public String getTotal() {
return total;
}
public void setTotal(String total) {
this.total = total;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
}

View File

@@ -0,0 +1,79 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
* Created by cimenmus on 23.10.2017.
*/
public class CityModel {
@Expose @SerializedName("shipping_point_id") private String shippingPointId;
@Expose @SerializedName("store_id") private String storeId;
@Expose @SerializedName("postcode") private String postcode;
@Expose @SerializedName("minimum_price") private String minimumPrice;
private String city;
private String canton;
private void checkNull(){
if(shippingPointId == null){
shippingPointId = "";
}
if(storeId == null){
storeId = "";
}
if(postcode == null){
postcode = "";
}
if(minimumPrice == null){
minimumPrice = "";
}
if(city == null){
city = "";
}
if(canton == null){
canton = "";
}
}
public static void checkNull(ArrayList<CityModel> cityList){
for (CityModel cityModel : cityList){
cityModel.checkNull();
}
}
public String getShippingPointId() {
return shippingPointId;
}
public String getStoreId() {
return storeId;
}
public String getPostcode() {
return postcode;
}
public String getMinimumPrice() {
return minimumPrice;
}
public String getCity() {
return city;
}
public String getCanton() {
return canton;
}
}

View File

@@ -0,0 +1,80 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
* Created by cimenmus on 23.10.2017.
*/
public class CountryModel {
@Expose @SerializedName("country_id") private String id;
@Expose @SerializedName("iso_code_2") private String isoCode2;
@Expose @SerializedName("iso_code_3") private String isoCode3;
@Expose @SerializedName("address_format") private String addressFormat;
@Expose @SerializedName("postcode_required") private String postcodeRequired;
private String name;
private String status;
private void checkNull(){
if(id == null)
id = "";
if(isoCode2 == null)
isoCode2 = "";
if(isoCode3 == null)
isoCode3 = "";
if(addressFormat == null)
addressFormat = "";
if(postcodeRequired == null)
postcodeRequired = "";
if(name == null)
name = "";
if(status == null)
status = "";
}
public static void checkNull(ArrayList<CountryModel> countryList){
for(CountryModel countryModel : countryList){
countryModel.checkNull();
}
}
public String getId() {
return id;
}
public String getIsoCode2() {
return isoCode2;
}
public String getIsoCode3() {
return isoCode3;
}
public String getAddressFormat() {
return addressFormat;
}
public String getPostcodeRequired() {
return postcodeRequired;
}
public String getName() {
return name;
}
public String getStatus() {
return status;
}
}

View File

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

View File

@@ -0,0 +1,73 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import ch.pizzacucina.android.helper.DateTimeHelper;
/**
* Created by cimenmus on 26/09/2017.
*/
public class CustomerTokenModel implements Serializable {
@Expose @SerializedName("customer_token") private String token;
@Expose @SerializedName("token_death_time") private String expiresIn;
@Expose @SerializedName("refresh_token") private String refreshToken;
private StoreModel storeOfToken;
public boolean isCustomerTokenAlive(){
long millis7days = 86400000 * 7;
return DateTimeHelper.getMillisFromDateString(expiresIn) - System.currentTimeMillis() >= millis7days;
}
public void checkNull(){
if(token == null)
token = "";
if(expiresIn == null)
expiresIn = "";
if(refreshToken == null)
refreshToken = "";
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(String expiresIn) {
this.expiresIn = expiresIn;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
public StoreModel getStoreOfToken() {
if(storeOfToken == null){
storeOfToken = new StoreModel();
}
return storeOfToken;
}
public void setStoreOfToken(StoreModel storeOfToken) {
this.storeOfToken = storeOfToken;
}
}

View File

@@ -0,0 +1,18 @@
package ch.pizzacucina.android.model;
/**
* Created by cimenmus on 24.10.2017.
*/
public class DeleteAddressResponseModel {
private String address_id;
public String getAddress_id() {
return address_id;
}
public void setAddress_id(String address_id) {
this.address_id = address_id;
}
}

View File

@@ -0,0 +1,131 @@
package ch.pizzacucina.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;
import ch.pizzacucina.android.api.ApiConstants;
/**
* Created by cimenmus on 17/10/2017.
*/
public class PaymentMethodModel {
private String code;
private String title;
private String terms;
private boolean isSelected;
@Expose @SerializedName("sort_order")
private String sortOrder;
public enum PaymentMethodType {
CREDIT_DEBIT_CARD,
CASH,
TRANSFER,
PAYPAL,
TWINT,
POST_FINANCE_CARD,
ANDROID_PAY,
APPLE_PAY,
UNKNOWN
}
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){
for(PaymentMethodModel paymentMethodModel : paymentMethodList){
paymentMethodModel.checkNull();
}
}
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 PaymentMethodType getPaymentMethodType() {
switch (code){
case ApiConstants.PAYMENT_METHOD_CODE_CREDIT_DEBIT_CARD:
return PaymentMethodType.CREDIT_DEBIT_CARD;
case ApiConstants.PAYMENT_METHOD_CODE_BANK_CASH:
return PaymentMethodType.CASH;
case ApiConstants.PAYMENT_METHOD_CODE_TRANSFER:
return PaymentMethodType.TRANSFER;
case ApiConstants.PAYMENT_METHOD_CODE_PAYPAL:
return PaymentMethodType.PAYPAL;
case ApiConstants.PAYMENT_METHOD_CODE_TWINT:
return PaymentMethodType.TWINT;
case ApiConstants.PAYMENT_METHOD_CODE_POST_FINANCE_CARD:
return PaymentMethodType.POST_FINANCE_CARD;
case ApiConstants.PAYMENT_METHOD_CODE_ANDROID_PAY:
return PaymentMethodType.ANDROID_PAY;
case ApiConstants.PAYMENT_METHOD_CODE_APPLE_PAY:
return PaymentMethodType.APPLE_PAY;
default:
return PaymentMethodType.UNKNOWN;
}
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
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() {
return isSelected;
}
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.pizzacucina.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

@@ -0,0 +1,14 @@
package ch.pizzacucina.android.model;
public class PaymentTokenModel {
private String token;
public String getToken() {
return token != null ? token : "";
}
public void setToken(String token) {
this.token = token;
}
}

View File

@@ -0,0 +1,55 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.SerializedName;
public class PostfinancePaymentDataModel {
private String route;
@SerializedName("orderID")
private String orderId;
@SerializedName("PM")
private String paymentMethodName;
@SerializedName("STATUS")
private String status;
@SerializedName("PAYID")
private String paymentId;
public String getRoute() {
if(route == null){
route = "";
}
return route;
}
public String getOrderId() {
if(orderId == null){
orderId = "";
}
return orderId;
}
public String getPaymentMethodName() {
if(paymentMethodName == null){
paymentMethodName = "";
}
return paymentMethodName;
}
public String getStatus() {
if(status == null){
status = "";
}
return status;
}
public String getPaymentId() {
if(paymentId == null){
paymentId = "";
}
return paymentId;
}
}

View File

@@ -0,0 +1,34 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.SerializedName;
public class PostfinancePaymentResponseModel {
private boolean success;
private String message;
@SerializedName("error_code")
private int errorCode;
@SerializedName("data")
private PostfinancePaymentDataModel paymentDataModel;
public boolean isSuccess() {
return success;
}
public String getMessage() {
if(message == null){
message = "";
}
return message;
}
public int getErrorCode() {
return errorCode;
}
public PostfinancePaymentDataModel getPaymentDataModel() {
return paymentDataModel;
}
}

View File

@@ -0,0 +1,21 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by cimenmus on 25.10.2017.
*/
public class RemoveProductFromCartResponseModel {
@Expose @SerializedName("cart_id") private String cartId;
public String getCartId() {
return cartId;
}
public void setCartId(String cartId) {
this.cartId = cartId;
}
}

View File

@@ -0,0 +1,96 @@
package ch.pizzacucina.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 ShippingMethodModel {
private String code;
private String title;
private boolean isSelected;
@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){
for(ShippingMethodModel shippingMethodModel : shippingMethodList){
shippingMethodModel.checkNull();
}
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public boolean isSelected() {
return isSelected;
}
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.pizzacucina.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

@@ -0,0 +1,38 @@
package ch.pizzacucina.android.model;
/**
* Created by cimenmus on 26.10.2017.
*/
public class StoreInfoModel {
private String title;
private String content;
public void checkNull(){
if(title == null){
title = "";
}
if(content == null){
content = "";
}
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}

View File

@@ -0,0 +1,111 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.SerializedName;
public class StoreModel {
@SerializedName("shipping_point_id")
private String shippingPointId;
@SerializedName("store_id")
private String storeId;
@SerializedName("postcode")
private String postCode;
@SerializedName("city")
private String city;
@SerializedName("minimum_price")
private String minimumPrice;
@SerializedName("canton")
private String canton;
@SerializedName("store_name")
private String storeName;
public StoreModel(){
checkNull();
}
public void checkNull(){
if(shippingPointId == null){
shippingPointId = "";
}
if(storeId == null){
storeId = "";
}
if(postCode == null){
postCode = "";
}
if(city == null){
city = "";
}
if(minimumPrice == null){
minimumPrice = "00.00";
}
if(canton == null){
canton = "";
}
if(storeName == null){
storeName = "";
}
}
public String getShippingPointId() {
return shippingPointId;
}
public void setShippingPointId(String shippingPointId) {
this.shippingPointId = shippingPointId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getPostCode() {
return postCode;
}
public void setPostCode(String postCode) {
this.postCode = postCode;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getMinimumPrice() {
return minimumPrice;
}
public void setMinimumPrice(String minimumPrice) {
this.minimumPrice = minimumPrice;
}
public String getCanton() {
return canton;
}
public void setCanton(String canton) {
this.canton = canton;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
}

View File

@@ -0,0 +1,57 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
public class StoreShiftModel {
@SerializedName("monday")
private ArrayList<String> mondayShift;
@SerializedName("tuesday")
private ArrayList<String> tuesdayShift;
@SerializedName("wednesday")
private ArrayList<String> wednesdayShift;
@SerializedName("thursday")
private ArrayList<String> thursdayShift;
@SerializedName("friday")
private ArrayList<String> fridayShift;
@SerializedName("saturday")
private ArrayList<String> saturdayShift;
@SerializedName("sunday")
private ArrayList<String> sundayShift;
public ArrayList<String> getMondayShift() {
return mondayShift != null ? mondayShift : new ArrayList<String>();
}
public ArrayList<String> getTuesdayShift() {
return tuesdayShift != null ? tuesdayShift : new ArrayList<String>();
}
public ArrayList<String> getWednesdayShift() {
return wednesdayShift != null ? wednesdayShift : new ArrayList<String>();
}
public ArrayList<String> getThursdayShift() {
return thursdayShift != null ? thursdayShift : new ArrayList<String>();
}
public ArrayList<String> getFridayShift() {
return fridayShift != null ? fridayShift : new ArrayList<String>();
}
public ArrayList<String> getSaturdayShift() {
return saturdayShift != null ? saturdayShift : new ArrayList<String>();
}
public ArrayList<String> getSundayShift() {
return sundayShift != null ? sundayShift : new ArrayList<String>();
}
}

View File

@@ -0,0 +1,129 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
/**
* Created by cimenmus on 26/09/2017.
*/
public class UserModel implements Serializable{
@Expose @SerializedName("customer_id") private String id;
@Expose @SerializedName("address_id") private String addressId;
@Expose @SerializedName("pizza_pass_count") private String pizzapassCount;
@Expose @SerializedName("kebab_pass_count") private String kebappassCount;
private String firstname;
private String lastname;
private String email;
private String telephone;
private CustomerTokenModel token;
public void checkNull(){
if(id == null)
id = "";
if(addressId == null)
addressId = "";
if(firstname == null)
firstname = "";
if(lastname == null)
lastname = "";
if(email == null)
email = "";
if(telephone == null)
telephone = "";
if(pizzapassCount == null)
pizzapassCount = "0";
if(kebappassCount == null)
kebappassCount = "0";
if(token != null)
token.checkNull();
}
public String getFullname(){
return firstname + " " + lastname;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAddressId() {
return addressId;
}
public void setAddressId(String addressId) {
this.addressId = addressId;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public CustomerTokenModel getToken() {
return token;
}
public void setToken(CustomerTokenModel token) {
this.token = token;
}
public String getPizzapassCount() {
return pizzapassCount;
}
public void setPizzapassCount(String pizzapassCount) {
this.pizzapassCount = pizzapassCount;
}
public String getKebappassCount() {
return kebappassCount;
}
public void setKebappassCount(String kebappassCount) {
this.kebappassCount = kebappassCount;
}
}

View File

@@ -0,0 +1,89 @@
package ch.pizzacucina.android.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
* Created by cimenmus on 26.10.2017.
*/
public class ZoneModel {
@Expose @SerializedName("zone_id") private String zoneId;
@Expose @SerializedName("country_id") private String countryId;
private String name;
private String code;
private String status;
private void checkNull(){
if(zoneId == null){
zoneId = "";
}
if(countryId == null){
countryId = "";
}
if(name == null){
name = "";
}
if(code == null){
code = "";
}
if(status == null){
status = "";
}
}
public static void checkNull(ArrayList<ZoneModel> zoneList){
for(ZoneModel zoneModel : zoneList){
zoneModel.checkNull();
}
}
public String getZoneId() {
return zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getCountryId() {
return countryId;
}
public void setCountryId(String countryId) {
this.countryId = countryId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}

View File

@@ -0,0 +1,81 @@
package ch.pizzacucina.android.model.cart;
import java.io.Serializable;
import java.util.ArrayList;
import ch.pizzacucina.android.api.ApiConstants;
/**
* Created by cimenmus on 05/10/2017.
*/
public class CartInfoModel implements Serializable {
private ArrayList<CartProductModel> products;
private ArrayList<CartTotalModel> totals;
private boolean isPizzapassCampaignUsed;
private boolean isKebappassCampaignUsed;
public ArrayList<CartProductModel> getProducts() {
return products;
}
public void setProducts(ArrayList<CartProductModel> products) {
this.products = products;
}
/*
public ArrayList<CartTotalModel> getTotals() {
return totals;
}
public void setTotals(ArrayList<CartTotalModel> totals) {
this.totals = totals;
}
*/
public CartTotalModel getCartTotalModel(){
CartTotalModel cartTotalModel = null;
for(CartTotalModel crtTtl : totals){
if(crtTtl.getTitle().toLowerCase().equals(ApiConstants.CART_TOTAL)){
cartTotalModel = crtTtl;
break;
}
}
if(cartTotalModel == null){
cartTotalModel = totals.get(0);
}
return cartTotalModel;
}
public ArrayList<CartTotalModel> getTotalsList() {
return totals;
}
public void checkNull(){
if(products == null){
products = new ArrayList<>();
}
if(totals == null){
totals = new ArrayList<>();
}
CartProductModel.checkNull(products);
}
public boolean isPizzapassCampaignUsed() {
return isPizzapassCampaignUsed;
}
public void setPizzapassCampaignUsed(boolean pizzapassCampaignUsed) {
isPizzapassCampaignUsed = pizzapassCampaignUsed;
}
public boolean isKebappassCampaignUsed() {
return isKebappassCampaignUsed;
}
public void setKebappassCampaignUsed(boolean kebappassCampaignUsed) {
isKebappassCampaignUsed = kebappassCampaignUsed;
}
}

View File

@@ -0,0 +1,167 @@
package ch.pizzacucina.android.model.cart;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Created by cimenmus on 05/10/2017.
*/
public class CartProductModel implements Serializable {
@Expose @SerializedName("cart_id") private String cartId;
@Expose @SerializedName("product_id") private String productId;
@Expose @SerializedName("categories") private ArrayList<String> categoryList;
private String name;
private String model;
private String quantity;
private String shipping;
private String price;
private String total;
private boolean stock;
private int reward;
private ArrayList<CartProductOptionModel> option;
private void checkNull(){
if(cartId == null)
cartId = "";
if(productId == null)
productId = "";
if(name == null)
name = "";
if(model == null)
model = "";
if(quantity == null)
quantity = "";
if(shipping == null)
shipping = "";
if(price == null)
price = "";
if(total == null)
total = "";
if(option != null){
for(CartProductOptionModel cartProductOptionModel : option){
cartProductOptionModel.checkNull();
}
}
if(categoryList == null){
categoryList = new ArrayList<>();
}
}
public static void checkNull(ArrayList<CartProductModel> cartProductList){
for(CartProductModel cartProductModel : cartProductList){
cartProductModel.checkNull();
}
}
public String getCartId() {
return cartId;
}
public void setCartId(String cartId) {
this.cartId = cartId;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public String getShipping() {
return shipping;
}
public void setShipping(String shipping) {
this.shipping = shipping;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getTotal() {
return total;
}
public void setTotal(String total) {
this.total = total;
}
public boolean isStock() {
return stock;
}
public void setStock(boolean stock) {
this.stock = stock;
}
public int getReward() {
return reward;
}
public void setReward(int reward) {
this.reward = reward;
}
public ArrayList<CartProductOptionModel> getOption() {
return option;
}
public void setOption(ArrayList<CartProductOptionModel> option) {
this.option = option;
}
public ArrayList<String> getCategoryList() {
return categoryList;
}
public void setCategoryList(ArrayList<String> categoryList) {
this.categoryList = categoryList;
}
}

View File

@@ -0,0 +1,78 @@
package ch.pizzacucina.android.model.cart;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
/**
* Created by cimenmus on 05/10/2017.
*/
public class CartProductOptionModel implements Serializable {
@Expose @SerializedName("product_option_id") private String id;
@Expose @SerializedName("product_option_value_id") private String valueId;
private String name;
private String value;
private String type;
public void checkNull(){
if(id == null)
id = "";
if(valueId == null)
valueId = "";
if(name == null)
name = "";
if(value == null)
value = "";
if(type == null)
type = "";
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getValueId() {
return valueId;
}
public void setValueId(String valueId) {
this.valueId = valueId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@@ -0,0 +1,40 @@
package ch.pizzacucina.android.model.cart;
import java.io.Serializable;
/**
* Created by cimenmus on 05/10/2017.
*/
public class CartTotalModel implements Serializable {
private String title;
private String text;
public CartTotalModel(String title, String text){
this.title = title;
this.text = text;
}
public String getTitle() {
if(title == null){
title = "";
}
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getText() {
if(text == null){
text = "";
}
return text;
}
public void setText(String text) {
this.text = text;
}
}

View File

@@ -0,0 +1,925 @@
package ch.pizzacucina.android.model.history;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.ArrayList;
import ch.pizzacucina.android.helper.DateTimeHelper;
/**
* Created by cimenmus on 04/10/2017.
*/public class OrderHistoryModel implements Serializable {
@SerializedName("order_id")
@Expose
private String id;
@SerializedName("invoice_no")
@Expose
private String invoiceNo;
@SerializedName("invoice_prefix")
@Expose
private String invoicePrefix;
@SerializedName("store_id")
@Expose
private String storeId;
@SerializedName("store_name")
@Expose
private String storeName;
@SerializedName("store_url")
@Expose
private String storeUrl;
@SerializedName("customer_id")
@Expose
private String customerId;
@SerializedName("customer_group_id")
@Expose
private String customerGroupId;
@SerializedName("firstname")
@Expose
private String firstname;
@SerializedName("lastname")
@Expose
private String lastname;
@SerializedName("email")
@Expose
private String email;
@SerializedName("telephone")
@Expose
private String telephone;
@SerializedName("fax")
@Expose
private String fax;
@SerializedName("custom_field")
@Expose
private String customField;
@SerializedName("payment_firstname")
@Expose
private String paymentFirstname;
@SerializedName("payment_lastname")
@Expose
private String paymentLastname;
@SerializedName("payment_company")
@Expose
private String paymentCompany;
@SerializedName("payment_address_1")
@Expose
private String paymentAddress1;
@SerializedName("payment_address_2")
@Expose
private String paymentAddress2;
@SerializedName("payment_city")
@Expose
private String paymentCity;
@SerializedName("payment_postcode")
@Expose
private String paymentPostcode;
@SerializedName("payment_country")
@Expose
private String paymentCountry;
@SerializedName("payment_country_id")
@Expose
private String paymentCountryId;
@SerializedName("payment_zone")
@Expose
private String paymentZone;
@SerializedName("payment_zone_id")
@Expose
private String paymentZoneId;
@SerializedName("payment_address_format")
@Expose
private String paymentAddressFormat;
@SerializedName("payment_custom_field")
@Expose
private String paymentCustomField;
@SerializedName("payment_method")
@Expose
private String paymentMethod;
@SerializedName("payment_code")
@Expose
private String paymentCode;
@SerializedName("shipping_firstname")
@Expose
private String shippingFirstname;
@SerializedName("shipping_lastname")
@Expose
private String shippingLastname;
@SerializedName("shipping_company")
@Expose
private String shippingCompany;
@SerializedName("shipping_address_1")
@Expose
private String shippingAddress1;
@SerializedName("shipping_address_2")
@Expose
private String shippingAddress2;
@SerializedName("shipping_city")
@Expose
private String shippingCity;
@SerializedName("shipping_postcode")
@Expose
private String shippingPostcode;
@SerializedName("shipping_country")
@Expose
private String shippingCountry;
@SerializedName("shipping_country_id")
@Expose
private String shippingCountryId;
@SerializedName("shipping_zone")
@Expose
private String shippingZone;
@SerializedName("shipping_zone_id")
@Expose
private String shippingZoneId;
@SerializedName("shipping_address_format")
@Expose
private String shippingAddressFormat;
@SerializedName("shipping_custom_field")
@Expose
private String shippingCustomField;
@SerializedName("shipping_method")
@Expose
private String shippingMethod;
@SerializedName("shipping_code")
@Expose
private String shippingCode;
@SerializedName("comment")
@Expose
private String comment;
@SerializedName("total")
@Expose
private String total;
@SerializedName("order_status_id")
@Expose
private String orderStatusId;
@SerializedName("affiliate_id")
@Expose
private String affiliateId;
@SerializedName("commission")
@Expose
private String commission;
@SerializedName("marketing_id")
@Expose
private String marketingId;
@SerializedName("tracking")
@Expose
private String tracking;
@SerializedName("language_id")
@Expose
private String languageId;
@SerializedName("currency_id")
@Expose
private String currencyId;
@SerializedName("currency_code")
@Expose
private String currencyCode;
@SerializedName("currency_value")
@Expose
private String currencyValue;
@SerializedName("ip")
@Expose
private String ip;
@SerializedName("forwarded_ip")
@Expose
private String forwardedIp;
@SerializedName("user_agent")
@Expose
private String userAgent;
@SerializedName("accept_language")
@Expose
private String acceptLanguage;
@SerializedName("date_added")
@Expose
private String createDate;
@SerializedName("date_modified")
@Expose
private String dateModified;
@SerializedName("shipping_time")
@Expose
private String shippingTime;
@SerializedName("status")
@Expose
private String status;
public int getTotalInt(){
try {
return Integer.valueOf(total);
}catch (Exception e){
return 0;
}
}
public String getTotalString(){
return currencyCode + " " + total;
}
public String getFormattedCreateDate(){
return DateTimeHelper.getFormattedDateFromDateString(createDate);
}
private void checkNull(){
if(id == null)
id = "";
if(invoiceNo == null)
invoiceNo = "";
if(invoicePrefix == null)
invoicePrefix = "";
if(storeId == null)
storeId = "";
if(storeName == null)
storeName = "";
if(storeUrl == null)
storeUrl = "";
if(customerId == null)
customerId = "";
if(customerGroupId == null)
customerGroupId = "";
if(firstname == null)
firstname = "";
if(lastname == null)
lastname = "";
if(email == null)
email = "";
if(telephone == null)
telephone = "";
if(fax == null)
fax = "";
if(customField == null)
customField = "";
if(paymentFirstname == null)
paymentFirstname = "";
if(paymentLastname == null)
paymentLastname = "";
if(paymentCompany == null)
paymentCompany = "";
if(paymentAddress1 == null)
paymentAddress1 = "";
if(paymentAddress2 == null)
paymentAddress2 = "";
if(paymentCity == null)
paymentCity = "";
if(paymentPostcode == null)
paymentPostcode = "";
if(paymentCountry == null)
paymentCountry = "";
if(paymentCountryId == null)
paymentCountryId = "";
if(paymentZone == null)
paymentZone = "";
if(paymentZoneId == null)
paymentZoneId = "";
if(paymentAddressFormat == null)
paymentAddressFormat = "";
if(paymentCustomField == null)
paymentCustomField = "";
if(paymentMethod == null)
paymentMethod = "";
if(paymentCode == null)
paymentCode = "";
if(shippingFirstname == null)
shippingFirstname = "";
if(shippingLastname == null)
shippingLastname = "";
if(shippingCompany == null)
shippingCompany = "";
if(shippingAddress1 == null)
shippingAddress1 = "";
if(shippingAddress2 == null)
shippingAddress2 = "";
if(shippingCity == null)
shippingCity = "";
if(shippingPostcode == null)
shippingPostcode = "";
if(shippingCountry == null)
shippingCountry = "";
if(shippingCountryId == null)
shippingCountryId = "";
if(shippingZone == null)
shippingZone = "";
if(shippingZoneId == null)
shippingZoneId = "";
if(shippingAddressFormat == null)
shippingAddressFormat = "";
if(shippingCustomField == null)
shippingCustomField = "";
if(shippingMethod == null)
shippingMethod = "";
if(shippingCode == null)
shippingCode = "";
if(comment == null)
comment = "";
if(total == null)
total = "0.0";
if(orderStatusId == null)
orderStatusId = "";
if(affiliateId == null)
affiliateId = "";
if(commission == null)
commission = "";
if(marketingId == null)
marketingId = "";
if(tracking == null)
tracking = "";
if(languageId == null)
languageId = "";
if(currencyId == null)
currencyId = "";
if(currencyCode == null)
currencyCode = "";
if(currencyValue == null)
currencyValue = "";
if(ip == null)
ip = "";
if(forwardedIp == null)
forwardedIp = "";
if(userAgent == null)
userAgent = "";
if(acceptLanguage == null)
acceptLanguage = "";
if(createDate == null)
createDate = "";
if(dateModified == null)
dateModified = "";
if(shippingTime == null)
shippingTime = "";
if(status == null)
status = "";
}
public static void checkNull(ArrayList<OrderHistoryModel> orderHistoryList){
for(OrderHistoryModel orderHistoryModel : orderHistoryList){
orderHistoryModel.checkNull();
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getInvoiceNo() {
return invoiceNo;
}
public void setInvoiceNo(String invoiceNo) {
this.invoiceNo = invoiceNo;
}
public String getInvoicePrefix() {
return invoicePrefix;
}
public void setInvoicePrefix(String invoicePrefix) {
this.invoicePrefix = invoicePrefix;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getStoreUrl() {
return storeUrl;
}
public void setStoreUrl(String storeUrl) {
this.storeUrl = storeUrl;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getCustomerGroupId() {
return customerGroupId;
}
public void setCustomerGroupId(String customerGroupId) {
this.customerGroupId = customerGroupId;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getCustomField() {
return customField;
}
public void setCustomField(String customField) {
this.customField = customField;
}
public String getPaymentFirstname() {
return paymentFirstname;
}
public void setPaymentFirstname(String paymentFirstname) {
this.paymentFirstname = paymentFirstname;
}
public String getPaymentLastname() {
return paymentLastname;
}
public void setPaymentLastname(String paymentLastname) {
this.paymentLastname = paymentLastname;
}
public String getPaymentCompany() {
return paymentCompany;
}
public void setPaymentCompany(String paymentCompany) {
this.paymentCompany = paymentCompany;
}
public String getPaymentAddress1() {
return paymentAddress1;
}
public void setPaymentAddress1(String paymentAddress1) {
this.paymentAddress1 = paymentAddress1;
}
public String getPaymentAddress2() {
return paymentAddress2;
}
public void setPaymentAddress2(String paymentAddress2) {
this.paymentAddress2 = paymentAddress2;
}
public String getPaymentCity() {
return paymentCity;
}
public void setPaymentCity(String paymentCity) {
this.paymentCity = paymentCity;
}
public String getPaymentPostcode() {
return paymentPostcode;
}
public void setPaymentPostcode(String paymentPostcode) {
this.paymentPostcode = paymentPostcode;
}
public String getPaymentCountry() {
return paymentCountry;
}
public void setPaymentCountry(String paymentCountry) {
this.paymentCountry = paymentCountry;
}
public String getPaymentCountryId() {
return paymentCountryId;
}
public void setPaymentCountryId(String paymentCountryId) {
this.paymentCountryId = paymentCountryId;
}
public String getPaymentZone() {
return paymentZone;
}
public void setPaymentZone(String paymentZone) {
this.paymentZone = paymentZone;
}
public String getPaymentZoneId() {
return paymentZoneId;
}
public void setPaymentZoneId(String paymentZoneId) {
this.paymentZoneId = paymentZoneId;
}
public String getPaymentAddressFormat() {
return paymentAddressFormat;
}
public void setPaymentAddressFormat(String paymentAddressFormat) {
this.paymentAddressFormat = paymentAddressFormat;
}
public String getPaymentCustomField() {
return paymentCustomField;
}
public void setPaymentCustomField(String paymentCustomField) {
this.paymentCustomField = paymentCustomField;
}
public String getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(String paymentMethod) {
this.paymentMethod = paymentMethod;
}
public String getPaymentCode() {
return paymentCode;
}
public void setPaymentCode(String paymentCode) {
this.paymentCode = paymentCode;
}
public String getShippingFirstname() {
return shippingFirstname;
}
public void setShippingFirstname(String shippingFirstname) {
this.shippingFirstname = shippingFirstname;
}
public String getShippingLastname() {
return shippingLastname;
}
public void setShippingLastname(String shippingLastname) {
this.shippingLastname = shippingLastname;
}
public String getShippingCompany() {
return shippingCompany;
}
public void setShippingCompany(String shippingCompany) {
this.shippingCompany = shippingCompany;
}
public String getShippingAddress1() {
return shippingAddress1;
}
public void setShippingAddress1(String shippingAddress1) {
this.shippingAddress1 = shippingAddress1;
}
public String getShippingAddress2() {
return shippingAddress2;
}
public void setShippingAddress2(String shippingAddress2) {
this.shippingAddress2 = shippingAddress2;
}
public String getShippingCity() {
return shippingCity;
}
public void setShippingCity(String shippingCity) {
this.shippingCity = shippingCity;
}
public String getShippingPostcode() {
return shippingPostcode;
}
public void setShippingPostcode(String shippingPostcode) {
this.shippingPostcode = shippingPostcode;
}
public String getShippingCountry() {
return shippingCountry;
}
public void setShippingCountry(String shippingCountry) {
this.shippingCountry = shippingCountry;
}
public String getShippingCountryId() {
return shippingCountryId;
}
public void setShippingCountryId(String shippingCountryId) {
this.shippingCountryId = shippingCountryId;
}
public String getShippingZone() {
return shippingZone;
}
public void setShippingZone(String shippingZone) {
this.shippingZone = shippingZone;
}
public String getShippingZoneId() {
return shippingZoneId;
}
public void setShippingZoneId(String shippingZoneId) {
this.shippingZoneId = shippingZoneId;
}
public String getShippingAddressFormat() {
return shippingAddressFormat;
}
public void setShippingAddressFormat(String shippingAddressFormat) {
this.shippingAddressFormat = shippingAddressFormat;
}
public String getShippingCustomField() {
return shippingCustomField;
}
public void setShippingCustomField(String shippingCustomField) {
this.shippingCustomField = shippingCustomField;
}
public String getShippingMethod() {
return shippingMethod;
}
public void setShippingMethod(String shippingMethod) {
this.shippingMethod = shippingMethod;
}
public String getShippingCode() {
return shippingCode;
}
public void setShippingCode(String shippingCode) {
this.shippingCode = shippingCode;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getTotal() {
return total;
}
public void setTotal(String total) {
this.total = total;
}
public String getOrderStatusId() {
return orderStatusId;
}
public void setOrderStatusId(String orderStatusId) {
this.orderStatusId = orderStatusId;
}
public String getAffiliateId() {
return affiliateId;
}
public void setAffiliateId(String affiliateId) {
this.affiliateId = affiliateId;
}
public String getCommission() {
return commission;
}
public void setCommission(String commission) {
this.commission = commission;
}
public String getMarketingId() {
return marketingId;
}
public void setMarketingId(String marketingId) {
this.marketingId = marketingId;
}
public String getTracking() {
return tracking;
}
public void setTracking(String tracking) {
this.tracking = tracking;
}
public String getLanguageId() {
return languageId;
}
public void setLanguageId(String languageId) {
this.languageId = languageId;
}
public String getCurrencyId() {
return currencyId;
}
public void setCurrencyId(String currencyId) {
this.currencyId = currencyId;
}
public String getCurrencyCode() {
return currencyCode;
}
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
public String getCurrencyValue() {
return currencyValue;
}
public void setCurrencyValue(String currencyValue) {
this.currencyValue = currencyValue;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getForwardedIp() {
return forwardedIp;
}
public void setForwardedIp(String forwardedIp) {
this.forwardedIp = forwardedIp;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public String getAcceptLanguage() {
return acceptLanguage;
}
public void setAcceptLanguage(String acceptLanguage) {
this.acceptLanguage = acceptLanguage;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public String getDateModified() {
return dateModified;
}
public void setDateModified(String dateModified) {
this.dateModified = dateModified;
}
public String getShippingTime() {
return shippingTime;
}
public void setShippingTime(String shippingTime) {
this.shippingTime = shippingTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}

Some files were not shown because too many files have changed in this diff Show More