add to cart actions
This commit is contained in:
@@ -45,6 +45,7 @@ dependencies {
|
||||
compile 'com.github.AndroidDeveloperLB:DialogShard:3'
|
||||
compile 'com.github.HITGIF:TextFieldBoxes:1.3.3'
|
||||
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.1.3'
|
||||
compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
|
||||
compile 'q.rorbin:badgeview:1.1.0'
|
||||
testCompile 'junit:junit:4.12'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
|
||||
|
||||
@@ -131,6 +131,7 @@ public class LoginActivity extends BaseActivity {
|
||||
response.body().isSuccess()){
|
||||
SharedPrefsHelper.setCartItemCount(response.body().getData().getProducts().size());
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
finishAffinity();
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindString;
|
||||
@@ -102,12 +103,7 @@ public class RegisterActivity extends BaseActivity {
|
||||
|
||||
private void registerUser(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<ResponseObject<UserModel>> call = ApiService.apiInterface.register(
|
||||
pizzalinkEditTextList.get(0).getText(), pizzalinkEditTextList.get(1).getText(),
|
||||
pizzalinkEditTextList.get(2).getText(), pizzalinkEditTextList.get(3).getText(),
|
||||
pizzalinkEditTextList.get(4).getText(), pizzalinkEditTextList.get(5).getText(),
|
||||
pizzalinkEditTextList.get(6).getText(), "",
|
||||
pizzalinkEditTextList.get(7).getText(), pizzalinkEditTextList.get(8).getText(), "1","1");
|
||||
Call<ResponseObject<UserModel>> call = ApiService.apiInterface.register(getRegisterParams());
|
||||
call.enqueue(new Callback<ResponseObject<UserModel>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseObject<UserModel>> call, Response<ResponseObject<UserModel>> response) {
|
||||
@@ -120,6 +116,7 @@ public class RegisterActivity extends BaseActivity {
|
||||
SharedPrefsHelper.saveCustomerToken(response.body().getData().getToken());
|
||||
SharedPrefsHelper.setCustomerLoggedIn(true);
|
||||
startActivity(new Intent(RegisterActivity.this, MainActivity.class));
|
||||
finishAffinity();
|
||||
}
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
@@ -133,11 +130,28 @@ public class RegisterActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private HashMap<String, Object> getRegisterParams(){
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("firstname", pizzalinkEditTextList.get(0).getText());
|
||||
params.put("lastname", pizzalinkEditTextList.get(1).getText());
|
||||
params.put("telephone", pizzalinkEditTextList.get(2).getText());
|
||||
params.put("email", pizzalinkEditTextList.get(3).getText());
|
||||
params.put("password", pizzalinkEditTextList.get(4).getText());
|
||||
params.put("password1", pizzalinkEditTextList.get(5).getText());
|
||||
params.put("address_1", pizzalinkEditTextList.get(6).getText());
|
||||
params.put("address_2", "");
|
||||
params.put("city", pizzalinkEditTextList.get(7).getText());
|
||||
params.put("postcode", pizzalinkEditTextList.get(8).getText());
|
||||
params.put("country_id", "1");
|
||||
params.put("zone_id", "1");
|
||||
return params;
|
||||
}
|
||||
|
||||
private void setTestFields(){
|
||||
pizzalinkEditTextList.get(0).getEditText().setText("testname");
|
||||
pizzalinkEditTextList.get(1).getEditText().setText("testsurname");
|
||||
pizzalinkEditTextList.get(2).getEditText().setText("1234567890");
|
||||
pizzalinkEditTextList.get(3).getEditText().setText("test2@test.com");
|
||||
pizzalinkEditTextList.get(3).getEditText().setText("test3@test.com");
|
||||
pizzalinkEditTextList.get(4).getEditText().setText("test");
|
||||
pizzalinkEditTextList.get(5).getEditText().setText("test");
|
||||
pizzalinkEditTextList.get(6).getEditText().setText("test address 1");
|
||||
|
||||
@@ -41,7 +41,6 @@ public class SplashActivity extends BaseActivity {
|
||||
getCategoryList();
|
||||
else
|
||||
DialogHelper.showNoNetworkDialog();
|
||||
//startActivity(new Intent(this, MainActivity.class));
|
||||
}
|
||||
|
||||
private void getCategoryList(){
|
||||
|
||||
@@ -15,6 +15,7 @@ public class ApiEndPoints {
|
||||
public static final String API_GET_PRODUCTS_BY_CATEGORY = PREFIX + "getProductsByCategory" + SUFFIX;
|
||||
public static final String API_GET_PRODUCT = PREFIX + "getProduct" + SUFFIX;
|
||||
//public static final String API_ADD_PRODUCTS_TO_BASKET = PREFIX + "addProductsToBasket" + SUFFIX + "&token=sor37aVmOYP1v4OxpCsv11w3DkeGDttB";
|
||||
public static final String API_ADD_PRODUCTS_TO_BASKET = PREFIX + "addProductsToBasket" + SUFFIX;
|
||||
//public static final String API_ADD_PRODUCTS_TO_BASKET = PREFIX + "addProductsToBasket" + SUFFIX;
|
||||
public static final String API_ADD_PRODUCTS_TO_BASKET = PREFIX + "addProductsToBasket" + SUFFIX + "&token=";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ch.pizzalink.android.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import ch.pizzalink.android.model.AddProductToBasketResponseModel;
|
||||
@@ -10,14 +9,13 @@ import ch.pizzalink.android.model.OrderModel;
|
||||
import ch.pizzalink.android.model.UserModel;
|
||||
import ch.pizzalink.android.model.menu.MenuProductModel;
|
||||
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.Header;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
import retrofit2.http.Url;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 04/02/2017.
|
||||
@@ -28,6 +26,7 @@ public interface ApiInterface {
|
||||
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
|
||||
Call<ResponseArray<CategoryModel>> getAllCategories();
|
||||
|
||||
/*
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_REGISTER)
|
||||
Call<ResponseObject<UserModel>> register(@Field("firstname") String firstname,
|
||||
@@ -42,6 +41,13 @@ public interface ApiInterface {
|
||||
@Field("postcode") String postcode,
|
||||
@Field("country_id") String country_id,
|
||||
@Field("zone_id") String zone_id);
|
||||
*/
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_REGISTER)
|
||||
Call<ResponseObject<UserModel>> register(@FieldMap HashMap<String, Object> body);
|
||||
|
||||
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_LOGIN)
|
||||
@@ -67,174 +73,9 @@ public interface ApiInterface {
|
||||
@POST(ApiEndPoints.API_GET_PRODUCT)
|
||||
Call<ResponseArray<MenuProductModel>> getProductById(@Field("product_id") int productId);
|
||||
|
||||
@POST(ApiEndPoints.API_ADD_PRODUCTS_TO_BASKET)
|
||||
Call<ResponseObject<AddProductToBasketResponseModel>> addProductsToBasket(@Body HashMap<String, Object> body);
|
||||
|
||||
/*
|
||||
// default encoded is false
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_ADD_PRODUCTS_TO_BASKET)
|
||||
Call<ResponseObject<AddProductToBasketResponseModel>> addProductsToBasket(@FieldMap(encoded = true) HashMap<String, Object> fields);
|
||||
*/
|
||||
@POST
|
||||
Call<ResponseObject<AddProductToBasketResponseModel>> addProductsToBasket(@Url String url,
|
||||
@FieldMap HashMap<String, Object> body);
|
||||
|
||||
|
||||
/*
|
||||
{
|
||||
"product_id": "56",
|
||||
"quantity": "1",
|
||||
"token": "wXTVshBk2TU4XJmb23wa320zOBRodw4K",
|
||||
"options": [
|
||||
{
|
||||
"optionId" : "232",
|
||||
"optionValue" : "34"
|
||||
},
|
||||
{
|
||||
"optionId" : "232",
|
||||
"optionValue" : "33"
|
||||
},
|
||||
{
|
||||
"optionId" : "231",
|
||||
"optionValue" : "31"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
|
||||
Call<CategoryListResponseModel> getAllCategories();
|
||||
|
||||
@GET(ApiEndPoints.API_GET_ALL_AUTHORS)
|
||||
Call<AuthorListResponseModel> getAllAuthors();
|
||||
|
||||
@GET(ApiEndPoints.API_GET_MAGAZINES)
|
||||
Call<MagazineListResponseModel> getMagazineList();
|
||||
|
||||
@GET(ApiEndPoints.API_GET_MAIN_PAGE_NEWS)
|
||||
Call<NewsListResponseModel> getMainPageNews();
|
||||
|
||||
@GET(ApiEndPoints.API_GET_NEWS_LIST_BY_CATEGORY)
|
||||
Call<NewsListResponseModel> getNewsListByCategory(@Query("category_id") String categoryId);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_NEWS_DETAILS)
|
||||
Call<NewsDetailsResponseModel> getNewsDetails(@Query("article_id") String articleId);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_NEWS_DETAILS)
|
||||
Call<NewsDetailsResponseModel> getVideoNewsDetails(@Query("article_id") String articleId, @Query("video") String video);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_TAGS_OF_NEWS)
|
||||
Call<NewsDetailsResponseModel> getTagsOfNews(@Query("getTagsByArticle") String articleId);
|
||||
|
||||
// NOT : tag ları yazarken boşluk yerine %20 işreti koy
|
||||
@GET(ApiEndPoints.API_GET_NEWS_LIST_BY_TAG)
|
||||
Call<NewsListResponseModel> getNewsListByTag(@Query("tag_name") String tagName);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_ARTICLES_OF_AUTHOR)
|
||||
Call<NewsListResponseModel> getArticlesOfAuthor(@Query("author_id") String authorId);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_ARTICLE_DETAILS)
|
||||
Call<NewsDetailsResponseModel> getArticleDetails(@Query("article_id") String articleId);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_EVENT_LOCATIONS)
|
||||
Call<EventLocationListResponseModel> getEventLocations();
|
||||
|
||||
@GET(ApiEndPoints.API_GET_CURRENT_EVENTS)
|
||||
Call<EventListResponseModel> getCurrentEvents();
|
||||
|
||||
@GET(ApiEndPoints.API_GET_CURRENT_EVENTS)
|
||||
Call<EventListResponseModel> getCurrentEvents(@Query("location") String locationName);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_UPCOMING_EVENTS)
|
||||
Call<EventListResponseModel> getUpcomingEvents(@Query("day") String dayCount);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_UPCOMING_EVENTS)
|
||||
Call<EventListResponseModel> getUpcomingEvents(@Query("day") String dayCount, @Query("location") String locationName);
|
||||
|
||||
@GET(ApiEndPoints.API_GET_SQUARE_ADS)
|
||||
Call<AdResponseModel> getSquareAds();
|
||||
|
||||
@GET(ApiEndPoints.API_GET_BANNER_ADS)
|
||||
Call<AdResponseModel> getBannerAds();
|
||||
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_CUSTOMER_LOGIN)
|
||||
Call<LoginCustomerResponseModel> loginUser(@Field("email") String email, @Field("password") String password);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_CUSTOMER_LOG_OUT)
|
||||
Call<ResponseModel> logoutUser(@Field("token") String customerToken);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_REGISTER_CUSTOMER)
|
||||
Call<LoginCustomerResponseModel> registerCustomer(@Field("customer_name") String name, @Field("customer_surname") String surname,
|
||||
@Field("customer_mail") String email, @Field("customer_phone") String phone,
|
||||
@Field("customer_password") String password);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_GET_CUSTOMER_INFO)
|
||||
Call<CustomerInfoResponseModel> getCustomerInfo(@Field("token") String customerToken);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_GET_STORE_CUSTOMER_INFO)
|
||||
Call<StoreCustomerInfoResponseModel> getStoreCustomerInfo(@Field("token") String customerToken);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_REFRESH_CUSTOMER_TOKEN)
|
||||
Call<RefreshTokenResponseModel> refreshCustomerToken(@Field("refresh_token") String refreshToken);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_REFRESH_STORE_CUSTOMER_TOKEN)
|
||||
Call<RefreshTokenResponseModel> refreshStoreCustomerToken(@Field("refresh_token") String refreshToken);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_GET_ALL_CAMPAIGNS)
|
||||
Call<AllCampaignsResponseModel> getAllCampaigns(@Field("token") String customerToken);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_GET_CAMPAIGN_DETAILS)
|
||||
Call<AllCampaignsResponseModel> getCampaignDetails(@Field("token") String customerToken,
|
||||
@Field("campaign_id") String campaignId);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_GET_CAMPAIGN_LIST_OF_COMPANY)
|
||||
Call<AllCampaignsResponseModel> getCampaingsOfCompany(@Field("token") String customerToken,
|
||||
@Field("firm_barcode") String firmBarcode);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_STORE_CUSTOMER_LOGIN)
|
||||
Call<LoginStoreCustomerResponseModel> loginStoreCustomer(@Field("username") String email, @Field("password") String password);
|
||||
|
||||
|
||||
@POST(ApiEndPoints.API_CUSTOMER_LOGIN)
|
||||
Call<LoginCustomerResponseModel> loginUser(@Body HashMap<String, Object> body);
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
@@ -27,8 +28,10 @@ public class 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);
|
||||
@@ -45,6 +48,10 @@ public class ApiService {
|
||||
}
|
||||
});
|
||||
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); // set your desired log level
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
builder.addInterceptor(logging);
|
||||
|
||||
OkHttpClient client = builder.build();
|
||||
|
||||
retrofit = new Retrofit.Builder()
|
||||
|
||||
@@ -25,6 +25,7 @@ import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.activity.MainActivity;
|
||||
import ch.pizzalink.android.adapter.recycler.ProductCheckboxOptionsRecyclerAdapter;
|
||||
import ch.pizzalink.android.adapter.recycler.ProductRadioOptionsRecyclerAdapter;
|
||||
import ch.pizzalink.android.api.ApiEndPoints;
|
||||
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.api.ResponseObject;
|
||||
@@ -222,7 +223,7 @@ public class ProductPropertiesBottomSheetDialog extends BottomSheetDialogFragmen
|
||||
private void addProductToCart(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<ResponseObject<AddProductToBasketResponseModel>> call =
|
||||
ApiService.apiInterface.addProductsToBasket(getAddToCartRequestParams());
|
||||
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) {
|
||||
@@ -234,6 +235,8 @@ public class ProductPropertiesBottomSheetDialog extends BottomSheetDialogFragmen
|
||||
SharedPrefsHelper.setCartItemCount(SharedPrefsHelper.getCartItemCount() + 1);
|
||||
MainActivity mainActivity = (MainActivity) getActivity();
|
||||
mainActivity.setCartItemCount();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, response.body().getData().getErrorMessage());
|
||||
@@ -254,29 +257,36 @@ public class ProductPropertiesBottomSheetDialog extends BottomSheetDialogFragmen
|
||||
private HashMap<String, Object> getAddToCartRequestParams(){
|
||||
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("product_id", menuProductModel.getId());
|
||||
params.put("quantity", productCount);
|
||||
|
||||
for(MenuProductOptionModel productOptionModel : menuProductModel.getProductOptionList()){
|
||||
|
||||
ArrayList<String> selectedOptionsList = new ArrayList<>();
|
||||
ArrayList<String> selectedCheckboxOptionList = new ArrayList<>();
|
||||
|
||||
for(MenuProductOptionValueModel productOptionValueModel : productOptionModel.getOptionValueModelList()){
|
||||
|
||||
if(productOptionValueModel.isSelected()){
|
||||
selectedOptionsList.add(productOptionValueModel.getProductOptionValueId());
|
||||
//params.put("product[" + productOptionModel.getProductOptionId() + "]", productOptionValueModel.getProductOptionValueId());
|
||||
|
||||
|
||||
if(productOptionModel.getType().equals("checkbox")){
|
||||
selectedCheckboxOptionList.add(productOptionValueModel.getProductOptionValueId());
|
||||
}
|
||||
else {
|
||||
params.put("option[" + productOptionModel.getProductOptionId() + "]", productOptionValueModel.getProductOptionValueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
params.put("product[" + productOptionModel.getProductOptionId() + "]", selectedOptionsList);
|
||||
if(productOptionModel.getType().equals("checkbox")){
|
||||
params.put("option[" + productOptionModel.getProductOptionId() + "]", selectedCheckboxOptionList);
|
||||
}
|
||||
|
||||
}
|
||||
params.put("product_id", menuProductModel.getId());
|
||||
params.put("token", SessionHelper.getCustomerToken().getToken());
|
||||
params.put("quantity", productCount);
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkFields(){
|
||||
|
||||
if(radioRecyclerView.getVisibility() == View.VISIBLE &&
|
||||
@@ -305,12 +315,4 @@ public class ProductPropertiesBottomSheetDialog extends BottomSheetDialogFragmen
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void onItemClick(Item item) {
|
||||
mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.pizzalink.android.fragment;
|
||||
|
||||
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;
|
||||
@@ -11,6 +12,9 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindColor;
|
||||
@@ -52,6 +56,8 @@ public class CartFragment extends BaseFragment {
|
||||
@BindView(R.id.clearCartButton) Button clearCartButton;
|
||||
|
||||
@BindString(R.string.bottom_nav_menu_item_cart) String fragmentTitle;
|
||||
@BindString(R.string.alert_clear_cart) String clearCartAlertText;
|
||||
|
||||
|
||||
@BindColor(R.color.actvity_default_background_color_1) int grayColor;
|
||||
@BindColor(R.color.white) int whiteColor;
|
||||
@@ -85,7 +91,18 @@ public class CartFragment extends BaseFragment {
|
||||
protected void onClick(View view){
|
||||
switch (view.getId()){
|
||||
case R.id.clearCartButton:
|
||||
clearCart();
|
||||
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:
|
||||
break;
|
||||
|
||||
@@ -2,11 +2,15 @@ package ch.pizzalink.android.fragment;
|
||||
|
||||
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 android.widget.Button;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -33,6 +37,8 @@ public class ProfileFragment extends BaseFragment {
|
||||
@BindView(R.id.logoutButton) Button logoutButton;
|
||||
|
||||
@BindString(R.string.bottom_nav_menu_item_profile) String fragmentTitle;
|
||||
@BindString(R.string.alert_logout) String logoutAlertText;
|
||||
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "profileFragment";
|
||||
|
||||
@@ -57,7 +63,18 @@ public class ProfileFragment extends BaseFragment {
|
||||
|
||||
@OnClick(R.id.logoutButton)
|
||||
public void onClick(View view){
|
||||
logOutOnWeb();
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,11 +13,18 @@ public class DialogHelper {
|
||||
|
||||
private static MaterialDialog loadingDialog;
|
||||
|
||||
public static void showDialogWithPositiveButton(Context context, String content) {
|
||||
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(R.string.alert)
|
||||
.content(content)
|
||||
.title(title)
|
||||
.content(message)
|
||||
.positiveText(R.string.ok)
|
||||
.positiveColor(ContextCompat.getColor(context, R.color.colorPrimary))
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@@ -83,19 +90,17 @@ public class DialogHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
public static void showDialogWithPositiveButtonCallback(Context context, String content,
|
||||
MaterialDialog.SingleButtonCallback positiveButtonCallback) {
|
||||
|
||||
public static void showTwoButtonsDialog(Context context, String message,
|
||||
MaterialDialog.SingleButtonCallback positiveButtonCallback,
|
||||
MaterialDialog.SingleButtonCallback negativeButtonCallback){
|
||||
new MaterialDialog.Builder(context)
|
||||
.title(R.string.alert)
|
||||
.content(content)
|
||||
.content(message)
|
||||
.positiveText(R.string.ok)
|
||||
.positiveColor(ContextCompat.getColor(context, R.color.colorPrimary))
|
||||
.onPositive(positiveButtonCallback)
|
||||
.negativeText(R.string.cancel)
|
||||
.onNegative(negativeButtonCallback)
|
||||
.show();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import com.google.gson.annotations.SerializedName;
|
||||
public class AddProductToBasketResponseModel {
|
||||
|
||||
@Expose @SerializedName("success") private String successMessage;
|
||||
@Expose @SerializedName("parameter") private String errorMessage;
|
||||
@Expose @SerializedName("option") private String errorMessage;
|
||||
//@Expose @SerializedName("parameter") private String errorMessage;
|
||||
|
||||
public String getSuccessMessage() {
|
||||
return successMessage;
|
||||
|
||||
@@ -49,7 +49,8 @@
|
||||
android:id="@+id/emailPizzalinkEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:hint="@string/email"/>
|
||||
app:hint="@string/email"
|
||||
app:inputType="email"/>
|
||||
|
||||
<ch.pizzalink.android.view.PizzalinkEditText
|
||||
android:id="@+id/passwordPizzalinkEditText"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/cartInfoLayout"
|
||||
android:scrollbars="vertical"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
@@ -37,7 +38,7 @@
|
||||
<View
|
||||
android:id="@+id/cartDividerSpace"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_height="1dp"
|
||||
android:background="@drawable/shadow" />
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -96,7 +96,9 @@
|
||||
<string name="bad_request">Bad Request</string>
|
||||
<string name="failed">Connection failed</string>
|
||||
<string name="ok">Tamam</string>
|
||||
<string name="cancel">İptal</string>
|
||||
<string name="loading">Lütfen bekleyiniz...</string>
|
||||
<string name="alert_logout">Çıkış yapmak istediğinize emin misiniz?</string>
|
||||
|
||||
<string name="month_name_january">Jan.</string>
|
||||
<string name="month_name_february">Feb.</string>
|
||||
@@ -117,6 +119,7 @@
|
||||
<string name="count">Count</string>
|
||||
|
||||
<string name="no_options_selected_part">is not selected.</string>
|
||||
<string name="alert_clear_cart">Sepetinizdeki ürünleri silmek istediğinize emin misiniz?</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user