User Voucher Info
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.
@@ -0,0 +1,68 @@
|
||||
package ch.pizzacucina.android.adapter.recycler;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import java.util.ArrayList;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzacucina.android.R;
|
||||
import ch.pizzacucina.android.activity.BaseActivity;
|
||||
import ch.pizzacucina.android.model.PersonalCouponModel;
|
||||
|
||||
public class PersonalCouponCodesRecyclerAdapter extends RecyclerView.Adapter<PersonalCouponCodesRecyclerAdapter.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private ArrayList<PersonalCouponModel> personalCouponCodeList;
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
@BindView(R.id.personalCouponCodeTextView) TextView personalCouponCodeTextView;
|
||||
@BindView(R.id.personalCouponTotalAmountTextView) TextView personalCouponTotalAmountTextView;
|
||||
@BindView(R.id.personalCouponRemainingAmountTextView) TextView personalCouponRemainingAmountTextView;
|
||||
@BindView(R.id.personalCouponStatusTextView) TextView personalCouponStatusTextView;
|
||||
|
||||
public ViewHolder(final View view) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
}
|
||||
}
|
||||
|
||||
public PersonalCouponCodesRecyclerAdapter(Context context,
|
||||
ArrayList<PersonalCouponModel> personalCouponCodeList){
|
||||
this.context = context;
|
||||
this.personalCouponCodeList = personalCouponCodeList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersonalCouponCodesRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
View root = LayoutInflater.from(BaseActivity.currentActivity).inflate(R.layout.row_personal_coupon_code, viewGroup, false);
|
||||
return new PersonalCouponCodesRecyclerAdapter.ViewHolder(root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PersonalCouponCodesRecyclerAdapter.ViewHolder holder, int position) {
|
||||
|
||||
holder.personalCouponCodeTextView.setText(personalCouponCodeList.get(position).getCode());
|
||||
holder.personalCouponTotalAmountTextView.setText(personalCouponCodeList.get(position).getAmount());
|
||||
holder.personalCouponRemainingAmountTextView.setText(personalCouponCodeList.get(position).getTotal());
|
||||
|
||||
String statusMessage = "";
|
||||
if(personalCouponCodeList.get(position).isActive()){
|
||||
statusMessage = context.getString(R.string.yes);
|
||||
}
|
||||
else {
|
||||
statusMessage = context.getString(R.string.no);
|
||||
}
|
||||
holder.personalCouponStatusTextView.setText(statusMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return personalCouponCodeList.size();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,5 +54,6 @@ public class ApiEndPoints {
|
||||
public static final String API_CREATE_BRAINTREE_PAYMENT_TOKEN = PREFIX + "createPaymentToken" + SUFFIX + "&token=";
|
||||
public static final String API_GET_DATATRANS_INFO = PREFIX + "getDatatransInfo" + SUFFIX + "&token=";
|
||||
public static final String API_CREATE_DATATRANS_PAYMENT = PREFIX + "checkDatatransPayment" + SUFFIX + "&token=";
|
||||
public static final String API_GET_PERSONAL_COUPONS = PREFIX + "getUserVouchers" + SUFFIX + "&token=";
|
||||
|
||||
}
|
||||
|
||||
@@ -252,7 +252,9 @@ public interface ApiInterface {
|
||||
@GET(ApiEndPoints.API_GET_CAMPAIGN_BANNERS)
|
||||
Call<ResponseArray<CampaignBannerModel>> getCampaignBanners();
|
||||
|
||||
|
||||
@GET("{storeName}" + ApiEndPoints.API_GET_PERSONAL_COUPONS)
|
||||
Call<ResponseArray<PersonalCouponModel>> getPersonalCouponList(@Path("storeName") String storeName,
|
||||
@Query("token") String token);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package ch.pizzacucina.android.fragment;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -16,6 +18,8 @@ import com.onesignal.OneSignal;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -26,14 +30,17 @@ import ch.pizzacucina.android.activity.MyAddressesActivity;
|
||||
import ch.pizzacucina.android.activity.SplashActivity;
|
||||
import ch.pizzacucina.android.activity.UpdatePasswordActivity;
|
||||
import ch.pizzacucina.android.activity.UpdateProfileActivity;
|
||||
import ch.pizzacucina.android.adapter.recycler.PersonalCouponCodesRecyclerAdapter;
|
||||
import ch.pizzacucina.android.api.ApiConstants;
|
||||
import ch.pizzacucina.android.api.ApiErrorUtils;
|
||||
import ch.pizzacucina.android.api.ApiService;
|
||||
import ch.pizzacucina.android.api.ResponseArray;
|
||||
import ch.pizzacucina.android.api.ResponseObject;
|
||||
import ch.pizzacucina.android.helper.DialogHelper;
|
||||
import ch.pizzacucina.android.helper.NetworkHelper;
|
||||
import ch.pizzacucina.android.helper.SessionHelper;
|
||||
import ch.pizzacucina.android.helper.SharedPrefsHelper;
|
||||
import ch.pizzacucina.android.model.PersonalCouponModel;
|
||||
import ch.pizzacucina.android.model.UserModel;
|
||||
import ch.pizzacucina.android.view.AppInfoView;
|
||||
import retrofit2.Call;
|
||||
@@ -55,6 +62,7 @@ public class ProfileFragment extends BaseFragment {
|
||||
@BindView(R.id.emailPizzalinkInfoLayout) AppInfoView emailPizzalinkInfoLayout;
|
||||
@BindView(R.id.phonePizzalinkInfoLayout) AppInfoView phonePizzalinkInfoLayout;
|
||||
@BindView(R.id.enableNotificationsSwitch) SwitchCompat enableNotificationsSwitch;
|
||||
@BindView(R.id.personalCouponCodesRecyclerView) RecyclerView personalCouponCodesRecyclerView;
|
||||
|
||||
@BindString(R.string.bottom_nav_menu_item_profile) String fragmentTitle;
|
||||
@BindString(R.string.alert_logout) String logoutAlertText;
|
||||
@@ -64,6 +72,7 @@ public class ProfileFragment extends BaseFragment {
|
||||
private int REQUEST_CODE_UPDATE_PROFILE = 2563;
|
||||
|
||||
private UserModel userModel;
|
||||
private PersonalCouponCodesRecyclerAdapter personalCouponCodesRecyclerAdapter;
|
||||
|
||||
public ProfileFragment() {}
|
||||
|
||||
@@ -228,11 +237,11 @@ public class ProfileFragment extends BaseFragment {
|
||||
call.enqueue(new Callback<ResponseObject<UserModel>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseObject<UserModel>> call, Response<ResponseObject<UserModel>> response) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
if(response.isSuccessful() &&
|
||||
response.body().getData() != null &&
|
||||
response.body().isSuccess()){
|
||||
setFields(response.body().getData());
|
||||
getPersonalCouponCodeList();
|
||||
}
|
||||
else {
|
||||
ApiErrorUtils.parseError(response);
|
||||
@@ -247,6 +256,32 @@ public class ProfileFragment extends BaseFragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void getPersonalCouponCodeList(){
|
||||
Call<ResponseArray<PersonalCouponModel>> call = ApiService.apiInterface.getPersonalCouponList(
|
||||
SessionHelper.getSelectedStore().getStoreName(),
|
||||
SessionHelper.getCustomerToken().getToken());
|
||||
call.enqueue(new Callback<ResponseArray<PersonalCouponModel>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseArray<PersonalCouponModel>> call, Response<ResponseArray<PersonalCouponModel>> response) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
if(response.isSuccessful() &&
|
||||
response.body().getData() != null &&
|
||||
response.body().isSuccess()){
|
||||
initPersonalCouponCodesRecyclerView(response.body().getData());
|
||||
}
|
||||
else {
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ResponseArray<PersonalCouponModel>> call, Throwable t) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setFields(UserModel user){
|
||||
|
||||
user.checkNull();
|
||||
@@ -261,6 +296,13 @@ public class ProfileFragment extends BaseFragment {
|
||||
phonePizzalinkInfoLayout.setText(userModel.getTelephone());
|
||||
}
|
||||
|
||||
private void initPersonalCouponCodesRecyclerView(ArrayList<PersonalCouponModel> personalCouponList){
|
||||
personalCouponCodesRecyclerAdapter = new PersonalCouponCodesRecyclerAdapter(BaseActivity.currentActivity, personalCouponList);
|
||||
personalCouponCodesRecyclerView.setLayoutManager(new LinearLayoutManager(BaseActivity.currentActivity));
|
||||
personalCouponCodesRecyclerView.setNestedScrollingEnabled(false);
|
||||
personalCouponCodesRecyclerView.setAdapter(personalCouponCodesRecyclerAdapter);
|
||||
}
|
||||
|
||||
private void logOutOnWeb(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<ResponseObject> call = ApiService.apiInterface.logout(
|
||||
|
||||
@@ -29,10 +29,15 @@ public class PersonalCouponModel extends CouponModel {
|
||||
@SerializedName("voucher_theme_id")
|
||||
private String voucherThemeId;
|
||||
|
||||
@Expose
|
||||
@SerializedName("is_active")
|
||||
private Boolean isActive;
|
||||
|
||||
private String theme;
|
||||
private String message;
|
||||
private String image;
|
||||
private String amount;
|
||||
private String total;
|
||||
|
||||
@Override
|
||||
public CouponType getCouponType() {
|
||||
@@ -41,8 +46,13 @@ public class PersonalCouponModel extends CouponModel {
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
if(isActive != null){
|
||||
return isActive;
|
||||
}
|
||||
else {
|
||||
return getStatus().equals("1");
|
||||
}
|
||||
}
|
||||
|
||||
public String getVoucherId() {
|
||||
if(voucherId == null){
|
||||
@@ -113,4 +123,11 @@ public class PersonalCouponModel extends CouponModel {
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
public String getTotal() {
|
||||
if(total == null){
|
||||
total = "";
|
||||
}
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,27 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:description="@string/kebap_pass" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:text="@string/vouchers_title"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textSize="12sp"
|
||||
fontPath="fonts/Quicksand-Bold.ttf" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/personalCouponCodesRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
tools:listitem="@layout/row_personal_coupon_code"/>
|
||||
|
||||
<ch.pizzacucina.android.view.AppInfoView
|
||||
android:id="@+id/firstnamePizzalinkInfoLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
118
app/src/main/res/layout/row_personal_coupon_code.xml
Normal file
118
app/src/main/res/layout/row_personal_coupon_code.xml
Normal file
@@ -0,0 +1,118 @@
|
||||
<?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:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Regular.ttf"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/voucher_code"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/personalCouponCodeTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/red"
|
||||
tools:text="TEST"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Regular.ttf"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/voucher_total_amount"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/personalCouponTotalAmountTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:textColor="@color/red"
|
||||
android:textSize="12sp"
|
||||
tools:text="CHF 25.00"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Regular.ttf"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/voucher_remaining_amount"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/personalCouponRemainingAmountTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:textColor="@color/red"
|
||||
android:textSize="12sp"
|
||||
tools:text="CHF 10.00"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Regular.ttf"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/voucher_remaining_status"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/personalCouponStatusTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:textColor="@color/red"
|
||||
android:textSize="12sp"
|
||||
tools:text="YES"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -28,6 +28,8 @@
|
||||
<string name="need_to_login_for_shopping">Bitte einloggen um zu bestellen.</string>
|
||||
<string name="need_to_login_for_that_part">Sie müssen sich registrieren um diese Seite zu besuchen.</string>
|
||||
<string name="cancel_all_caps">BEENDEN</string>
|
||||
<string name="yes">JA</string>
|
||||
<string name="no">NEIN</string>
|
||||
<!-- General-->
|
||||
|
||||
<!-- SplashActivity -->
|
||||
@@ -221,6 +223,11 @@
|
||||
<string name="change_post_code">Postleitzahl Ändern</string>
|
||||
<string name="alert_logout">Möchten Sie sich abmelden?</string>
|
||||
<string name="button_logout">Abmelden</string>
|
||||
<string name="vouchers_title">VOUCHERS</string>
|
||||
<string name="voucher_code">Code:</string>
|
||||
<string name="voucher_total_amount">Total:</string>
|
||||
<string name="voucher_remaining_amount">Remaining:</string>
|
||||
<string name="voucher_remaining_status">Active:</string>
|
||||
<!-- ProfileFragment-->
|
||||
|
||||
<!-- UpdateProfilectivity-->
|
||||
|
||||
Reference in New Issue
Block a user