Showing
5 changed files
with
108 additions
and
52 deletions
| ... | @@ -26,6 +26,7 @@ import ly.warp.sdk.fragments.MyRewardsFragment; | ... | @@ -26,6 +26,7 @@ import ly.warp.sdk.fragments.MyRewardsFragment; |
| 26 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 26 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 27 | import ly.warp.sdk.io.models.Campaign; | 27 | import ly.warp.sdk.io.models.Campaign; |
| 28 | import ly.warp.sdk.io.models.CouponList; | 28 | import ly.warp.sdk.io.models.CouponList; |
| 29 | +import ly.warp.sdk.io.models.MarketPassDetailsModel; | ||
| 29 | import ly.warp.sdk.io.models.UnifiedCoupon; | 30 | import ly.warp.sdk.io.models.UnifiedCoupon; |
| 30 | import ly.warp.sdk.utils.managers.WarplyManager; | 31 | import ly.warp.sdk.utils.managers.WarplyManager; |
| 31 | 32 | ||
| ... | @@ -58,6 +59,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -58,6 +59,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
| 58 | WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); | 59 | WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); |
| 59 | WarplyManager.getCampaigns(mCampaignsCallback); | 60 | WarplyManager.getCampaigns(mCampaignsCallback); |
| 60 | WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); | 61 | WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); |
| 62 | + WarplyManager.getMarketPassDetails(mMarketPassDetailsCallback); | ||
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | 65 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { |
| ... | @@ -191,4 +193,16 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -191,4 +193,16 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
| 191 | Toast.makeText(BaseFragmentActivity.this, "Unified Coupons Error", Toast.LENGTH_SHORT).show(); | 193 | Toast.makeText(BaseFragmentActivity.this, "Unified Coupons Error", Toast.LENGTH_SHORT).show(); |
| 192 | } | 194 | } |
| 193 | }; | 195 | }; |
| 196 | + | ||
| 197 | + private final CallbackReceiver<MarketPassDetailsModel> mMarketPassDetailsCallback = new CallbackReceiver<MarketPassDetailsModel>() { | ||
| 198 | + @Override | ||
| 199 | + public void onSuccess(MarketPassDetailsModel result) { | ||
| 200 | + Toast.makeText(BaseFragmentActivity.this, "Market Pass Success", Toast.LENGTH_SHORT).show(); | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + @Override | ||
| 204 | + public void onFailure(int errorCode) { | ||
| 205 | + Toast.makeText(BaseFragmentActivity.this, "Market Pass Error", Toast.LENGTH_SHORT).show(); | ||
| 206 | + } | ||
| 207 | + }; | ||
| 194 | } | 208 | } | ... | ... |
| ... | @@ -91,7 +91,8 @@ public class MarketPassActivity extends Activity implements View.OnClickListener | ... | @@ -91,7 +91,8 @@ public class MarketPassActivity extends Activity implements View.OnClickListener |
| 91 | WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mTvButtonMap); | 91 | WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mTvButtonMap); |
| 92 | 92 | ||
| 93 | mPbLoading.setVisibility(View.VISIBLE); | 93 | mPbLoading.setVisibility(View.VISIBLE); |
| 94 | - WarplyManager.getMarketPassDetails(mMarketPassDetailsCallback); | 94 | +// WarplyManager.getMarketPassDetails(mMarketPassDetailsCallback); |
| 95 | + initViews(); | ||
| 95 | } | 96 | } |
| 96 | 97 | ||
| 97 | @Override | 98 | @Override |
| ... | @@ -147,42 +148,57 @@ public class MarketPassActivity extends Activity implements View.OnClickListener | ... | @@ -147,42 +148,57 @@ public class MarketPassActivity extends Activity implements View.OnClickListener |
| 147 | mIvInfo.setOnClickListener(this); | 148 | mIvInfo.setOnClickListener(this); |
| 148 | mLlMap.setOnClickListener(this); | 149 | mLlMap.setOnClickListener(this); |
| 149 | 150 | ||
| 150 | - if (mMarketPassDetails != null) | 151 | + if(WarplyManagerHelper.getMarketPassDetails() != null) { |
| 151 | - createBarcodeBitmap(mMarketPassDetails.getBarcode()); | 152 | +// if (mMarketPassDetails != null) |
| 152 | - | 153 | + createBarcodeBitmap(WarplyManagerHelper.getMarketPassDetails().getBarcode()); |
| 153 | - if (mMarketPassDetails != null) { | 154 | + |
| 154 | - String passValue = String.format(Locale.GERMAN, "%.02f", mMarketPassDetails.getTotalDiscount()); | 155 | +// if (mMarketPassDetails != null) { |
| 155 | - SpannableStringBuilder sBuilder = new SpannableStringBuilder(); | 156 | + String passValue = String.format(Locale.GERMAN, "%.2f", WarplyManagerHelper.getMarketPassDetails().getTotalDiscount()); |
| 156 | - sBuilder.append(String.format(getString(R.string.cos_market_pass_coupons_title), String.valueOf(mMarketPassDetails.getTotalDiscount()))); | 157 | + String fullText = String.format(getString(R.string.cos_market_pass_coupons_title), passValue); |
| 157 | - Typeface typefaceBold = ResourcesCompat.getFont(this, R.font.peridot_bold); | 158 | + int startIndex = fullText.indexOf(passValue); |
| 158 | - CustomTypefaceSpan typefaceBoldSpan = new CustomTypefaceSpan(typefaceBold); | 159 | + int endIndex = startIndex + passValue.length(); |
| 159 | - sBuilder.setSpan(typefaceBoldSpan, 29, 30 + passValue.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | 160 | + SpannableStringBuilder sBuilder = new SpannableStringBuilder(fullText); |
| 160 | - mTvPassCount.setText(sBuilder, TextView.BufferType.SPANNABLE); | 161 | + Typeface typefaceBold = ResourcesCompat.getFont(this, R.font.peridot_bold); |
| 161 | - } | 162 | + CustomTypefaceSpan typefaceBoldSpan = new CustomTypefaceSpan(typefaceBold); |
| 162 | - | 163 | + sBuilder.setSpan(typefaceBoldSpan, startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| 163 | - if (mMarketPassDetails != null) { | 164 | + mTvPassCount.setText(sBuilder, TextView.BufferType.SPANNABLE); |
| 164 | - for (int i = 0; i < mMarketPassDetails.getSupermarkets().size(); i++) { | 165 | +// } |
| 165 | - int tempIndex = i; | 166 | + |
| 166 | - LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); | 167 | +// if (mMarketPassDetails != null) { |
| 167 | - RelativeLayout v = (RelativeLayout) vi.inflate(R.layout.item_sheet_image, null); | 168 | + for (int i = 0; i < WarplyManagerHelper.getMarketPassDetails().getSupermarkets().size(); i++) { |
| 168 | - | 169 | + int tempIndex = i; |
| 169 | - ImageView merchantLogo = (ImageView) v.findViewById(R.id.iv_market_logo); | 170 | + LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 170 | - Glide.with(this) | 171 | + RelativeLayout v = (RelativeLayout) vi.inflate(R.layout.item_sheet_image, null); |
| 172 | + | ||
| 173 | + ImageView merchantLogo = (ImageView) v.findViewById(R.id.iv_market_logo); | ||
| 174 | + Glide.with(this) | ||
| 171 | // .setDefaultRequestOptions( | 175 | // .setDefaultRequestOptions( |
| 172 | // RequestOptions | 176 | // RequestOptions |
| 173 | // .placeholderOf(R.drawable.ic_default_contact_photo) | 177 | // .placeholderOf(R.drawable.ic_default_contact_photo) |
| 174 | // .error(R.drawable.ic_default_contact_photo)) | 178 | // .error(R.drawable.ic_default_contact_photo)) |
| 175 | - .load(mMarketPassDetails.getSupermarkets().get(i).getLogo()) | 179 | + .load(WarplyManagerHelper.getMarketPassDetails().getSupermarkets().get(i).getLogo()) |
| 176 | - .diskCacheStrategy(DiskCacheStrategy.DATA) | 180 | + .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 177 | - .into(merchantLogo); | 181 | + .into(merchantLogo); |
| 178 | - mLlParentLogosView.addView(v, tempIndex, new ViewGroup.LayoutParams( | 182 | + mLlParentLogosView.addView(v, tempIndex, new ViewGroup.LayoutParams( |
| 179 | - ViewGroup.LayoutParams.WRAP_CONTENT, | 183 | + ViewGroup.LayoutParams.WRAP_CONTENT, |
| 180 | - ViewGroup.LayoutParams.WRAP_CONTENT)); | 184 | + ViewGroup.LayoutParams.WRAP_CONTENT)); |
| 185 | + | ||
| 186 | + } | ||
| 187 | +// } | ||
| 181 | 188 | ||
| 189 | + mCvMarketDetails.setVisibility(View.VISIBLE); | ||
| 190 | + mPbLoading.setVisibility(View.GONE); | ||
| 191 | + } else { | ||
| 192 | + mPbLoading.setVisibility(View.GONE); | ||
| 193 | + if (!isFinishing()) { | ||
| 194 | + mAlertDialog = new AlertDialog.Builder(MarketPassActivity.this) | ||
| 195 | + .setTitle(R.string.cos_dlg_error_subtitle) | ||
| 196 | + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { | ||
| 197 | + dialogPositive.dismiss(); | ||
| 198 | + }) | ||
| 199 | + .show(); | ||
| 182 | } | 200 | } |
| 183 | } | 201 | } |
| 184 | - | ||
| 185 | - mCvMarketDetails.setVisibility(View.VISIBLE); | ||
| 186 | } | 202 | } |
| 187 | 203 | ||
| 188 | private void createBarcodeBitmap(String barcodeString) { | 204 | private void createBarcodeBitmap(String barcodeString) { |
| ... | @@ -209,26 +225,26 @@ public class MarketPassActivity extends Activity implements View.OnClickListener | ... | @@ -209,26 +225,26 @@ public class MarketPassActivity extends Activity implements View.OnClickListener |
| 209 | // Inner and Anonymous Classes | 225 | // Inner and Anonymous Classes |
| 210 | // =========================================================== | 226 | // =========================================================== |
| 211 | 227 | ||
| 212 | - private final CallbackReceiver<MarketPassDetailsModel> mMarketPassDetailsCallback = new CallbackReceiver<MarketPassDetailsModel>() { | 228 | +// private final CallbackReceiver<MarketPassDetailsModel> mMarketPassDetailsCallback = new CallbackReceiver<MarketPassDetailsModel>() { |
| 213 | - @Override | 229 | +// @Override |
| 214 | - public void onSuccess(MarketPassDetailsModel result) { | 230 | +// public void onSuccess(MarketPassDetailsModel result) { |
| 215 | - mPbLoading.setVisibility(View.GONE); | 231 | +// mPbLoading.setVisibility(View.GONE); |
| 216 | - mMarketPassDetails = result; | 232 | +// mMarketPassDetails = result; |
| 217 | - initViews(); | 233 | +// initViews(); |
| 218 | - } | 234 | +// } |
| 219 | - | 235 | +// |
| 220 | - @Override | 236 | +// @Override |
| 221 | - public void onFailure(int errorCode) { | 237 | +// public void onFailure(int errorCode) { |
| 222 | - mPbLoading.setVisibility(View.GONE); | 238 | +// mPbLoading.setVisibility(View.GONE); |
| 223 | - | 239 | +// |
| 224 | - if (!isFinishing()) { | 240 | +// if (!isFinishing()) { |
| 225 | - mAlertDialog = new AlertDialog.Builder(MarketPassActivity.this) | 241 | +// mAlertDialog = new AlertDialog.Builder(MarketPassActivity.this) |
| 226 | - .setTitle(R.string.cos_dlg_error_subtitle) | 242 | +// .setTitle(R.string.cos_dlg_error_subtitle) |
| 227 | - .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { | 243 | +// .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { |
| 228 | - dialogPositive.dismiss(); | 244 | +// dialogPositive.dismiss(); |
| 229 | - }) | 245 | +// }) |
| 230 | - .show(); | 246 | +// .show(); |
| 231 | - } | 247 | +// } |
| 232 | - } | 248 | +// } |
| 233 | - }; | 249 | +// }; |
| 234 | } | 250 | } | ... | ... |
| ... | @@ -27,6 +27,7 @@ import ly.warp.sdk.db.WarplyDBHelper; | ... | @@ -27,6 +27,7 @@ import ly.warp.sdk.db.WarplyDBHelper; |
| 27 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 27 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 28 | import ly.warp.sdk.io.models.Campaign; | 28 | import ly.warp.sdk.io.models.Campaign; |
| 29 | import ly.warp.sdk.io.models.CouponList; | 29 | import ly.warp.sdk.io.models.CouponList; |
| 30 | +import ly.warp.sdk.io.models.MarketPassDetailsModel; | ||
| 30 | import ly.warp.sdk.io.models.UnifiedCoupon; | 31 | import ly.warp.sdk.io.models.UnifiedCoupon; |
| 31 | import ly.warp.sdk.utils.WarpJSONParser; | 32 | import ly.warp.sdk.utils.WarpJSONParser; |
| 32 | import ly.warp.sdk.utils.WarplyManagerHelper; | 33 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| ... | @@ -128,6 +129,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip | ... | @@ -128,6 +129,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip |
| 128 | WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); | 129 | WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); |
| 129 | WarplyManager.getCampaigns(mCampaignsCallback); | 130 | WarplyManager.getCampaigns(mCampaignsCallback); |
| 130 | WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); | 131 | WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); |
| 132 | + WarplyManager.getMarketPassDetails(mMarketPassDetailsCallback); | ||
| 131 | mSwipeRefresh.setRefreshing(false); | 133 | mSwipeRefresh.setRefreshing(false); |
| 132 | } else { | 134 | } else { |
| 133 | mSwipeRefresh.setRefreshing(false); | 135 | mSwipeRefresh.setRefreshing(false); |
| ... | @@ -239,6 +241,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip | ... | @@ -239,6 +241,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip |
| 239 | WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); | 241 | WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); |
| 240 | WarplyManager.getCampaigns(mCampaignsCallback); | 242 | WarplyManager.getCampaigns(mCampaignsCallback); |
| 241 | WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); | 243 | WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); |
| 244 | + WarplyManager.getMarketPassDetails(mMarketPassDetailsCallback); | ||
| 242 | } | 245 | } |
| 243 | 246 | ||
| 244 | @Override | 247 | @Override |
| ... | @@ -247,4 +250,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip | ... | @@ -247,4 +250,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip |
| 247 | Toast.makeText(getActivity(), "LOGIN ERROR", Toast.LENGTH_SHORT).show(); | 250 | Toast.makeText(getActivity(), "LOGIN ERROR", Toast.LENGTH_SHORT).show(); |
| 248 | } | 251 | } |
| 249 | }; | 252 | }; |
| 253 | + | ||
| 254 | + private final CallbackReceiver<MarketPassDetailsModel> mMarketPassDetailsCallback = new CallbackReceiver<MarketPassDetailsModel>() { | ||
| 255 | + @Override | ||
| 256 | + public void onSuccess(MarketPassDetailsModel result) { | ||
| 257 | + Toast.makeText(getActivity(), "Market Pass Success", Toast.LENGTH_SHORT).show(); | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + @Override | ||
| 261 | + public void onFailure(int errorCode) { | ||
| 262 | + Toast.makeText(getActivity(), "Market Pass Error", Toast.LENGTH_SHORT).show(); | ||
| 263 | + } | ||
| 264 | + }; | ||
| 250 | } | 265 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -71,6 +71,7 @@ import ly.warp.sdk.io.models.LoyaltyBadgeModel; | ... | @@ -71,6 +71,7 @@ import ly.warp.sdk.io.models.LoyaltyBadgeModel; |
| 71 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | 71 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; |
| 72 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; | 72 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; |
| 73 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; | 73 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; |
| 74 | +import ly.warp.sdk.io.models.MarketPassDetailsModel; | ||
| 74 | import ly.warp.sdk.io.models.MerchantList; | 75 | import ly.warp.sdk.io.models.MerchantList; |
| 75 | import ly.warp.sdk.io.models.PushCampaign; | 76 | import ly.warp.sdk.io.models.PushCampaign; |
| 76 | import ly.warp.sdk.io.models.UnifiedCoupon; | 77 | import ly.warp.sdk.io.models.UnifiedCoupon; |
| ... | @@ -128,6 +129,7 @@ public class WarplyManagerHelper { | ... | @@ -128,6 +129,7 @@ public class WarplyManagerHelper { |
| 128 | private static ArrayList<UnifiedCoupon> mMarketCoupons = new ArrayList<>(), | 129 | private static ArrayList<UnifiedCoupon> mMarketCoupons = new ArrayList<>(), |
| 129 | mMarketCouponsList = new ArrayList<>(); | 130 | mMarketCouponsList = new ArrayList<>(); |
| 130 | private static String showVouchersBanner = ""; | 131 | private static String showVouchersBanner = ""; |
| 132 | + private static MarketPassDetailsModel mMarketPassDetails; | ||
| 131 | 133 | ||
| 132 | // =========================================================== | 134 | // =========================================================== |
| 133 | // Methods for/from SuperClass/Interfaces | 135 | // Methods for/from SuperClass/Interfaces |
| ... | @@ -137,6 +139,14 @@ public class WarplyManagerHelper { | ... | @@ -137,6 +139,14 @@ public class WarplyManagerHelper { |
| 137 | // Methods | 139 | // Methods |
| 138 | // =========================================================== | 140 | // =========================================================== |
| 139 | 141 | ||
| 142 | + public static MarketPassDetailsModel getMarketPassDetails() { | ||
| 143 | + return mMarketPassDetails; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + public static void setMarketPassDetails(MarketPassDetailsModel marketPassDetails) { | ||
| 147 | + mMarketPassDetails = marketPassDetails; | ||
| 148 | + } | ||
| 149 | + | ||
| 140 | public static String openSupermarketCampaign(Context context) { | 150 | public static String openSupermarketCampaign(Context context) { |
| 141 | // if (WarplyProperty.getAppUuid(context).equals("f83dfde1145e4c2da69793abb2f579af")) { | 151 | // if (WarplyProperty.getAppUuid(context).equals("f83dfde1145e4c2da69793abb2f579af")) { |
| 142 | // return "https://dev.supermarketdeals.eu/map"; | 152 | // return "https://dev.supermarketdeals.eu/map"; | ... | ... |
| ... | @@ -5289,6 +5289,7 @@ public class WarplyManager { | ... | @@ -5289,6 +5289,7 @@ public class WarplyManager { |
| 5289 | Futures.addCallback(mergedResultFuture, new FutureCallback<MarketPassDetailsModel>() { | 5289 | Futures.addCallback(mergedResultFuture, new FutureCallback<MarketPassDetailsModel>() { |
| 5290 | @Override | 5290 | @Override |
| 5291 | public void onSuccess(MarketPassDetailsModel mergedResult) { | 5291 | public void onSuccess(MarketPassDetailsModel mergedResult) { |
| 5292 | + WarplyManagerHelper.setMarketPassDetails(mergedResult); | ||
| 5292 | executorService.shutdownNow(); | 5293 | executorService.shutdownNow(); |
| 5293 | new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mergedResult)); | 5294 | new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mergedResult)); |
| 5294 | } | 5295 | } | ... | ... |
-
Please register or login to post a comment