Showing
4 changed files
with
119 additions
and
38 deletions
... | @@ -17,8 +17,12 @@ import android.widget.LinearLayout; | ... | @@ -17,8 +17,12 @@ import android.widget.LinearLayout; |
17 | import android.widget.RelativeLayout; | 17 | import android.widget.RelativeLayout; |
18 | import android.widget.TextView; | 18 | import android.widget.TextView; |
19 | 19 | ||
20 | +import androidx.appcompat.app.AlertDialog; | ||
21 | +import androidx.cardview.widget.CardView; | ||
20 | import androidx.core.content.res.ResourcesCompat; | 22 | import androidx.core.content.res.ResourcesCompat; |
21 | 23 | ||
24 | +import com.bumptech.glide.Glide; | ||
25 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
22 | import com.google.zxing.BarcodeFormat; | 26 | import com.google.zxing.BarcodeFormat; |
23 | import com.google.zxing.common.BitMatrix; | 27 | import com.google.zxing.common.BitMatrix; |
24 | import com.google.zxing.oned.EAN13Writer; | 28 | import com.google.zxing.oned.EAN13Writer; |
... | @@ -28,12 +32,15 @@ import org.greenrobot.eventbus.EventBus; | ... | @@ -28,12 +32,15 @@ import org.greenrobot.eventbus.EventBus; |
28 | import java.util.Locale; | 32 | import java.util.Locale; |
29 | 33 | ||
30 | import ly.warp.sdk.R; | 34 | import ly.warp.sdk.R; |
35 | +import ly.warp.sdk.io.callbacks.CallbackReceiver; | ||
31 | import ly.warp.sdk.io.models.CustomTypefaceSpan; | 36 | import ly.warp.sdk.io.models.CustomTypefaceSpan; |
32 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; | 37 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; |
38 | +import ly.warp.sdk.io.models.MarketPassDetailsModel; | ||
33 | import ly.warp.sdk.utils.WarpUtils; | 39 | import ly.warp.sdk.utils.WarpUtils; |
34 | import ly.warp.sdk.utils.WarplyManagerHelper; | 40 | import ly.warp.sdk.utils.WarplyManagerHelper; |
35 | import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; | 41 | import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; |
36 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; | 42 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; |
43 | +import ly.warp.sdk.utils.managers.WarplyManager; | ||
37 | 44 | ||
38 | 45 | ||
39 | public class MarketPassActivity extends Activity implements View.OnClickListener { | 46 | public class MarketPassActivity extends Activity implements View.OnClickListener { |
... | @@ -50,6 +57,10 @@ public class MarketPassActivity extends Activity implements View.OnClickListener | ... | @@ -50,6 +57,10 @@ public class MarketPassActivity extends Activity implements View.OnClickListener |
50 | private TextView mFontHeader, mPassHeader, mPassSubtitle, mTvBarcode, mTvPassCount, mTvButtonMap; | 57 | private TextView mFontHeader, mPassHeader, mPassSubtitle, mTvBarcode, mTvPassCount, mTvButtonMap; |
51 | private LinearLayout mLlMap, mLlParentLogosView; | 58 | private LinearLayout mLlMap, mLlParentLogosView; |
52 | private boolean mMapPressed = false, mPassInfoPressed = false; | 59 | private boolean mMapPressed = false, mPassInfoPressed = false; |
60 | + private MarketPassDetailsModel mMarketPassDetails = new MarketPassDetailsModel(); | ||
61 | + private RelativeLayout mPbLoading; | ||
62 | + private AlertDialog mAlertDialog; | ||
63 | + private CardView mCvMarketDetails; | ||
53 | 64 | ||
54 | // =========================================================== | 65 | // =========================================================== |
55 | // Methods for/from SuperClass/Interfaces | 66 | // Methods for/from SuperClass/Interfaces |
... | @@ -71,12 +82,16 @@ public class MarketPassActivity extends Activity implements View.OnClickListener | ... | @@ -71,12 +82,16 @@ public class MarketPassActivity extends Activity implements View.OnClickListener |
71 | mTvButtonMap = findViewById(R.id.tv_button_map); | 82 | mTvButtonMap = findViewById(R.id.tv_button_map); |
72 | mLlMap = findViewById(R.id.ll_map); | 83 | mLlMap = findViewById(R.id.ll_map); |
73 | mLlParentLogosView = findViewById(R.id.ll_sm_logos); | 84 | mLlParentLogosView = findViewById(R.id.ll_sm_logos); |
85 | + mPbLoading = findViewById(R.id.pb_loading); | ||
86 | + mPbLoading.setOnTouchListener((v, event) -> true); | ||
87 | + mCvMarketDetails = findViewById(R.id.cv_market_details); | ||
74 | 88 | ||
75 | WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mPassHeader); | 89 | WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mPassHeader); |
76 | WarpUtils.renderCustomFont(this, R.font.peridot_regular, mPassSubtitle, mTvBarcode, mTvPassCount); | 90 | WarpUtils.renderCustomFont(this, R.font.peridot_regular, mPassSubtitle, mTvBarcode, mTvPassCount); |
77 | WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mTvButtonMap); | 91 | WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mTvButtonMap); |
78 | 92 | ||
79 | - initViews(); | 93 | + mPbLoading.setVisibility(View.VISIBLE); |
94 | + WarplyManager.getMarketPassDetails(mMarketPassDetailsCallback); | ||
80 | } | 95 | } |
81 | 96 | ||
82 | @Override | 97 | @Override |
... | @@ -132,31 +147,42 @@ public class MarketPassActivity extends Activity implements View.OnClickListener | ... | @@ -132,31 +147,42 @@ public class MarketPassActivity extends Activity implements View.OnClickListener |
132 | mIvInfo.setOnClickListener(this); | 147 | mIvInfo.setOnClickListener(this); |
133 | mLlMap.setOnClickListener(this); | 148 | mLlMap.setOnClickListener(this); |
134 | 149 | ||
135 | - //TODO: replace with dynmamic barcode | 150 | + if (mMarketPassDetails != null) |
136 | - createBarcodeBitmap("4006381333931"); | 151 | + createBarcodeBitmap(mMarketPassDetails.getBarcode()); |
137 | - | 152 | + |
138 | - //TODO: replace with actual value | 153 | + if (mMarketPassDetails != null) { |
139 | - String passValue = String.format(Locale.GERMAN, "%.00f", 30f); | 154 | + String passValue = String.format(Locale.GERMAN, "%.02f", mMarketPassDetails.getTotalDiscount()); |
140 | - SpannableStringBuilder sBuilder = new SpannableStringBuilder(); | 155 | + SpannableStringBuilder sBuilder = new SpannableStringBuilder(); |
141 | - sBuilder.append(String.format(getString(R.string.cos_market_pass_coupons_title), "30")); | 156 | + sBuilder.append(String.format(getString(R.string.cos_market_pass_coupons_title), String.valueOf(mMarketPassDetails.getTotalDiscount()))); |
142 | - Typeface typefaceBold = ResourcesCompat.getFont(this, R.font.peridot_bold); | 157 | + Typeface typefaceBold = ResourcesCompat.getFont(this, R.font.peridot_bold); |
143 | - CustomTypefaceSpan typefaceBoldSpan = new CustomTypefaceSpan(typefaceBold); | 158 | + CustomTypefaceSpan typefaceBoldSpan = new CustomTypefaceSpan(typefaceBold); |
144 | - sBuilder.setSpan(typefaceBoldSpan, 31, 31 + passValue.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | 159 | + sBuilder.setSpan(typefaceBoldSpan, 31, 31 + passValue.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
145 | - mTvPassCount.setText(sBuilder, TextView.BufferType.SPANNABLE); | 160 | + mTvPassCount.setText(sBuilder, TextView.BufferType.SPANNABLE); |
146 | - | 161 | + } |
147 | - //TODO: replace with dynamic size of logos | 162 | + |
148 | - for (int i = 0; i < 3; i++) { | 163 | + if (mMarketPassDetails != null) { |
149 | - int tempIndex = i; | 164 | + for (int i = 0; i < mMarketPassDetails.getSupermarkets().size(); i++) { |
150 | - LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); | 165 | + int tempIndex = i; |
151 | - RelativeLayout v = (RelativeLayout) vi.inflate(R.layout.item_sheet_image, null); | 166 | + LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
152 | - | 167 | + RelativeLayout v = (RelativeLayout) vi.inflate(R.layout.item_sheet_image, null); |
153 | - ImageView merchantLogo = (ImageView) v.findViewById(R.id.iv_market_logo); | 168 | + |
154 | - merchantLogo.setImageResource(R.drawable.ic_ab_logo); | 169 | + ImageView merchantLogo = (ImageView) v.findViewById(R.id.iv_market_logo); |
155 | - mLlParentLogosView.addView(v, tempIndex, new ViewGroup.LayoutParams( | 170 | + Glide.with(this) |
156 | - ViewGroup.LayoutParams.WRAP_CONTENT, | 171 | +// .setDefaultRequestOptions( |
157 | - ViewGroup.LayoutParams.WRAP_CONTENT)); | 172 | +// RequestOptions |
173 | +// .placeholderOf(R.drawable.ic_default_contact_photo) | ||
174 | +// .error(R.drawable.ic_default_contact_photo)) | ||
175 | + .load(mMarketPassDetails.getSupermarkets().get(i).getLogo()) | ||
176 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
177 | + .into(merchantLogo); | ||
178 | + mLlParentLogosView.addView(v, tempIndex, new ViewGroup.LayoutParams( | ||
179 | + ViewGroup.LayoutParams.WRAP_CONTENT, | ||
180 | + ViewGroup.LayoutParams.WRAP_CONTENT)); | ||
158 | 181 | ||
182 | + } | ||
159 | } | 183 | } |
184 | + | ||
185 | + mCvMarketDetails.setVisibility(View.VISIBLE); | ||
160 | } | 186 | } |
161 | 187 | ||
162 | private void createBarcodeBitmap(String barcodeString) { | 188 | private void createBarcodeBitmap(String barcodeString) { |
... | @@ -182,4 +208,27 @@ public class MarketPassActivity extends Activity implements View.OnClickListener | ... | @@ -182,4 +208,27 @@ public class MarketPassActivity extends Activity implements View.OnClickListener |
182 | // =========================================================== | 208 | // =========================================================== |
183 | // Inner and Anonymous Classes | 209 | // Inner and Anonymous Classes |
184 | // =========================================================== | 210 | // =========================================================== |
211 | + | ||
212 | + private final CallbackReceiver<MarketPassDetailsModel> mMarketPassDetailsCallback = new CallbackReceiver<MarketPassDetailsModel>() { | ||
213 | + @Override | ||
214 | + public void onSuccess(MarketPassDetailsModel result) { | ||
215 | + mPbLoading.setVisibility(View.GONE); | ||
216 | + mMarketPassDetails = result; | ||
217 | + initViews(); | ||
218 | + } | ||
219 | + | ||
220 | + @Override | ||
221 | + public void onFailure(int errorCode) { | ||
222 | + mPbLoading.setVisibility(View.GONE); | ||
223 | + | ||
224 | + if (!isFinishing()) { | ||
225 | + mAlertDialog = new AlertDialog.Builder(MarketPassActivity.this) | ||
226 | + .setTitle(R.string.cos_dlg_error_subtitle) | ||
227 | + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { | ||
228 | + dialogPositive.dismiss(); | ||
229 | + }) | ||
230 | + .show(); | ||
231 | + } | ||
232 | + } | ||
233 | + }; | ||
185 | } | 234 | } | ... | ... |
... | @@ -42,15 +42,18 @@ public class MarketPassDetailsModel { | ... | @@ -42,15 +42,18 @@ public class MarketPassDetailsModel { |
42 | private static final String BARCODE = "barcode"; | 42 | private static final String BARCODE = "barcode"; |
43 | private static final String SUPERMARKETS = "supermarkets"; | 43 | private static final String SUPERMARKETS = "supermarkets"; |
44 | private static final String TOTAL_DISCOUNT = "total_available_discount"; | 44 | private static final String TOTAL_DISCOUNT = "total_available_discount"; |
45 | + private static final String NEW_OFFERS = "new_offers"; | ||
45 | 46 | ||
46 | private ArrayList<Supermarkets> supermarkets = new ArrayList<Supermarkets>(); | 47 | private ArrayList<Supermarkets> supermarkets = new ArrayList<Supermarkets>(); |
47 | private String barcode = ""; | 48 | private String barcode = ""; |
48 | private double totalDiscount = 0.0d; | 49 | private double totalDiscount = 0.0d; |
50 | + private int newOffers = 0; | ||
49 | 51 | ||
50 | public MarketPassDetailsModel() { | 52 | public MarketPassDetailsModel() { |
51 | this.supermarkets = new ArrayList<Supermarkets>(); | 53 | this.supermarkets = new ArrayList<Supermarkets>(); |
52 | this.barcode = ""; | 54 | this.barcode = ""; |
53 | this.totalDiscount = 0.0d; | 55 | this.totalDiscount = 0.0d; |
56 | + this.newOffers = 0; | ||
54 | } | 57 | } |
55 | 58 | ||
56 | /** | 59 | /** |
... | @@ -81,6 +84,7 @@ public class MarketPassDetailsModel { | ... | @@ -81,6 +84,7 @@ public class MarketPassDetailsModel { |
81 | } | 84 | } |
82 | this.barcode = json.optString(BARCODE); | 85 | this.barcode = json.optString(BARCODE); |
83 | this.totalDiscount = json.optDouble(TOTAL_DISCOUNT); | 86 | this.totalDiscount = json.optDouble(TOTAL_DISCOUNT); |
87 | + this.newOffers = json.optInt(NEW_OFFERS); | ||
84 | } | 88 | } |
85 | } | 89 | } |
86 | 90 | ||
... | @@ -95,6 +99,7 @@ public class MarketPassDetailsModel { | ... | @@ -95,6 +99,7 @@ public class MarketPassDetailsModel { |
95 | jObj.putOpt(BARCODE, this.barcode); | 99 | jObj.putOpt(BARCODE, this.barcode); |
96 | jObj.putOpt(TOTAL_DISCOUNT, this.totalDiscount); | 100 | jObj.putOpt(TOTAL_DISCOUNT, this.totalDiscount); |
97 | jObj.putOpt(SUPERMARKETS, this.supermarkets); | 101 | jObj.putOpt(SUPERMARKETS, this.supermarkets); |
102 | + jObj.putOpt(NEW_OFFERS, this.newOffers); | ||
98 | } catch (JSONException e) { | 103 | } catch (JSONException e) { |
99 | if (WarpConstants.DEBUG) { | 104 | if (WarpConstants.DEBUG) { |
100 | e.printStackTrace(); | 105 | e.printStackTrace(); |
... | @@ -148,15 +153,9 @@ public class MarketPassDetailsModel { | ... | @@ -148,15 +153,9 @@ public class MarketPassDetailsModel { |
148 | 153 | ||
149 | public Supermarkets(JSONObject json) { | 154 | public Supermarkets(JSONObject json) { |
150 | if (json != null) { | 155 | if (json != null) { |
151 | - if (json.optJSONObject(LOGO) != null) { | 156 | + this.logo = json.optString(LOGO); |
152 | - this.logo = json.optString(LOGO); | 157 | + this.name = json.optString(NAME); |
153 | - } | 158 | + this.uuid = json.optString(UUID); |
154 | - if (json.optJSONObject(NAME) != null) { | ||
155 | - this.name = json.optString(NAME); | ||
156 | - } | ||
157 | - if (json.optJSONObject(UUID) != null) { | ||
158 | - this.uuid = json.optString(UUID); | ||
159 | - } | ||
160 | } | 159 | } |
161 | } | 160 | } |
162 | 161 | ||
... | @@ -213,4 +212,12 @@ public class MarketPassDetailsModel { | ... | @@ -213,4 +212,12 @@ public class MarketPassDetailsModel { |
213 | public void setTotalDiscount(double totalDiscount) { | 212 | public void setTotalDiscount(double totalDiscount) { |
214 | this.totalDiscount = totalDiscount; | 213 | this.totalDiscount = totalDiscount; |
215 | } | 214 | } |
215 | + | ||
216 | + public int getNewOffers() { | ||
217 | + return newOffers; | ||
218 | + } | ||
219 | + | ||
220 | + public void setNewOffers(int newOffers) { | ||
221 | + this.newOffers = newOffers; | ||
222 | + } | ||
216 | } | 223 | } | ... | ... |
... | @@ -109,6 +109,7 @@ public class ExpiredCouponAdapter extends RecyclerView.Adapter<ExpiredCouponAdap | ... | @@ -109,6 +109,7 @@ public class ExpiredCouponAdapter extends RecyclerView.Adapter<ExpiredCouponAdap |
109 | if (couponItem != null) { | 109 | if (couponItem != null) { |
110 | if (mIsCustom) { | 110 | if (mIsCustom) { |
111 | holder.tvCouponTitle.setText(couponItem.getMerchantDetails().getAdminName()); | 111 | holder.tvCouponTitle.setText(couponItem.getMerchantDetails().getAdminName()); |
112 | + holder.tvCouponsShop.setText(couponItem.getRedeemDetails().getName()); | ||
112 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 113 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
113 | holder.tvCouponSubtitle.setText(Html.fromHtml(couponItem.getCouponsetDetails().getInnerText(), Html.FROM_HTML_MODE_COMPACT)); | 114 | holder.tvCouponSubtitle.setText(Html.fromHtml(couponItem.getCouponsetDetails().getInnerText(), Html.FROM_HTML_MODE_COMPACT)); |
114 | } else { | 115 | } else { | ... | ... |
... | @@ -66,13 +66,16 @@ | ... | @@ -66,13 +66,16 @@ |
66 | android:layout_height="wrap_content"> | 66 | android:layout_height="wrap_content"> |
67 | 67 | ||
68 | <androidx.cardview.widget.CardView | 68 | <androidx.cardview.widget.CardView |
69 | + android:id="@+id/cv_market_details" | ||
69 | android:layout_width="match_parent" | 70 | android:layout_width="match_parent" |
70 | android:layout_height="wrap_content" | 71 | android:layout_height="wrap_content" |
71 | android:layout_marginHorizontal="16dp" | 72 | android:layout_marginHorizontal="16dp" |
72 | android:layout_marginVertical="24dp" | 73 | android:layout_marginVertical="24dp" |
74 | + android:visibility="gone" | ||
73 | app:cardBackgroundColor="@android:color/white" | 75 | app:cardBackgroundColor="@android:color/white" |
74 | app:cardCornerRadius="16dp" | 76 | app:cardCornerRadius="16dp" |
75 | - app:cardElevation="2dp"> | 77 | + app:cardElevation="2dp" |
78 | + tools:visibility="visible"> | ||
76 | 79 | ||
77 | <RelativeLayout | 80 | <RelativeLayout |
78 | android:layout_width="match_parent" | 81 | android:layout_width="match_parent" |
... | @@ -172,12 +175,12 @@ | ... | @@ -172,12 +175,12 @@ |
172 | android:id="@+id/ll_sm_logos" | 175 | android:id="@+id/ll_sm_logos" |
173 | android:layout_width="0dp" | 176 | android:layout_width="0dp" |
174 | android:layout_height="0dp" | 177 | android:layout_height="0dp" |
175 | - android:orientation="horizontal" | ||
176 | android:gravity="center" | 178 | android:gravity="center" |
179 | + android:orientation="horizontal" | ||
177 | app:layout_constraintBottom_toBottomOf="parent" | 180 | app:layout_constraintBottom_toBottomOf="parent" |
181 | + app:layout_constraintEnd_toStartOf="@+id/ll_map" | ||
178 | app:layout_constraintStart_toStartOf="parent" | 182 | app:layout_constraintStart_toStartOf="parent" |
179 | - app:layout_constraintTop_toTopOf="parent" | 183 | + app:layout_constraintTop_toTopOf="parent"> |
180 | - app:layout_constraintEnd_toStartOf="@+id/ll_map"> | ||
181 | 184 | ||
182 | </LinearLayout> | 185 | </LinearLayout> |
183 | 186 | ||
... | @@ -186,10 +189,10 @@ | ... | @@ -186,10 +189,10 @@ |
186 | android:layout_width="148dp" | 189 | android:layout_width="148dp" |
187 | android:layout_height="48dp" | 190 | android:layout_height="48dp" |
188 | android:layout_gravity="center" | 191 | android:layout_gravity="center" |
192 | + android:layout_marginEnd="12dp" | ||
189 | android:background="@drawable/selector_button_green_border3" | 193 | android:background="@drawable/selector_button_green_border3" |
190 | android:gravity="center" | 194 | android:gravity="center" |
191 | android:orientation="horizontal" | 195 | android:orientation="horizontal" |
192 | - android:layout_marginEnd="12dp" | ||
193 | app:layout_constraintBottom_toBottomOf="parent" | 196 | app:layout_constraintBottom_toBottomOf="parent" |
194 | app:layout_constraintEnd_toEndOf="parent" | 197 | app:layout_constraintEnd_toEndOf="parent" |
195 | app:layout_constraintTop_toTopOf="parent"> | 198 | app:layout_constraintTop_toTopOf="parent"> |
... | @@ -209,4 +212,25 @@ | ... | @@ -209,4 +212,25 @@ |
209 | </androidx.cardview.widget.CardView> | 212 | </androidx.cardview.widget.CardView> |
210 | </RelativeLayout> | 213 | </RelativeLayout> |
211 | </ScrollView> | 214 | </ScrollView> |
215 | + | ||
216 | + <RelativeLayout | ||
217 | + android:id="@+id/pb_loading" | ||
218 | + android:layout_width="match_parent" | ||
219 | + android:layout_height="match_parent" | ||
220 | + android:background="@android:color/transparent" | ||
221 | + android:visibility="gone" | ||
222 | + app:layout_constraintBottom_toBottomOf="parent" | ||
223 | + app:layout_constraintEnd_toEndOf="parent" | ||
224 | + app:layout_constraintStart_toStartOf="parent" | ||
225 | + app:layout_constraintTop_toTopOf="parent" | ||
226 | + tools:visibility="visible"> | ||
227 | + | ||
228 | + <ProgressBar | ||
229 | + android:layout_width="48dp" | ||
230 | + android:layout_height="48dp" | ||
231 | + android:layout_centerInParent="true" | ||
232 | + android:indeterminate="true" | ||
233 | + android:indeterminateTint="@color/cos_green5" | ||
234 | + android:indeterminateTintMode="src_atop" /> | ||
235 | + </RelativeLayout> | ||
212 | </androidx.constraintlayout.widget.ConstraintLayout> | 236 | </androidx.constraintlayout.widget.ConstraintLayout> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment