campaign fix
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@@ -21,6 +21,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
|
||||
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<activity
|
||||
android:name=".activity.CreateOrderActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan"/>
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.ForgotPasswordActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@@ -51,11 +51,13 @@
|
||||
android:name=".activity.UpdateProfileActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.ProductPropertiesActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:name=".activity.ProductDetailsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.OrderHistoryDetailsActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name=".activity.CampaignProductListActivity" />
|
||||
<activity android:name=".activity.CampaignProductDetailsActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,399 @@
|
||||
package ch.pizzapp.android.activity;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
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 java.util.ArrayList;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import ch.pizzapp.android.R;
|
||||
import ch.pizzapp.android.adapter.recycler.ProductCheckboxOptionsRecyclerAdapter;
|
||||
import ch.pizzapp.android.adapter.recycler.ProductRadioOptionsRecyclerAdapter;
|
||||
import ch.pizzapp.android.api.ApiConstants;
|
||||
import ch.pizzapp.android.api.ApiEndPoints;
|
||||
import ch.pizzapp.android.api.ApiErrorUtils;
|
||||
import ch.pizzapp.android.api.ApiService;
|
||||
import ch.pizzapp.android.api.ResponseObject;
|
||||
import ch.pizzapp.android.helper.DialogHelper;
|
||||
import ch.pizzapp.android.helper.ImageLoadHelper;
|
||||
import ch.pizzapp.android.helper.PriceHelper;
|
||||
import ch.pizzapp.android.helper.SessionHelper;
|
||||
import ch.pizzapp.android.helper.SharedPrefsHelper;
|
||||
import ch.pizzapp.android.helper.TextHelper;
|
||||
import ch.pizzapp.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzapp.android.model.AddProductToBasketResponseModel;
|
||||
import ch.pizzapp.android.model.CampaignModel;
|
||||
import ch.pizzapp.android.model.cart.CartInfoModel;
|
||||
import ch.pizzapp.android.model.menu.MenuProductModel;
|
||||
import ch.pizzapp.android.model.menu.MenuProductOptionModel;
|
||||
import ch.pizzapp.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.addToCartButton) Button addToCartButton;
|
||||
@BindView(R.id.radioRecyclerHeaderTextView) TextView radioRecyclerHeaderTextView;
|
||||
@BindView(R.id.radioRecyclerView) RecyclerView radioRecyclerView;
|
||||
@BindView(R.id.checkboxRecyclerHeaderTextView) TextView checkboxRecyclerHeaderTextView;
|
||||
@BindView(R.id.checkboxRecyclerView) RecyclerView checkboxRecyclerView;
|
||||
@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 ArrayList<MenuProductOptionValueModel> productRadioOptionValueList = new ArrayList<>();
|
||||
private ArrayList<MenuProductOptionValueModel> productCheckboxOptionValueList = new ArrayList<>();
|
||||
private ProductRadioOptionsRecyclerAdapter productRadioOptionsRecyclerAdapter;
|
||||
private ProductCheckboxOptionsRecyclerAdapter productCheckboxOptionsRecyclerAdapter;
|
||||
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()){
|
||||
if((campaignModel.getCode().equals(ApiConstants.CAMPAIGN_CODE_PIZZAPASS) && SessionHelper.isUserUsedPizzapassCampaign()) ||
|
||||
(campaignModel.getCode().equals(ApiConstants.CAMPAIGN_CODE_CHAMPAGNE) && SessionHelper.isUserUsedChampagneCampaign())){
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getDataFromIntent(){
|
||||
menuProductModel = (MenuProductModel) getIntent().getSerializableExtra("menuProductModel");
|
||||
campaignModel = (CampaignModel) getIntent().getSerializableExtra("campaignModel");
|
||||
}
|
||||
private void initViews(){
|
||||
setFields();
|
||||
fillRadioAndCheckboxOptionLists();
|
||||
switch (menuProductModel.getProductOptionType()){
|
||||
case RADIO_AND_CHECKBOX:
|
||||
radioRecyclerView.setVisibility(View.VISIBLE);
|
||||
checkboxRecyclerView.setVisibility(View.VISIBLE);
|
||||
radioRecyclerHeaderTextView.setVisibility(View.VISIBLE);
|
||||
checkboxRecyclerHeaderTextView.setVisibility(View.VISIBLE);
|
||||
initRadioRecyclerView();
|
||||
initCheckboxRecyclerView();
|
||||
break;
|
||||
case RADIO:
|
||||
radioRecyclerHeaderTextView.setVisibility(View.VISIBLE);
|
||||
radioRecyclerView.setVisibility(View.VISIBLE);
|
||||
checkboxRecyclerView.setVisibility(View.GONE);
|
||||
checkboxRecyclerHeaderTextView.setVisibility(View.GONE);
|
||||
initRadioRecyclerView();
|
||||
break;
|
||||
case CHECKBOX:
|
||||
radioRecyclerHeaderTextView.setVisibility(View.GONE);
|
||||
radioRecyclerView.setVisibility(View.GONE);
|
||||
checkboxRecyclerHeaderTextView.setVisibility(View.VISIBLE);
|
||||
checkboxRecyclerView.setVisibility(View.VISIBLE);
|
||||
initCheckboxRecyclerView();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMenuProductModel(MenuProductModel menuProductModel){
|
||||
this.menuProductModel = menuProductModel;
|
||||
}
|
||||
|
||||
private void initRadioRecyclerView(){
|
||||
radioRecyclerView.setNestedScrollingEnabled(false);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(BaseActivity.currentActivity, 1);
|
||||
radioRecyclerView.setLayoutManager(gridLayoutManager);
|
||||
productRadioOptionsRecyclerAdapter = new ProductRadioOptionsRecyclerAdapter(productRadioOptionValueList, new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
if(!productRadioOptionValueList.get(position).isSelected()){
|
||||
for(MenuProductOptionValueModel menuProductOptionValueModel : productRadioOptionValueList){
|
||||
menuProductOptionValueModel.setSelected(false);
|
||||
}
|
||||
productRadioOptionValueList.get(position).setSelected(true);
|
||||
productRadioOptionsRecyclerAdapter.notifyDataSetChanged();
|
||||
productPriceTextView.setText(PriceHelper.calculatePriceAfterRadioOptionValueChanged(
|
||||
productCount, menuProductModel, productRadioOptionValueList.get(position)));
|
||||
}
|
||||
}
|
||||
});
|
||||
radioRecyclerView.setAdapter(productRadioOptionsRecyclerAdapter);
|
||||
}
|
||||
|
||||
private void initCheckboxRecyclerView(){
|
||||
checkboxRecyclerView.setNestedScrollingEnabled(false);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(BaseActivity.currentActivity, 1);
|
||||
checkboxRecyclerView.setLayoutManager(gridLayoutManager);
|
||||
productCheckboxOptionsRecyclerAdapter = new ProductCheckboxOptionsRecyclerAdapter(productCheckboxOptionValueList, new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
productCheckboxOptionValueList.get(position).setSelected(
|
||||
!productCheckboxOptionValueList.get(position).isSelected());
|
||||
productCheckboxOptionsRecyclerAdapter.notifyItemChanged(position);
|
||||
productPriceTextView.setText(
|
||||
PriceHelper.calculatePriceAfterCheckboxOptionValueChanged(
|
||||
productCount, menuProductModel, productCheckboxOptionValueList));
|
||||
}
|
||||
});
|
||||
checkboxRecyclerView.setAdapter(productCheckboxOptionsRecyclerAdapter);
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
private void fillRadioAndCheckboxOptionLists(){
|
||||
for(MenuProductOptionModel menuProductOptionModel : menuProductModel.getProductOptionList()){
|
||||
setSelectedPriceShowingOptions(menuProductOptionModel);
|
||||
|
||||
if(menuProductOptionModel.getType().toLowerCase().equals("radio") ||
|
||||
menuProductOptionModel.getType().toLowerCase().equals("select")){
|
||||
radioRecyclerHeaderTextView.setText(menuProductOptionModel.getName());
|
||||
productRadioOptionValueList.addAll(menuProductOptionModel.getOptionValueModelList());
|
||||
}
|
||||
else{
|
||||
checkboxRecyclerHeaderTextView.setText(menuProductOptionModel.getName());
|
||||
productCheckboxOptionValueList.addAll(menuProductOptionModel.getOptionValueModelList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addProductToCart(){
|
||||
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<ResponseObject<AddProductToBasketResponseModel>> call =
|
||||
ApiService.apiInterface.addProductsToBasket(
|
||||
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()){
|
||||
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, response.body().getData().getSuccessMessage());
|
||||
getCartItemCount();
|
||||
}
|
||||
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(){
|
||||
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
|
||||
ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
|
||||
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()));
|
||||
if(campaignModel.getCode().equals(ApiConstants.CAMPAIGN_CODE_PIZZAPASS)){
|
||||
SessionHelper.setUserUsedPizzapassCampaign(true);
|
||||
}
|
||||
else if(campaignModel.getCode().equals(ApiConstants.CAMPAIGN_CODE_CHAMPAGNE)){
|
||||
SessionHelper.setUserUsedChampagneCampaign(true);
|
||||
}
|
||||
|
||||
/*
|
||||
MainActivity mainActivity = (MainActivity) getActivity();
|
||||
mainActivity.setCartItemCount();
|
||||
*/
|
||||
setResult(RESULT_OK);
|
||||
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private boolean checkFields(){
|
||||
|
||||
if(radioRecyclerView.getVisibility() == View.VISIBLE &&
|
||||
!isSelectedAtLeastOne(productRadioOptionValueList)){
|
||||
DialogHelper.showAlertDialog(BaseActivity.currentActivity,
|
||||
radioRecyclerHeaderTextView.getText().toString() + " " + noOptionsSelectedText);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(checkboxRecyclerView.getVisibility() == View.VISIBLE &&
|
||||
!isSelectedAtLeastOne(productCheckboxOptionValueList)){
|
||||
DialogHelper.showAlertDialog(BaseActivity.currentActivity,
|
||||
checkboxRecyclerHeaderTextView.getText().toString() + " " + 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package ch.pizzapp.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.pizzapp.android.R;
|
||||
import ch.pizzapp.android.adapter.recycler.MenuProductRecyclerAdapter;
|
||||
import ch.pizzapp.android.api.ApiErrorUtils;
|
||||
import ch.pizzapp.android.api.ApiService;
|
||||
import ch.pizzapp.android.api.ResponseArray;
|
||||
import ch.pizzapp.android.helper.DialogHelper;
|
||||
import ch.pizzapp.android.helper.DisplayHelper;
|
||||
import ch.pizzapp.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzapp.android.model.CampaignModel;
|
||||
import ch.pizzapp.android.model.menu.MenuProductModel;
|
||||
import ch.pizzapp.android.view.AppToolbar;
|
||||
import ch.pizzapp.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("isFromChampagneCampaign", categoryModel.isChampagneCampaign());
|
||||
startActivityForResult(productPropertiesIntent, REQUEST_CODE_CAMPAIGN_PRODUCT_PROPERTIES);
|
||||
}
|
||||
});
|
||||
campaignProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
campaignProductRecyclerView.setAdapter(menuProductRecyclerAdapter);
|
||||
}
|
||||
|
||||
private void getCampaignProducts(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<ResponseArray<MenuProductModel>> call = ApiService.apiInterface.getProductsByCategory(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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,7 +40,6 @@ 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;
|
||||
@@ -77,7 +76,6 @@ public class MainActivity extends BaseActivity {
|
||||
private NavigationMenuRecyclerAdapter navigationMenuRecyclerAdapter;
|
||||
//private Badge badge;
|
||||
private Animation animUp,animDown;
|
||||
private CampaignModel campaignModel;
|
||||
|
||||
private SectionedRecyclerViewAdapter sectionAdapter = new SectionedRecyclerViewAdapter();
|
||||
|
||||
@@ -95,9 +93,14 @@ public class MainActivity extends BaseActivity {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
setCartItemCount();
|
||||
}
|
||||
|
||||
private void getDataFromIntent(){
|
||||
isStartWithOrderHistory = getIntent().getBooleanExtra("isStartWithOrderHistory", false);
|
||||
campaignModel = (CampaignModel)getIntent().getSerializableExtra("campaignModel");
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
@@ -158,10 +161,6 @@ 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));
|
||||
}
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
package ch.pizzapp.android.activity;
|
||||
|
||||
import android.support.design.widget.BottomSheetBehavior;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
@@ -42,20 +29,17 @@ import ch.pizzapp.android.helper.SharedPrefsHelper;
|
||||
import ch.pizzapp.android.helper.TextHelper;
|
||||
import ch.pizzapp.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzapp.android.model.AddProductToBasketResponseModel;
|
||||
import ch.pizzapp.android.model.AddToBasketOptionModel;
|
||||
import ch.pizzapp.android.model.ZoneModel;
|
||||
import ch.pizzapp.android.model.cart.CartInfoModel;
|
||||
import ch.pizzapp.android.model.menu.MenuProductModel;
|
||||
import ch.pizzapp.android.model.menu.MenuProductOptionModel;
|
||||
import ch.pizzapp.android.model.menu.MenuProductOptionValueModel;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class ProductPropertiesActivity extends BaseActivity {
|
||||
public class ProductDetailsActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.closeImageView) ImageView closeImageView;
|
||||
@BindView(R.id.backIcon) ImageView backIcon;
|
||||
@@ -73,7 +57,6 @@ 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;
|
||||
|
||||
@@ -83,12 +66,11 @@ 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) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_product_properties);
|
||||
setContentView(R.layout.activity_product_details);
|
||||
ButterKnife.bind(this);
|
||||
getDataFromIntent();
|
||||
initViews();
|
||||
@@ -106,9 +88,6 @@ public class ProductPropertiesActivity extends BaseActivity {
|
||||
finish();
|
||||
break;
|
||||
case R.id.increaseProductCountImageView:
|
||||
if(isFromPizzapassCampaign || isFromChampagneCampaign){
|
||||
return;
|
||||
}
|
||||
productCount++;
|
||||
productCountTextView.setText(String.valueOf(productCount));
|
||||
productPriceTextView.setText(
|
||||
@@ -127,13 +106,7 @@ public class ProductPropertiesActivity extends BaseActivity {
|
||||
case R.id.addToCartButton:
|
||||
if(checkFields()){
|
||||
if(SessionHelper.isCustomerLoggedIn()){
|
||||
if((isFromPizzapassCampaign && SessionHelper.isUserUsedPizzapassCampaign()) ||
|
||||
(isFromChampagneCampaign && SessionHelper.isUserUsedChampagneCampaign())){
|
||||
DialogHelper.showAlertDialog(BaseActivity.currentActivity, cannotUseCampaignText);
|
||||
}
|
||||
else {
|
||||
addProductToCart();
|
||||
}
|
||||
addProductToCart();
|
||||
}
|
||||
else {
|
||||
DialogHelper.showNeedToLoginDialog(R.string.need_to_login_for_shopping);
|
||||
@@ -175,9 +148,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();
|
||||
fillRadioAndCheckboxOptionLists();
|
||||
@@ -367,12 +339,6 @@ 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();
|
||||
@@ -92,10 +92,15 @@ public class CartFragment extends BaseFragment {
|
||||
View view = inflater.inflate(R.layout.fragment_cart, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
initViews();
|
||||
getCartProducts();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getCartProducts();
|
||||
}
|
||||
|
||||
@OnClick({R.id.clearCartButton, R.id.continueCartButton})
|
||||
protected void onClick(View view){
|
||||
switch (view.getId()){
|
||||
|
||||
@@ -17,7 +17,7 @@ import butterknife.ButterKnife;
|
||||
import ch.pizzapp.android.R;
|
||||
import ch.pizzapp.android.activity.BaseActivity;
|
||||
import ch.pizzapp.android.activity.MainActivity;
|
||||
import ch.pizzapp.android.activity.ProductPropertiesActivity;
|
||||
import ch.pizzapp.android.activity.ProductDetailsActivity;
|
||||
import ch.pizzapp.android.adapter.recycler.MenuProductRecyclerAdapter;
|
||||
import ch.pizzapp.android.api.ApiErrorUtils;
|
||||
import ch.pizzapp.android.api.ApiService;
|
||||
@@ -102,10 +102,8 @@ public class MenuFragment extends BaseFragment {
|
||||
new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductPropertiesActivity.class);
|
||||
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductDetailsActivity.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));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import butterknife.ButterKnife;
|
||||
import ch.pizzapp.android.R;
|
||||
import ch.pizzapp.android.activity.BaseActivity;
|
||||
import ch.pizzapp.android.activity.MainActivity;
|
||||
import ch.pizzapp.android.activity.ProductPropertiesActivity;
|
||||
import ch.pizzapp.android.activity.ProductDetailsActivity;
|
||||
import ch.pizzapp.android.adapter.recycler.MenuProductRecyclerAdapter;
|
||||
import ch.pizzapp.android.api.ApiConstants;
|
||||
import ch.pizzapp.android.api.ApiErrorUtils;
|
||||
@@ -100,7 +100,7 @@ public class ProductFragment extends BaseFragment {
|
||||
new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductPropertiesActivity.class);
|
||||
Intent productPropertiesIntent = new Intent(BaseActivity.currentActivity, ProductDetailsActivity.class);
|
||||
productPropertiesIntent.putExtra("menuProductModel", productList.get(position));
|
||||
startActivityForResult(productPropertiesIntent, REQUEST_CODE_PRODUCT_PROPERTIES);
|
||||
//showBottomsheetDialog(productList.get(position));
|
||||
|
||||
@@ -3,6 +3,7 @@ package ch.pizzapp.android.fragment.createOrder;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -19,8 +20,8 @@ import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import ch.pizzapp.android.R;
|
||||
import ch.pizzapp.android.activity.BaseActivity;
|
||||
import ch.pizzapp.android.activity.CampaignProductListActivity;
|
||||
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;
|
||||
@@ -30,12 +31,15 @@ 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.CartInfoModel;
|
||||
import ch.pizzapp.android.model.cart.CartProductModel;
|
||||
import ch.pizzapp.android.view.AppInfoView;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 17/10/2017.
|
||||
*/
|
||||
@@ -63,6 +67,7 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
@BindString(R.string.something_went_wrong) String genericErrorText;
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "orderSummaryFragment";
|
||||
private int REQUEST_CODE_CAMPAIGN_PRODUCT_LIST = 7847;
|
||||
private CreateOrderActivity createOrderActivity;
|
||||
|
||||
public CreateOrderSummaryFragment() {}
|
||||
@@ -84,6 +89,15 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
return view;
|
||||
}
|
||||
|
||||
@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.previousTextView, R.id.nextTextView})
|
||||
protected void onClick(View view){
|
||||
CreateOrderActivity createOrderActivity = (CreateOrderActivity) getActivity();
|
||||
@@ -142,6 +156,20 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
}
|
||||
else {
|
||||
checkChampagneCampaign();
|
||||
/*
|
||||
// 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();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -183,9 +211,9 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
Intent campaignIntent = new Intent(BaseActivity.currentActivity, MainActivity.class);
|
||||
Intent campaignIntent = new Intent(BaseActivity.currentActivity, CampaignProductListActivity.class);
|
||||
campaignIntent.putExtra("campaignModel", campaignModel);
|
||||
BaseActivity.currentActivity.startActivity(campaignIntent);
|
||||
startActivityForResult(campaignIntent, REQUEST_CODE_CAMPAIGN_PRODUCT_LIST);
|
||||
}
|
||||
},
|
||||
R.string.decline_campaign,
|
||||
@@ -263,9 +291,9 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
Intent campaignIntent = new Intent(BaseActivity.currentActivity, MainActivity.class);
|
||||
Intent campaignIntent = new Intent(BaseActivity.currentActivity, CampaignProductListActivity.class);
|
||||
campaignIntent.putExtra("campaignModel", campaignModel);
|
||||
BaseActivity.currentActivity.startActivity(campaignIntent);
|
||||
startActivityForResult(campaignIntent, REQUEST_CODE_CAMPAIGN_PRODUCT_LIST);
|
||||
}
|
||||
},
|
||||
R.string.decline_campaign,
|
||||
@@ -384,4 +412,29 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
return containsAnyPizza;
|
||||
}
|
||||
|
||||
private void getCartProducts(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<ResponseObject<CartInfoModel>> call = ApiService.apiInterface.getCartProducts(
|
||||
ApiEndPoints.API_GET_CART_PRODUCTS + SessionHelper.getCustomerToken().getToken());
|
||||
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.setCartInfo(response.body().getData());
|
||||
}
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ResponseObject<CartInfoModel>> call, Throwable t) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,25 +27,11 @@ 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();
|
||||
@@ -94,13 +80,4 @@ public class CategoryModel implements Serializable{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public class AppToolbar extends Toolbar {
|
||||
|
||||
private View rootView;
|
||||
private TextView toolbarTitleTextView;
|
||||
private ImageView hamburgerIcon, backIcon;
|
||||
private boolean showHamburgerIcon, showBackIcon;
|
||||
private ImageView hamburgerIcon, backIcon, closeIcon;
|
||||
private boolean showHamburgerIcon, showBackIcon, showCloseIcon;
|
||||
private String title;
|
||||
private int toolbarBackgroundColor, titleTextColor;
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AppToolbar extends Toolbar {
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AppToolbar, 0, 0);
|
||||
try {
|
||||
showHamburgerIcon = a.getBoolean(R.styleable.AppToolbar_showHamburgerMenuIcon, false);
|
||||
showCloseIcon = a.getBoolean(R.styleable.AppToolbar_showCloseIcon, false);
|
||||
showBackIcon = a.getBoolean(R.styleable.AppToolbar_showBackIcon, false);
|
||||
title = a.getString(R.styleable.AppToolbar_title);
|
||||
/*
|
||||
@@ -65,17 +66,26 @@ public class AppToolbar extends Toolbar {
|
||||
//this.setBackgroundResource(toolbarBackgroundColor);
|
||||
//toolbarTitleTextView.setTextColor(titleTextColor);
|
||||
hamburgerIcon = (ImageView) rootView.findViewById(R.id.hamburgerIcon);
|
||||
closeIcon = (ImageView) rootView.findViewById(R.id.closeIcon);
|
||||
backIcon = (ImageView) rootView.findViewById(R.id.backIcon);
|
||||
if(showHamburgerIcon)
|
||||
hamburgerIcon.setVisibility(VISIBLE);
|
||||
if(showBackIcon)
|
||||
backIcon.setVisibility(VISIBLE);
|
||||
if(showCloseIcon)
|
||||
closeIcon.setVisibility(VISIBLE);
|
||||
backIcon.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
BaseActivity.currentActivity.onBackPressed();
|
||||
}
|
||||
});
|
||||
closeIcon.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
BaseActivity.currentActivity.onBackPressed();
|
||||
}
|
||||
});
|
||||
if(title != null) {
|
||||
toolbarTitleTextView.setText(title);
|
||||
toolbarTitleTextView.setVisibility(VISIBLE);
|
||||
|
||||
261
app/src/main/res/layout/activity_campaign_product_details.xml
Normal file
261
app/src/main/res/layout/activity_campaign_product_details.xml
Normal file
@@ -0,0 +1,261 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="MissingPrefix"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/white"
|
||||
tools:context="ch.pizzapp.android.activity.CampaignProductDetailsActivity">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/ic_back"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<!-- android:background="@color/cart_dialog_background" -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:background="@color/white">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backIcon"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:src="@drawable/ic_back"
|
||||
android:tint="@color/red"
|
||||
android:padding="8dp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/closeImageView"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:src="@drawable/ic_cancel"
|
||||
android:layout_gravity="right|end"
|
||||
android:padding="12dp"
|
||||
android:visibility="visible"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/productImageView"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_toRightOf="@+id/productImageView"
|
||||
android:layout_toEndOf="@+id/productImageView">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productNameTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/navy"
|
||||
android:textSize="18sp"
|
||||
android:padding="12sp"
|
||||
android:text="Pizza Formaggio"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productPriceTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/red"
|
||||
android:text="CHF 25.00"
|
||||
android:textSize="18sp"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productDescriptionTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:textColor="@color/navy"
|
||||
android:text="Mozzarella, Artischocken, Pilze, Peperoni, Oliven, Oregano"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/addToCartButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:text="@string/add_to_cart"
|
||||
style="@style/PizzalinkRedButton"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:text="@string/count"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/navy"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/ProductCountLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_margin="12dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/deccreaseProductCountImageView"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:padding="4dp"
|
||||
android:src="@drawable/ic_decrease"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productCountTextView"
|
||||
android:layout_width="24dp"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
android:includeFontPadding="false"
|
||||
android:lineSpacingExtra="0dp"
|
||||
android:textSize="24sp"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:layout_toRightOf="@+id/deccreaseProductCountImageView"
|
||||
android:layout_toEndOf="@+id/deccreaseProductCountImageView"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:textColor="@color/navy"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/increaseProductCountImageView"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:padding="4dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_toRightOf="@+id/productCountTextView"
|
||||
android:layout_toEndOf="@+id/productCountTextView"
|
||||
android:src="@drawable/ic_increase"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="@color/navy"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_marginEnd="12dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/radioRecyclerHeaderTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:padding="12dp"
|
||||
android:visibility="gone"
|
||||
android:text="Size"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/navy"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/radioRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="@color/navy"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_marginEnd="12dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/checkboxRecyclerHeaderTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:padding="12dp"
|
||||
android:visibility="gone"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/navy"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/checkboxRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
32
app/src/main/res/layout/activity_campaign_product_list.xml
Normal file
32
app/src/main/res/layout/activity_campaign_product_list.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="ch.pizzapp.android.activity.CampaignProductListActivity">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/background_wood"/>
|
||||
|
||||
<ch.pizzapp.android.view.AppToolbar
|
||||
android:id="@+id/campaignProductsAppToolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
app:showCloseIcon="true"
|
||||
app:title="@string/activity_title_login"
|
||||
app:titleTextColor="@color/navy" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/campaignProductRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_below="@+id/campaignProductsAppToolbar"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -74,7 +74,7 @@
|
||||
<com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
|
||||
android:id="@+id/bottomNavigationView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
app:itemIconTint="@drawable/selector_bottom_navigation_item"
|
||||
app:itemTextColor="@drawable/selector_bottom_navigation_item"
|
||||
android:background="@color/navy"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize">
|
||||
android:layout_height="?android:attr/actionBarSize">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/previousTextView"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="MissingPrefix"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:contentInsetLeft="0dp"
|
||||
android:contentInsetStart="0dp"
|
||||
app:contentInsetLeft="0dp"
|
||||
@@ -27,17 +27,27 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/hamburgerIcon"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_width="?android:attr/actionBarSize"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:padding="20dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_hamburger_menu"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/closeIcon"
|
||||
android:layout_width="?android:attr/actionBarSize"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:padding="20dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_cancel"
|
||||
android:tint="@color/white"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backIcon"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_width="?android:attr/actionBarSize"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:padding="20dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_back"
|
||||
@@ -54,8 +64,8 @@
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_width="?android:attr/actionBarSize"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:padding="12dp"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<declare-styleable name="AppToolbar">
|
||||
<attr name="showHamburgerMenuIcon" format="boolean" />
|
||||
<attr name="showBackIcon" format="boolean" />
|
||||
<attr name="showCloseIcon" format="boolean" />
|
||||
<attr name="title" format="string" />
|
||||
<attr name="toolbarBackgroundColor" format="reference" />
|
||||
<attr name="toolbarTitleTextColor" format="reference" />
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
<!-- General-->
|
||||
|
||||
<!-- SplashActivity -->
|
||||
<string name="no_network_message">Keine Internetverbindung. Bitte versuchen Sie es später noch einmal.</string>
|
||||
<string name="alert_update_app">Sie müssen die Pizzalink-Applikation aktualisieren, um sie zu verwenden.</string>
|
||||
<string name="no_network_message">Keine Internetverbindung. Bitte versuchen Sie es später noch einmal.</string>
|
||||
|
||||
<string name="alert_update_app">Sie müssen die Pizzalink-Applikation aktualisieren, um sie zu verwenden.</string>
|
||||
|
||||
<string name="update_app">AKTUALISIEREN</string>
|
||||
<!-- SplashActivity -->
|
||||
|
||||
@@ -48,7 +50,8 @@
|
||||
|
||||
<!-- ForgotPasswordActivity-->
|
||||
<string name="activity_title_forgot_password">Passwort vergessen</string>
|
||||
<string name="reset_password_hint"> Geben sie beim registrieren ihre E-Mail-Adresse ein und folgen Sie den Anweisungen.</string>
|
||||
<string name="reset_password_hint"> Geben sie beim registrieren ihre E-Mail-Adresse ein und folgen Sie den Anweisungen.</string>
|
||||
|
||||
<string name="reset_password_button">SENDEN</string>
|
||||
<string name="password_reset">Erforderliche Informationen wurden an Ihre E-Mail-Adresse geschickt. Folgen Sie den Anweisungen um Ihr Passwort zurückzusetzen.</string>
|
||||
<!-- ForgotPasswordActivity-->
|
||||
@@ -70,7 +73,8 @@
|
||||
<string name="alert_fill_all_fields">Bitte füllen Sie alle Felder aus.</string>
|
||||
<string name="alert_invalid_email">Bitte geben sie eine gültige E-Mail-Adresse ein.</string>
|
||||
<string name="alert_passwords_not_matched">Passwörter stimmen nicht überein.</string>
|
||||
<string name="alert_invalid_post_code">Bitte geben sie eine gültige Postleitzahl ein.</string>
|
||||
<string name="alert_invalid_post_code">Bitte geben sie eine gültige Postleitzahl ein.</string>
|
||||
|
||||
<string name="alert_select_country_first">Bitte wählen Sie zuerst ein Land.</string>
|
||||
<string name="button_register">REGISTRIEREN</string>
|
||||
<!-- RegisterActivity-->
|
||||
@@ -97,7 +101,8 @@
|
||||
<string name="continue_cart">WEITER</string>
|
||||
<string name="clear_cart">LÖSCHEN</string>
|
||||
<string name="no_product_on_cart">Es befindet sich kein Produkt im Warenkorb.</string>
|
||||
<string name="alert_remove_prdocut_from_cart">Möchten Sie das Produkt aus dem Warenkorb entfernen?</string>
|
||||
<string name="alert_remove_prdocut_from_cart">Möchten Sie das Produkt aus dem Warenkorb entfernen?</string>
|
||||
|
||||
<string name="product_removed_from_cart">Produkt wurde aus dem Warenkorb entfernt.</string>
|
||||
<string name="alert_clear_cart">Möchten Sie alle Produkte aus dem Warenkorb entfernen?</string>
|
||||
<!-- CartFragment-->
|
||||
|
||||
Reference in New Issue
Block a user