campaig services

This commit is contained in:
cimenmus
2018-06-11 22:21:06 +03:00
parent df10927bb9
commit 87f3596b50
17 changed files with 583 additions and 9 deletions

Binary file not shown.

View File

@@ -129,6 +129,8 @@ public class CreateOrderActivity extends BaseActivity {
startActivity(mainActivityIntent);
SharedPrefsHelper.setCartItemCount(0);
SharedPrefsHelper.setCartTotalPrice("0");
SharedPrefsHelper.setUserUsedPizzapassCampaign(false);
SharedPrefsHelper.setUserUsedChampagneCampaign(false);
finishAffinity();
break;
}

View File

@@ -40,6 +40,7 @@ import ch.pizzapp.android.helper.DialogHelper;
import ch.pizzapp.android.helper.PriceHelper;
import ch.pizzapp.android.helper.SessionHelper;
import ch.pizzapp.android.helper.SharedPrefsHelper;
import ch.pizzapp.android.model.CampaignModel;
import ch.pizzapp.android.model.CategoryModel;
import ch.pizzapp.android.view.AppToolbar;
import io.github.luizgrp.sectionedrecyclerviewadapter.SectionParameters;
@@ -50,8 +51,7 @@ 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.pizzalinkToolbar) AppToolbar appToolbar;
@BindView(R.id.cartTotalRelativeLayout) RelativeLayout cartTotalRelativeLayout;
@BindView(R.id.cartTotalTextView) TextView cartTotalTextView;
@BindView(R.id.bottomNavigationView) BottomNavigationViewEx bottomNavigationView;
@@ -77,6 +77,7 @@ public class MainActivity extends BaseActivity {
private NavigationMenuRecyclerAdapter navigationMenuRecyclerAdapter;
//private Badge badge;
private Animation animUp,animDown;
private CampaignModel campaignModel;
private SectionedRecyclerViewAdapter sectionAdapter = new SectionedRecyclerViewAdapter();
@@ -96,6 +97,7 @@ public class MainActivity extends BaseActivity {
private void getDataFromIntent(){
isStartWithOrderHistory = getIntent().getBooleanExtra("isStartWithOrderHistory", false);
campaignModel = (CampaignModel)getIntent().getSerializableExtra("campaignModel");
}
private void initViews(){
@@ -156,6 +158,10 @@ public class MainActivity extends BaseActivity {
if(isStartWithOrderHistory){
bottomNavigationView.setCurrentItem(1);
}
else if (campaignModel != null) {
CategoryModel campaignCategoryModel = new CategoryModel(campaignModel);
openProductsScreen(campaignCategoryModel);
}
else {
openProductsScreen(categoryList.get(2));
}

View File

@@ -73,6 +73,7 @@ public class ProductPropertiesActivity extends BaseActivity {
@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;
@@ -82,6 +83,7 @@ public class ProductPropertiesActivity extends BaseActivity {
private ArrayList<MenuProductOptionValueModel> productCheckboxOptionValueList = new ArrayList<>();
private ProductRadioOptionsRecyclerAdapter productRadioOptionsRecyclerAdapter;
private ProductCheckboxOptionsRecyclerAdapter productCheckboxOptionsRecyclerAdapter;
private boolean isFromPizzapassCampaign, isFromChampagneCampaign;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -104,6 +106,9 @@ public class ProductPropertiesActivity extends BaseActivity {
finish();
break;
case R.id.increaseProductCountImageView:
if(isFromPizzapassCampaign || isFromChampagneCampaign){
return;
}
productCount++;
productCountTextView.setText(String.valueOf(productCount));
productPriceTextView.setText(
@@ -122,7 +127,13 @@ public class ProductPropertiesActivity extends BaseActivity {
case R.id.addToCartButton:
if(checkFields()){
if(SessionHelper.isCustomerLoggedIn()){
addProductToCart();
if((isFromPizzapassCampaign && SessionHelper.isUserUsedPizzapassCampaign()) ||
(isFromChampagneCampaign && SessionHelper.isUserUsedChampagneCampaign())){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, cannotUseCampaignText);
}
else {
addProductToCart();
}
}
else {
DialogHelper.showNeedToLoginDialog(R.string.need_to_login_for_shopping);
@@ -164,6 +175,8 @@ public class ProductPropertiesActivity extends BaseActivity {
private void getDataFromIntent(){
menuProductModel = (MenuProductModel) getIntent().getSerializableExtra("menuProductModel");
isFromPizzapassCampaign = getIntent().getBooleanExtra("isFromPizzapassCampaign", false);
isFromChampagneCampaign = getIntent().getBooleanExtra("isFromChampagneCampaign", false);
}
private void initViews(){
setFields();
@@ -354,6 +367,12 @@ public class ProductPropertiesActivity extends BaseActivity {
response.body().isSuccess()){
SharedPrefsHelper.setCartItemCount(response.body().getData().getProducts().size());
SharedPrefsHelper.setCartTotalPrice(PriceHelper.removeCurrencyFromPrice(response.body().getData().getCartTotalModel().getText()));
if(isFromPizzapassCampaign){
SessionHelper.setUserUsedPizzapassCampaign(true);
}
else if(isFromChampagneCampaign){
SessionHelper.setUserUsedChampagneCampaign(true);
}
/*
MainActivity mainActivity = (MainActivity) getActivity();

View File

@@ -10,4 +10,7 @@ public class ApiConstants {
public static final int PRODUCT_ID_EKSTRA_KEBAP = 91;
public static final String APP_TYPE_ID_ANDROID = "2";
public static final int APP_ERROR_CODE_AUTHORIZATION = 1;
public static final String CAMPAIGN_CODE_PIZZAPASS = "PIZZAPASS";
public static final String CAMPAIGN_CODE_CHAMPAGNE = "CHAMPAGNE";
}

View File

@@ -36,4 +36,7 @@ public class ApiEndPoints {
public static final String API_GET_STORE_INFO = PREFIX + "getStoreInfo" + SUFFIX;
public static final String API_GET_ORDER_PRODUCT_LIST = PREFIX + "getOrderProducts" + SUFFIX;
public static final String API_CHECK_COUPON = PREFIX + "checkCoupon" + SUFFIX + "&token=";
public static final String API_CHECK_CAMPAIGN_PIZZAPASS = PREFIX + "detectPizzaPassCampaign" + SUFFIX + "&token=";
public static final String API_CHECK_CAMPAIGN_CHAMPAGNE = PREFIX + "detectChampagneCampaign" + SUFFIX + "&token=";
public static final String API_CHECK_DELIVERY_TIME = PREFIX + "checkDeliveryTimeService" + SUFFIX + "&token=";
}

View File

@@ -6,6 +6,7 @@ import ch.pizzapp.android.model.AddNewAddressResponseModel;
import ch.pizzapp.android.model.AddProductToBasketResponseModel;
import ch.pizzapp.android.model.AddressModel;
import ch.pizzapp.android.model.AppVersionModel;
import ch.pizzapp.android.model.CampaignModel;
import ch.pizzapp.android.model.CheckCouponModel;
import ch.pizzapp.android.model.CountryModel;
import ch.pizzapp.android.model.DeleteAddressResponseModel;
@@ -145,9 +146,17 @@ public interface ApiInterface {
@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_CHAMPAGNE)
Call<ResponseObject<CampaignModel>> checkChampagneCampaign(@Query("token") String token);
@GET(ApiEndPoints.API_CHECK_DELIVERY_TIME)
Call<ResponseObject<Boolean>> checkDeliveryTime();
}

View File

@@ -167,6 +167,8 @@ public class CartFragment extends BaseFragment {
setCartLayoutsVisibility();
SharedPrefsHelper.setCartItemCount(0);
SharedPrefsHelper.setCartTotalPrice("0");
SharedPrefsHelper.setUserUsedPizzapassCampaign(false);
SharedPrefsHelper.setUserUsedChampagneCampaign(false);
MainActivity mainActivity = (MainActivity) getActivity();
mainActivity.setCartItemCount();
}

View File

@@ -104,6 +104,8 @@ public class MenuFragment extends BaseFragment {
public void onItemClick(View view, int position) {
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductPropertiesActivity.class);
productPropertiesIntent.putExtra("menuProductModel", menuProductList.get(position));
productPropertiesIntent.putExtra("isFromPizzapassCampaign", categoryModel.isPizzapassCampaign());
productPropertiesIntent.putExtra("isFromChampagneCampaign", categoryModel.isChampagneCampaign());
startActivityForResult(productPropertiesIntent, REQUEST_CODE_PRODUCT_PROPERTIES);
//showBottomsheetDialog(menuProductList.get(position));
}

View File

@@ -1,10 +1,15 @@
package ch.pizzapp.android.fragment.createOrder;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import java.util.HashMap;
@@ -13,7 +18,9 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzapp.android.R;
import ch.pizzapp.android.activity.BaseActivity;
import ch.pizzapp.android.activity.CreateOrderActivity;
import ch.pizzapp.android.activity.MainActivity;
import ch.pizzapp.android.api.ApiEndPoints;
import ch.pizzapp.android.api.ApiErrorUtils;
import ch.pizzapp.android.api.ApiService;
@@ -22,6 +29,7 @@ import ch.pizzapp.android.helper.DialogHelper;
import ch.pizzapp.android.helper.PriceHelper;
import ch.pizzapp.android.helper.SessionHelper;
import ch.pizzapp.android.helper.SharedPrefsHelper;
import ch.pizzapp.android.model.CampaignModel;
import ch.pizzapp.android.model.cart.CartProductModel;
import ch.pizzapp.android.view.AppInfoView;
import retrofit2.Call;
@@ -51,6 +59,8 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
@BindString(R.string.slice_pizza) String slicePizzaText;
@BindString(R.string.yes) String yesText;
@BindString(R.string.no) String noText;
@BindString(R.string.restaurant_out_of_order) String restaurantOutOfOrderText;
@BindString(R.string.something_went_wrong) String genericErrorText;
public static final java.lang.String FRAGMENT_NAME = "orderSummaryFragment";
private CreateOrderActivity createOrderActivity;
@@ -82,7 +92,8 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
break;
case R.id.nextTextView:
createOrder();
//createOrder();
checkPizzapassCampaign();
break;
}
}
@@ -107,8 +118,203 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
}
}
private void createOrder(){
private void checkPizzapassCampaign(){
DialogHelper.showLoadingDialog();
ApiService
.apiInterface
.checkPizzapassCampaign(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() &&
!SessionHelper.isUserUsedPizzapassCampaign()){
DialogHelper.hideLoadingDialog();
if(response.body().getData() == null){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
else {
response.body().getData().checkNull();
showPizzapassCampaignDialog(response.body().getData());
}
}
else {
checkChampagneCampaign();
}
}
else{
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<CampaignModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
/*
// dummy //
CampaignModel campaignModel = new CampaignModel();
campaignModel.setCategoryId("71");
campaignModel.setName("Pizzapass");
campaignModel.setCode("PIZZAPASS");
campaignModel.setDescription("10 pizza alana 11. pizza bizden!");
if(!SessionHelper.isUserUsedPizzapassCampaign()){
showPizzapassCampaignDialog(campaignModel);
}
else {
checkChampagneCampaign();
}
*/
}
});
}
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, MainActivity.class);
campaignIntent.putExtra("campaignModel", campaignModel);
BaseActivity.currentActivity.startActivity(campaignIntent);
}
},
R.string.decline_campaign,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
DialogHelper.showLoadingDialog();
checkChampagneCampaign();
}
}
);
}
private void checkChampagneCampaign(){
ApiService
.apiInterface
.checkChampagneCampaign(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() && !SessionHelper.isUserUsedChampagneCampaign()){
DialogHelper.hideLoadingDialog();
if(response.body().getData() == null){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
else {
response.body().getData().checkNull();
showChampagneCampaignDialog(response.body().getData());
}
}
else {
checkDeliveryTime();
}
}
else{
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<CampaignModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
/*
// dummy //
CampaignModel campaignModel = new CampaignModel();
campaignModel.setCategoryId("72");
//campaignModel.setCategoryId("71");
campaignModel.setName("Champagne Campaign");
campaignModel.setCode("CHAMPAGNE");
campaignModel.setDescription("40 CHF ve üzeri alişverişlerde 5ML şampanya hediye!");
if(!SessionHelper.isUserUsedChampagneCampaign()){
showChampagneCampaignDialog(campaignModel);
}
else {
checkDeliveryTime();
}
*/
}
});
}
private void showChampagneCampaignDialog(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, MainActivity.class);
campaignIntent.putExtra("campaignModel", campaignModel);
BaseActivity.currentActivity.startActivity(campaignIntent);
}
},
R.string.decline_campaign,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
DialogHelper.showLoadingDialog();
checkDeliveryTime();
}
}
);
}
private void checkDeliveryTime(){
ApiService
.apiInterface
.checkDeliveryTime()
.enqueue(new Callback<ResponseObject<Boolean>>() {
@Override
public void onResponse(Call<ResponseObject<Boolean>> call, Response<ResponseObject<Boolean>> response) {
if(response.isSuccessful() &&
response.body() != null){
if(response.body().isSuccess()){
createOrder();
}
else {
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, restaurantOutOfOrderText);
}
}
else{
DialogHelper.hideLoadingDialog();
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<Boolean>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void createOrder(){
//DialogHelper.showLoadingDialog();
Call<ResponseObject<Integer>> call = ApiService.apiInterface.createOrder(
ApiEndPoints.API_CREATE_ORDER + SessionHelper.getCustomerToken().getToken(), getCreateOrderParams());
call.enqueue(new Callback<ResponseObject<Integer>>() {
@@ -177,4 +383,5 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
}
return containsAnyPizza;
}
}

View File

@@ -13,7 +13,9 @@ import java.util.ArrayList;
import ch.pizzapp.android.R;
import ch.pizzapp.android.activity.BaseActivity;
import ch.pizzapp.android.activity.LoginActivity;
import ch.pizzapp.android.activity.MainActivity;
import ch.pizzapp.android.activity.RegisterActivity;
import ch.pizzapp.android.model.CampaignModel;
public class DialogHelper {
@@ -120,19 +122,54 @@ public class DialogHelper {
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.navy)
.positiveText(R.string.ok)
.positiveText(positiveTextResId)
.onPositive(positiveButtonCallback)
.negativeText(R.string.cancel)
.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){
new MaterialDialog.Builder(BaseActivity.currentActivity)
.title(title)
.content(message)
.titleColorRes(R.color.red)
.contentColorRes(R.color.navy)
.positiveText(positiveTextResId)
.onPositive(positiveButtonCallback)
.negativeText(negativeTextResId)
.onNegative(negativeButtonCallback)
.typeface("Quicksand-Medium.ttf", "Quicksand-Regular.ttf")
.show();
}
public static void showNeedToLoginDialog(int messageResourceId){
MaterialDialog dialog = new MaterialDialog.Builder(BaseActivity.currentActivity)

View File

@@ -46,6 +46,39 @@ public class SessionHelper {
return SharedPrefsHelper.isCustomerLoggedIn();
}
public static void setUserSeenPizzapassCampaign(boolean isSeen){
SharedPrefsHelper.setUserSeenPizzapassCampaign(isSeen);
}
public static boolean isUserSeenPizzapassCampaign(){
return SharedPrefsHelper.isUserSeenPizzapassCampaign();
}
public static void setUserUsedPizzapassCampaign(boolean isUsed){
SharedPrefsHelper.setUserUsedPizzapassCampaign(isUsed);
}
public static boolean isUserUsedPizzapassCampaign(){
return SharedPrefsHelper.isUserUsedPizzapassCampaign();
}
public static void setUserSeenChampagneCampaign(boolean isUsed){
SharedPrefsHelper.setUserSeenChampagneCampaign(isUsed);
}
public static boolean isUserSeenChampagneCampaign(){
return SharedPrefsHelper.isUserSeenChampagneCampaign();
}
public static void setUserUsedChampagneCampaign(boolean isUsed){
SharedPrefsHelper.setUserUsedChampagneCampaign(isUsed);
}
public static boolean isUserUsedChampagneCampaign(){
return SharedPrefsHelper.isUserUsedChampagneCampaign();
}
public static void logOut(){
setCustomerLoggedIn(false);
clearCustomerToken();

View File

@@ -34,6 +34,10 @@ public class SharedPrefsHelper {
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_SEEN_PIZZAPASS_CAMPAIGN = SHARED_PREFS_NAME + "userSeenPizzapassCampaign";
private static final String PREF_KEY_USER_USED_PIZZAPASS_CAMPAIGN = SHARED_PREFS_NAME + "userUsedPizzapassCampaign";
private static final String PREF_KEY_USER_SEEN_CHAMPAGNE_CAMPAIGN = SHARED_PREFS_NAME + "userSeenChampagneCampaign";
private static final String PREF_KEY_USER_USED_CHAMPAGNE_CAMPAIGN = SHARED_PREFS_NAME + "userUsedChampagneCampaign";
private static SharedPreferences sharedPreferences =
BaseActivity.currentActivity
@@ -89,6 +93,10 @@ public class SharedPrefsHelper {
editor.remove(PREF_KEY_CUSTOMER_TOKEN);
editor.remove(PREF_KEY_CART_ITEM_COUNT);
editor.remove(PREF_KEY_CART_TOTAL_PRICE);
editor.remove(PREF_KEY_USER_SEEN_PIZZAPASS_CAMPAIGN);
editor.remove(PREF_KEY_USER_USED_PIZZAPASS_CAMPAIGN);
editor.remove(PREF_KEY_USER_SEEN_CHAMPAGNE_CAMPAIGN);
editor.remove(PREF_KEY_USER_USED_CHAMPAGNE_CAMPAIGN);
editor.apply();
}
@@ -115,6 +123,42 @@ public class SharedPrefsHelper {
return sharedPreferences.getBoolean(PREF_KEY_USER_LOG_IN_STATUS, false);
}
public static void setUserSeenPizzapassCampaign(boolean isSeen){
editor.putBoolean(PREF_KEY_USER_SEEN_PIZZAPASS_CAMPAIGN, isSeen);
editor.apply();
}
public static boolean isUserSeenPizzapassCampaign(){
return sharedPreferences.getBoolean(PREF_KEY_USER_SEEN_PIZZAPASS_CAMPAIGN, false);
}
public static void setUserUsedPizzapassCampaign(boolean isUsed){
editor.putBoolean(PREF_KEY_USER_USED_PIZZAPASS_CAMPAIGN, isUsed);
editor.apply();
}
public static boolean isUserUsedPizzapassCampaign(){
return sharedPreferences.getBoolean(PREF_KEY_USER_USED_PIZZAPASS_CAMPAIGN, false);
}
public static void setUserSeenChampagneCampaign(boolean isSeen){
editor.putBoolean(PREF_KEY_USER_SEEN_CHAMPAGNE_CAMPAIGN, isSeen);
editor.apply();
}
public static boolean isUserSeenChampagneCampaign(){
return sharedPreferences.getBoolean(PREF_KEY_USER_SEEN_CHAMPAGNE_CAMPAIGN, false);
}
public static void setUserUsedChampagneCampaign(boolean isUsed){
editor.putBoolean(PREF_KEY_USER_USED_CHAMPAGNE_CAMPAIGN, isUsed);
editor.apply();
}
public static boolean isUserUsedChampagneCampaign(){
return sharedPreferences.getBoolean(PREF_KEY_USER_USED_CHAMPAGNE_CAMPAIGN, false);
}
public static void setCartItemCount(int cartItemCount){
editor.putInt(PREF_KEY_CART_ITEM_COUNT, cartItemCount);
editor.apply();

View File

@@ -0,0 +1,177 @@
package ch.pizzapp.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

@@ -27,11 +27,25 @@ public class CategoryModel implements Serializable{
@SerializedName("children")
private ArrayList<CategoryModel> subCategoryList;
private String campaignCode;
public void checkNull(){
if(name == null)
name = "";
}
public CategoryModel(CampaignModel campaignModel){
try {
id = Integer.valueOf(campaignModel.getCategoryId());
}
catch (Exception e){
id = -1;
}
name = campaignModel.getName();
subCategoryList = new ArrayList<>();
campaignCode = campaignModel.getCode();
}
public static void checkNull(ArrayList<CategoryModel> categoryList){
for (CategoryModel categoryModel : categoryList){
categoryModel.checkNull();
@@ -79,4 +93,14 @@ public class CategoryModel implements Serializable{
public void setSubCategoryList(ArrayList<CategoryModel> subCategoryList) {
this.subCategoryList = subCategoryList;
}
public boolean isPizzapassCampaign() {
return campaignCode != null && campaignCode.toUpperCase().equals(ApiConstants.CAMPAIGN_CODE_PIZZAPASS);
}
public boolean isChampagneCampaign() {
return campaignCode != null && campaignCode.toUpperCase().equals(ApiConstants.CAMPAIGN_CODE_CHAMPAGNE);
}
}

View File

@@ -88,6 +88,9 @@
<string name="add_to_cart">IN DEN WARENKORB LEGEN</string>    
<string name="count">Stückzahl</string>    
<string name="no_options_selected_part">wurde nicht ausgewählt.</string>
<!-- tr -->
<string name="cannot_use_campaign">Bu kampanyadan daha önce yararlandığınız için sepetinize ekleyemezsiniz.</string>
<string name="restaurant_out_of_order">Restorant çalışma saatleri dışında olduğu için siparişinizi alamıyoruz.</string>
<!-- ProductPropertiesBottomSheetDialog -->
<!-- CartFragment-->    
@@ -167,6 +170,9 @@
<!-- CreateOrderResultFragment-->
<string name="order_successed">Ihre Bestellung ist erfolgreich. Ihre Bestellübersicht werden in der Bestellungshistorie angezeigt und kann dort verfolgt werden.</string>
<!-- tr -->
<string name="accept_campaign">EVET</string>
<string name="decline_campaign">HAYIR</string>
<!-- CreateOrderSummaryFragment-->
<!-- ProfileFragment-->    

View File

@@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files