Showing
25 changed files
with
612 additions
and
376 deletions
| ... | @@ -18,11 +18,6 @@ Debug=true | ... | @@ -18,11 +18,6 @@ Debug=true |
| 18 | # DEH Development: https://engage-uat.dei.gr | 18 | # DEH Development: https://engage-uat.dei.gr |
| 19 | BaseURL=https://engage-uat.dei.gr | 19 | BaseURL=https://engage-uat.dei.gr |
| 20 | 20 | ||
| 21 | -# For Verify Ticket request | ||
| 22 | -VerifyURL=/partners/dei/verify | ||
| 23 | - | ||
| 24 | -#WebActionHandler=app_package_name.WarplyWebActionHandler | ||
| 25 | - | ||
| 26 | # Replace the color with one you want the progress bar to have depending on you app theme-coloring | 21 | # Replace the color with one you want the progress bar to have depending on you app theme-coloring |
| 27 | # If not defined the colorPrimary will used | 22 | # If not defined the colorPrimary will used |
| 28 | #ProgressColor=red | 23 | #ProgressColor=red |
| ... | @@ -46,13 +41,10 @@ SendPackages=false | ... | @@ -46,13 +41,10 @@ SendPackages=false |
| 46 | # The app language | 41 | # The app language |
| 47 | Language=el | 42 | Language=el |
| 48 | 43 | ||
| 49 | -# The merchant id for some requests | ||
| 50 | -MerchantId=20113 | ||
| 51 | - | ||
| 52 | # The login type must be one of the below: | 44 | # The login type must be one of the below: |
| 53 | # email, msisdn, username | 45 | # email, msisdn, username |
| 54 | -LoginType=username | 46 | +LoginType=email |
| 55 | 47 | ||
| 56 | # The deeplink url scheme for react native campaigns: | 48 | # The deeplink url scheme for react native campaigns: |
| 57 | -# Example visit.greece.gr | ||
| 58 | -DL_URL_SCHEME=demo | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 49 | +# Example demo.app.gr | ||
| 50 | +DL_URL_SCHEME=demo.app.gr | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | #Fri Jul 26 17:08:44 EEST 2024 | 1 | #Fri Jul 26 17:08:44 EEST 2024 |
| 2 | distributionBase=GRADLE_USER_HOME | 2 | distributionBase=GRADLE_USER_HOME |
| 3 | distributionPath=wrapper/dists | 3 | distributionPath=wrapper/dists |
| 4 | -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip | 4 | +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip |
| 5 | zipStoreBase=GRADLE_USER_HOME | 5 | zipStoreBase=GRADLE_USER_HOME |
| 6 | zipStorePath=wrapper/dists | 6 | zipStorePath=wrapper/dists | ... | ... |
skill.md
0 → 100644
This diff is collapsed. Click to expand it.
| ... | @@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true | ... | @@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true |
| 5 | 5 | ||
| 6 | ext { | 6 | ext { |
| 7 | PUBLISH_GROUP_ID = 'ly.warp' | 7 | PUBLISH_GROUP_ID = 'ly.warp' |
| 8 | - PUBLISH_VERSION = '4.5.5.4deh3' | 8 | + PUBLISH_VERSION = '4.5.5.6deh4' |
| 9 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 9 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
| 10 | } | 10 | } |
| 11 | 11 | ... | ... |
| ... | @@ -45,6 +45,12 @@ | ... | @@ -45,6 +45,12 @@ |
| 45 | android:theme="@style/SDKAppTheme" /> | 45 | android:theme="@style/SDKAppTheme" /> |
| 46 | 46 | ||
| 47 | <activity | 47 | <activity |
| 48 | + android:name=".activities.SingleCouponsetActivity" | ||
| 49 | + android:exported="false" | ||
| 50 | + android:screenOrientation="portrait" | ||
| 51 | + android:theme="@style/SDKAppTheme" /> | ||
| 52 | + | ||
| 53 | + <activity | ||
| 48 | android:name=".activities.ProfileActivity" | 54 | android:name=".activities.ProfileActivity" |
| 49 | android:exported="false" | 55 | android:exported="false" |
| 50 | android:screenOrientation="portrait" | 56 | android:screenOrientation="portrait" | ... | ... |
| ... | @@ -1343,8 +1343,6 @@ public enum Warply { | ... | @@ -1343,8 +1343,6 @@ public enum Warply { |
| 1343 | else { | 1343 | else { |
| 1344 | if (warplyPath.equals("handle_image")) | 1344 | if (warplyPath.equals("handle_image")) |
| 1345 | sb = new StringBuilder(WarplyProperty.getBaseUrl(mContext) + WarpConstants.BASE_URL_API); | 1345 | sb = new StringBuilder(WarplyProperty.getBaseUrl(mContext) + WarpConstants.BASE_URL_API); |
| 1346 | - else if (warplyPath.equals("verify")) | ||
| 1347 | - sb = new StringBuilder(WarplyProperty.getBaseUrl(mContext) + WarplyProperty.getVerifyUrl(mContext)); | ||
| 1348 | else if (warplyPath.equals("cosuser")) | 1346 | else if (warplyPath.equals("cosuser")) |
| 1349 | sb = new StringBuilder(WarplyProperty.getBaseUrl(mContext) + "/partners/oauth/" + WarplyProperty.getAppUuid(mContext) + "/token"); | 1347 | sb = new StringBuilder(WarplyProperty.getBaseUrl(mContext) + "/partners/oauth/" + WarplyProperty.getAppUuid(mContext) + "/token"); |
| 1350 | else | 1348 | else | ... | ... |
| ... | @@ -3,6 +3,7 @@ package ly.warp.sdk.activities; | ... | @@ -3,6 +3,7 @@ package ly.warp.sdk.activities; |
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
| 6 | +import android.os.Parcelable; | ||
| 6 | import android.util.TypedValue; | 7 | import android.util.TypedValue; |
| 7 | import android.view.LayoutInflater; | 8 | import android.view.LayoutInflater; |
| 8 | import android.view.View; | 9 | import android.view.View; |
| ... | @@ -93,9 +94,9 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -93,9 +94,9 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 93 | 94 | ||
| 94 | @Override | 95 | @Override |
| 95 | public void onCouponsetClick(Couponset couponset, int position) { | 96 | public void onCouponsetClick(Couponset couponset, int position) { |
| 96 | -// Intent myIntent = new Intent(HomeActivity.this, SingleCouponActivity.class); | 97 | + Intent myIntent = new Intent(HomeActivity.this, SingleCouponsetActivity.class); |
| 97 | -// myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, couponset); | 98 | + myIntent.putExtra(SingleCouponsetActivity.EXTRA_OFFER_ITEM, (Parcelable) couponset); |
| 98 | -// startActivity(myIntent); | 99 | + startActivity(myIntent); |
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | // =========================================================== | 102 | // =========================================================== |
| ... | @@ -114,59 +115,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -114,59 +115,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 114 | mIvProfile.setOnClickListener(this); | 115 | mIvProfile.setOnClickListener(this); |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | - private void setupCouponsetSections(LinkedHashMap<String, ArrayList<Couponset>> categorizedMap) { | ||
| 118 | - mSectionsContainer.removeAllViews(); | ||
| 119 | - | ||
| 120 | - if (categorizedMap == null || categorizedMap.isEmpty()) { | ||
| 121 | - mSectionsLoading.setVisibility(View.GONE); | ||
| 122 | - return; | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - LayoutInflater inflater = LayoutInflater.from(this); | ||
| 126 | - int spacingInPixels = (int) TypedValue.applyDimension( | ||
| 127 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 128 | - | ||
| 129 | - for (Map.Entry<String, ArrayList<Couponset>> entry : categorizedMap.entrySet()) { | ||
| 130 | - String categoryName = entry.getKey(); | ||
| 131 | - ArrayList<Couponset> couponsets = entry.getValue(); | ||
| 132 | - | ||
| 133 | - if (couponsets == null || couponsets.isEmpty()) { | ||
| 134 | - continue; | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - View sectionView = inflater.inflate(R.layout.item_couponset_section, mSectionsContainer, false); | ||
| 138 | - | ||
| 139 | - TextView tvTitle = sectionView.findViewById(R.id.tv_section_title); | ||
| 140 | - String titleText = categoryName + " (" + couponsets.size() + ")"; | ||
| 141 | - tvTitle.setText(titleText); | ||
| 142 | - WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, tvTitle); | ||
| 143 | - | ||
| 144 | - TextView tvAll = sectionView.findViewById(R.id.tv_section_all); | ||
| 145 | - WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, tvAll); | ||
| 146 | - | ||
| 147 | - RecyclerView rvSection = sectionView.findViewById(R.id.rv_section_list); | ||
| 148 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | ||
| 149 | - rvSection.setLayoutManager(layoutManager); | ||
| 150 | - rvSection.setHasFixedSize(true); | ||
| 151 | - rvSection.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 152 | - | ||
| 153 | - List<Couponset> displayList = couponsets.size() > MAX_ITEMS_PER_SECTION | ||
| 154 | - ? new ArrayList<>(couponsets.subList(0, MAX_ITEMS_PER_SECTION)) | ||
| 155 | - : couponsets; | ||
| 156 | - | ||
| 157 | - CouponsetAdapter adapter = new CouponsetAdapter(this, displayList); | ||
| 158 | - adapter.setOnCouponsetClickListener(this); | ||
| 159 | - rvSection.setAdapter(adapter); | ||
| 160 | - | ||
| 161 | - mSectionsContainer.addView(sectionView); | ||
| 162 | - } | ||
| 163 | - mSectionsLoading.setVisibility(View.GONE); | ||
| 164 | - } | ||
| 165 | - | ||
| 166 | - // =========================================================== | ||
| 167 | - // Banner Methods | ||
| 168 | - // =========================================================== | ||
| 169 | - | ||
| 170 | private void setupBannerCarousel() { | 118 | private void setupBannerCarousel() { |
| 171 | mBannerViewPager = findViewById(R.id.banner_viewpager); | 119 | mBannerViewPager = findViewById(R.id.banner_viewpager); |
| 172 | mDotsContainer = findViewById(R.id.dots_container); | 120 | mDotsContainer = findViewById(R.id.dots_container); |
| ... | @@ -176,7 +124,17 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -176,7 +124,17 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 176 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(campaign))); | 124 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(campaign))); |
| 177 | }); | 125 | }); |
| 178 | mBannerAdapter.setOnBannerContentClickListener(article -> { | 126 | mBannerAdapter.setOnBannerContentClickListener(article -> { |
| 179 | - //TODO: click article | 127 | + if (article != null && article.getExtraFields() != null) { |
| 128 | + String couponsetUuid = article.getExtraFields().optString("url_link", null); | ||
| 129 | + if (couponsetUuid != null && !couponsetUuid.isEmpty()) { | ||
| 130 | + Couponset matchedCouponset = findCouponsetByUuid(couponsetUuid); | ||
| 131 | + if (matchedCouponset != null) { | ||
| 132 | + Intent myIntent = new Intent(HomeActivity.this, SingleCouponsetActivity.class); | ||
| 133 | + myIntent.putExtra(SingleCouponsetActivity.EXTRA_OFFER_ITEM, (Parcelable) matchedCouponset); | ||
| 134 | + startActivity(myIntent); | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + } | ||
| 180 | }); | 138 | }); |
| 181 | 139 | ||
| 182 | // Set the number of pages to preload for adjacent items | 140 | // Set the number of pages to preload for adjacent items |
| ... | @@ -220,9 +178,68 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -220,9 +178,68 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 220 | } | 178 | } |
| 221 | } | 179 | } |
| 222 | 180 | ||
| 223 | - // =========================================================== | 181 | + private void setupCouponsetSections(LinkedHashMap<String, ArrayList<Couponset>> categorizedMap) { |
| 224 | - // Callbacks | 182 | + mSectionsContainer.removeAllViews(); |
| 225 | - // =========================================================== | 183 | + |
| 184 | + if (categorizedMap == null || categorizedMap.isEmpty()) { | ||
| 185 | + mSectionsLoading.setVisibility(View.GONE); | ||
| 186 | + return; | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + LayoutInflater inflater = LayoutInflater.from(this); | ||
| 190 | + int spacingInPixels = (int) TypedValue.applyDimension( | ||
| 191 | + TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 192 | + | ||
| 193 | + for (Map.Entry<String, ArrayList<Couponset>> entry : categorizedMap.entrySet()) { | ||
| 194 | + String categoryName = entry.getKey(); | ||
| 195 | + ArrayList<Couponset> couponsets = entry.getValue(); | ||
| 196 | + | ||
| 197 | + if (couponsets == null || couponsets.isEmpty()) { | ||
| 198 | + continue; | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + View sectionView = inflater.inflate(R.layout.item_couponset_section, mSectionsContainer, false); | ||
| 202 | + | ||
| 203 | + TextView tvTitle = sectionView.findViewById(R.id.tv_section_title); | ||
| 204 | + String titleText = categoryName + " (" + couponsets.size() + ")"; | ||
| 205 | + tvTitle.setText(titleText); | ||
| 206 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, tvTitle); | ||
| 207 | + | ||
| 208 | + TextView tvAll = sectionView.findViewById(R.id.tv_section_all); | ||
| 209 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, tvAll); | ||
| 210 | + | ||
| 211 | + RecyclerView rvSection = sectionView.findViewById(R.id.rv_section_list); | ||
| 212 | + LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | ||
| 213 | + rvSection.setLayoutManager(layoutManager); | ||
| 214 | + rvSection.setHasFixedSize(true); | ||
| 215 | + rvSection.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 216 | + | ||
| 217 | + List<Couponset> displayList = couponsets.size() > MAX_ITEMS_PER_SECTION | ||
| 218 | + ? new ArrayList<>(couponsets.subList(0, MAX_ITEMS_PER_SECTION)) | ||
| 219 | + : couponsets; | ||
| 220 | + | ||
| 221 | + CouponsetAdapter adapter = new CouponsetAdapter(this, displayList); | ||
| 222 | + adapter.setOnCouponsetClickListener(this); | ||
| 223 | + rvSection.setAdapter(adapter); | ||
| 224 | + | ||
| 225 | + mSectionsContainer.addView(sectionView); | ||
| 226 | + } | ||
| 227 | + mSectionsLoading.setVisibility(View.GONE); | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + private Couponset findCouponsetByUuid(String uuid) { | ||
| 231 | + LinkedHashMap<String, ArrayList<Couponset>> categorizedMap = WarplyManagerHelper.getCouponsetCategorizedMap(); | ||
| 232 | + if (categorizedMap != null) { | ||
| 233 | + for (ArrayList<Couponset> couponsets : categorizedMap.values()) { | ||
| 234 | + for (Couponset couponset : couponsets) { | ||
| 235 | + if (uuid.equals(couponset.getUuid())) { | ||
| 236 | + return couponset; | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + return null; | ||
| 242 | + } | ||
| 226 | 243 | ||
| 227 | private final CallbackReceiver<ArrayList<BannerItem>> mCampaignsCallback = new CallbackReceiver<ArrayList<BannerItem>>() { | 244 | private final CallbackReceiver<ArrayList<BannerItem>> mCampaignsCallback = new CallbackReceiver<ArrayList<BannerItem>>() { |
| 228 | @Override | 245 | @Override | ... | ... |
| ... | @@ -3,28 +3,28 @@ package ly.warp.sdk.activities; | ... | @@ -3,28 +3,28 @@ package ly.warp.sdk.activities; |
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
| 6 | -import android.os.Build; | ||
| 7 | import android.os.Bundle; | 6 | import android.os.Bundle; |
| 7 | +import android.os.Parcelable; | ||
| 8 | import android.util.TypedValue; | 8 | import android.util.TypedValue; |
| 9 | import android.view.View; | 9 | import android.view.View; |
| 10 | -import android.view.WindowInsetsController; | ||
| 11 | import android.widget.ImageView; | 10 | import android.widget.ImageView; |
| 11 | +import android.widget.RelativeLayout; | ||
| 12 | import android.widget.TextView; | 12 | import android.widget.TextView; |
| 13 | 13 | ||
| 14 | import androidx.recyclerview.widget.LinearLayoutManager; | 14 | import androidx.recyclerview.widget.LinearLayoutManager; |
| 15 | import androidx.recyclerview.widget.RecyclerView; | 15 | import androidx.recyclerview.widget.RecyclerView; |
| 16 | 16 | ||
| 17 | -import java.util.List; | 17 | +import java.util.ArrayList; |
| 18 | 18 | ||
| 19 | import ly.warp.sdk.R; | 19 | import ly.warp.sdk.R; |
| 20 | import ly.warp.sdk.io.adapters.CouponAdapter; | 20 | import ly.warp.sdk.io.adapters.CouponAdapter; |
| 21 | import ly.warp.sdk.io.adapters.OfferAdapter; | 21 | import ly.warp.sdk.io.adapters.OfferAdapter; |
| 22 | -import ly.warp.sdk.io.models.CouponItem; | 22 | +import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 23 | -import ly.warp.sdk.io.models.DummyDataProvider; | 23 | +import ly.warp.sdk.io.models.Coupon; |
| 24 | -import ly.warp.sdk.io.models.OfferCategory; | ||
| 25 | import ly.warp.sdk.io.models.OfferItem; | 24 | import ly.warp.sdk.io.models.OfferItem; |
| 26 | import ly.warp.sdk.utils.WarpUtils; | 25 | import ly.warp.sdk.utils.WarpUtils; |
| 27 | -import ly.warp.sdk.views.HorizontalSpaceItemDecoration; | 26 | +import ly.warp.sdk.utils.WarplyManagerHelper; |
| 27 | +import ly.warp.sdk.utils.managers.WarplyManager; | ||
| 28 | import ly.warp.sdk.views.VerticalSpaceItemDecoration; | 28 | import ly.warp.sdk.views.VerticalSpaceItemDecoration; |
| 29 | 29 | ||
| 30 | public class ProfileActivity extends Activity implements View.OnClickListener, OfferAdapter.OnOfferClickListener, CouponAdapter.OnCouponClickListener { | 30 | public class ProfileActivity extends Activity implements View.OnClickListener, OfferAdapter.OnOfferClickListener, CouponAdapter.OnCouponClickListener { |
| ... | @@ -37,6 +37,7 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O | ... | @@ -37,6 +37,7 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O |
| 37 | // Fields | 37 | // Fields |
| 38 | // =========================================================== | 38 | // =========================================================== |
| 39 | 39 | ||
| 40 | + private RelativeLayout mPbLoading; | ||
| 40 | private TextView mTvHeaderTitle; | 41 | private TextView mTvHeaderTitle; |
| 41 | private ImageView mIvBack; | 42 | private ImageView mIvBack; |
| 42 | 43 | ||
| ... | @@ -51,7 +52,6 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O | ... | @@ -51,7 +52,6 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O |
| 51 | private RecyclerView mRvCoupons; | 52 | private RecyclerView mRvCoupons; |
| 52 | private CouponAdapter mCouponsAdapter; | 53 | private CouponAdapter mCouponsAdapter; |
| 53 | private TextView mBtnFilterActive, mBtnFilterFavorites, mBtnFilterRedeemed; | 54 | private TextView mBtnFilterActive, mBtnFilterFavorites, mBtnFilterRedeemed; |
| 54 | - private List<CouponItem> mCouponItems; | ||
| 55 | 55 | ||
| 56 | // =========================================================== | 56 | // =========================================================== |
| 57 | // Methods for/from SuperClass/Interfaces | 57 | // Methods for/from SuperClass/Interfaces |
| ... | @@ -68,11 +68,8 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O | ... | @@ -68,11 +68,8 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O |
| 68 | findViewById(R.id.header_layout), | 68 | findViewById(R.id.header_layout), |
| 69 | null); | 69 | null); |
| 70 | 70 | ||
| 71 | - // Setup profile suggestions section | 71 | + mPbLoading.setVisibility(View.VISIBLE); |
| 72 | - setupProfileSuggestionsSection(); | 72 | + WarplyManager.getCoupons(mCouponsCallback); |
| 73 | - | ||
| 74 | - // Setup my coupons section | ||
| 75 | - setupMyCouponsSection(); | ||
| 76 | } | 73 | } |
| 77 | 74 | ||
| 78 | @Override | 75 | @Override |
| ... | @@ -86,19 +83,19 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O | ... | @@ -86,19 +83,19 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O |
| 86 | if (id == R.id.iv_back) { | 83 | if (id == R.id.iv_back) { |
| 87 | onBackPressed(); | 84 | onBackPressed(); |
| 88 | } else if (id == R.id.btn_filter_active) { | 85 | } else if (id == R.id.btn_filter_active) { |
| 89 | - filterCoupons(CouponItem.STATUS_ACTIVE); | 86 | +// filterCoupons(CouponItem.STATUS_ACTIVE); |
| 90 | } else if (id == R.id.btn_filter_favorites) { | 87 | } else if (id == R.id.btn_filter_favorites) { |
| 91 | - filterCoupons(CouponItem.STATUS_FAVORITE); | 88 | +// filterCoupons(CouponItem.STATUS_FAVORITE); |
| 92 | } else if (id == R.id.btn_filter_redeemed) { | 89 | } else if (id == R.id.btn_filter_redeemed) { |
| 93 | - filterCoupons(CouponItem.STATUS_REDEEMED); | 90 | +// filterCoupons(CouponItem.STATUS_REDEEMED); |
| 94 | } | 91 | } |
| 95 | } | 92 | } |
| 96 | 93 | ||
| 97 | @Override | 94 | @Override |
| 98 | public void onOfferClick(OfferItem offerItem, int position) { | 95 | public void onOfferClick(OfferItem offerItem, int position) { |
| 99 | - Intent myIntent = new Intent(ProfileActivity.this, SingleCouponActivity.class); | 96 | +// Intent myIntent = new Intent(ProfileActivity.this, SingleCouponActivity.class); |
| 100 | - myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, offerItem); | 97 | +// myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, offerItem); |
| 101 | - startActivity(myIntent); | 98 | +// startActivity(myIntent); |
| 102 | } | 99 | } |
| 103 | 100 | ||
| 104 | @Override | 101 | @Override |
| ... | @@ -107,14 +104,14 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O | ... | @@ -107,14 +104,14 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O |
| 107 | } | 104 | } |
| 108 | 105 | ||
| 109 | @Override | 106 | @Override |
| 110 | - public void onCouponClick(CouponItem couponItem, int position) { | 107 | + public void onCouponClick(Coupon couponItem, int position) { |
| 111 | Intent myIntent = new Intent(ProfileActivity.this, SingleCouponActivity.class); | 108 | Intent myIntent = new Intent(ProfileActivity.this, SingleCouponActivity.class); |
| 112 | - myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, couponItem); | 109 | + myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, (Parcelable) couponItem); |
| 113 | startActivity(myIntent); | 110 | startActivity(myIntent); |
| 114 | } | 111 | } |
| 115 | 112 | ||
| 116 | @Override | 113 | @Override |
| 117 | - public void onFavoriteClick(CouponItem couponItem, int position) { | 114 | + public void onFavoriteClick(Coupon couponItem, int position) { |
| 118 | // Handle favorite click if needed | 115 | // Handle favorite click if needed |
| 119 | } | 116 | } |
| 120 | 117 | ||
| ... | @@ -126,6 +123,9 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O | ... | @@ -126,6 +123,9 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O |
| 126 | mIvBack = findViewById(R.id.iv_back); | 123 | mIvBack = findViewById(R.id.iv_back); |
| 127 | mIvBack.setOnClickListener(this); | 124 | mIvBack.setOnClickListener(this); |
| 128 | 125 | ||
| 126 | + mPbLoading = findViewById(R.id.pb_loading); | ||
| 127 | + mPbLoading.setOnTouchListener((v, event) -> true); | ||
| 128 | + | ||
| 129 | mTvHeaderTitle = findViewById(R.id.tv_header_title); | 129 | mTvHeaderTitle = findViewById(R.id.tv_header_title); |
| 130 | 130 | ||
| 131 | // Initialize Profile Suggestions section | 131 | // Initialize Profile Suggestions section |
| ... | @@ -151,63 +151,22 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O | ... | @@ -151,63 +151,22 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O |
| 151 | mBtnFilterActive, mBtnFilterFavorites, mBtnFilterRedeemed); | 151 | mBtnFilterActive, mBtnFilterFavorites, mBtnFilterRedeemed); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | - /** | ||
| 155 | - * Set up the Profile Suggestions section with dummy data | ||
| 156 | - */ | ||
| 157 | - private void setupProfileSuggestionsSection() { | ||
| 158 | - // Get Profile Suggestions data | ||
| 159 | - OfferCategory profileSuggestionsCategory = DummyDataProvider.getProfileSuggestions(); | ||
| 160 | - | ||
| 161 | - // Set category title with item count | ||
| 162 | - String categoryTitle = profileSuggestionsCategory.getName() + " (" + profileSuggestionsCategory.getItems().size() + ")"; | ||
| 163 | - mTvCategoryProfileSuggestions.setText(categoryTitle); | ||
| 164 | - | ||
| 165 | - // Set up RecyclerView | ||
| 166 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | ||
| 167 | - mRvProfileSuggestions.setLayoutManager(layoutManager); | ||
| 168 | - | ||
| 169 | - // Add spacing between items | ||
| 170 | - int spacingInPixels = (int) TypedValue.applyDimension( | ||
| 171 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 172 | - mRvProfileSuggestions.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 173 | - | ||
| 174 | - // Create and set adapter | ||
| 175 | - mProfileSuggestionsAdapter = new OfferAdapter(this, profileSuggestionsCategory.getItems()); | ||
| 176 | - mProfileSuggestionsAdapter.setOnOfferClickListener(this); | ||
| 177 | - mRvProfileSuggestions.setAdapter(mProfileSuggestionsAdapter); | ||
| 178 | - } | ||
| 179 | - | ||
| 180 | - /** | ||
| 181 | - * Set up the My Coupons section with dummy data and filters | ||
| 182 | - */ | ||
| 183 | private void setupMyCouponsSection() { | 154 | private void setupMyCouponsSection() { |
| 184 | - // Get coupons data | ||
| 185 | - mCouponItems = DummyDataProvider.getCoupons(); | ||
| 186 | - | ||
| 187 | - // Set up RecyclerView | ||
| 188 | LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); | 155 | LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); |
| 189 | mRvCoupons.setLayoutManager(layoutManager); | 156 | mRvCoupons.setLayoutManager(layoutManager); |
| 190 | mRvCoupons.setHasFixedSize(true); | 157 | mRvCoupons.setHasFixedSize(true); |
| 191 | 158 | ||
| 192 | - // Create and set adapter | 159 | + mCouponsAdapter = new CouponAdapter(this, WarplyManagerHelper.getCoupons()); |
| 193 | - mCouponsAdapter = new CouponAdapter(this, mCouponItems); | ||
| 194 | mCouponsAdapter.setOnCouponClickListener(this); | 160 | mCouponsAdapter.setOnCouponClickListener(this); |
| 195 | mRvCoupons.setAdapter(mCouponsAdapter); | 161 | mRvCoupons.setAdapter(mCouponsAdapter); |
| 196 | 162 | ||
| 197 | - // Add 16dp spacing between coupon items | ||
| 198 | int verticalSpacingInPixels = (int) TypedValue.applyDimension( | 163 | int verticalSpacingInPixels = (int) TypedValue.applyDimension( |
| 199 | TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); | 164 | TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); |
| 200 | mRvCoupons.addItemDecoration(new VerticalSpaceItemDecoration(verticalSpacingInPixels)); | 165 | mRvCoupons.addItemDecoration(new VerticalSpaceItemDecoration(verticalSpacingInPixels)); |
| 201 | 166 | ||
| 202 | - // Filter by active coupons by default | 167 | +// filterCoupons(CouponItem.STATUS_ACTIVE); |
| 203 | - filterCoupons(CouponItem.STATUS_ACTIVE); | ||
| 204 | } | 168 | } |
| 205 | 169 | ||
| 206 | - /** | ||
| 207 | - * Filter coupons by status | ||
| 208 | - * | ||
| 209 | - * @param status The status to filter by | ||
| 210 | - */ | ||
| 211 | private void filterCoupons(String status) { | 170 | private void filterCoupons(String status) { |
| 212 | // Reset all filter button styles | 171 | // Reset all filter button styles |
| 213 | mBtnFilterActive.setBackgroundResource(R.drawable.shape_transparent_black_border); | 172 | mBtnFilterActive.setBackgroundResource(R.drawable.shape_transparent_black_border); |
| ... | @@ -220,22 +179,35 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O | ... | @@ -220,22 +179,35 @@ public class ProfileActivity extends Activity implements View.OnClickListener, O |
| 220 | mBtnFilterRedeemed.setTextColor(getResources().getColor(R.color.custom_black2)); | 179 | mBtnFilterRedeemed.setTextColor(getResources().getColor(R.color.custom_black2)); |
| 221 | 180 | ||
| 222 | // Set selected filter button style | 181 | // Set selected filter button style |
| 223 | - if (CouponItem.STATUS_ACTIVE.equals(status)) { | 182 | +// if (CouponItem.STATUS_ACTIVE.equals(status)) { |
| 224 | - mBtnFilterActive.setBackgroundResource(R.drawable.shape_rectangle_rounded_black); | 183 | +// mBtnFilterActive.setBackgroundResource(R.drawable.shape_rectangle_rounded_black); |
| 225 | - mBtnFilterActive.setTextColor(Color.WHITE); | 184 | +// mBtnFilterActive.setTextColor(Color.WHITE); |
| 226 | - } else if (CouponItem.STATUS_FAVORITE.equals(status)) { | 185 | +// } else if (CouponItem.STATUS_FAVORITE.equals(status)) { |
| 227 | - mBtnFilterFavorites.setBackgroundResource(R.drawable.shape_rectangle_rounded_black); | 186 | +// mBtnFilterFavorites.setBackgroundResource(R.drawable.shape_rectangle_rounded_black); |
| 228 | - mBtnFilterFavorites.setTextColor(Color.WHITE); | 187 | +// mBtnFilterFavorites.setTextColor(Color.WHITE); |
| 229 | - } else if (CouponItem.STATUS_REDEEMED.equals(status)) { | 188 | +// } else if (CouponItem.STATUS_REDEEMED.equals(status)) { |
| 230 | - mBtnFilterRedeemed.setBackgroundResource(R.drawable.shape_rectangle_rounded_black); | 189 | +// mBtnFilterRedeemed.setBackgroundResource(R.drawable.shape_rectangle_rounded_black); |
| 231 | - mBtnFilterRedeemed.setTextColor(Color.WHITE); | 190 | +// mBtnFilterRedeemed.setTextColor(Color.WHITE); |
| 232 | - } | 191 | +// } |
| 233 | 192 | ||
| 234 | // Apply filter to adapter | 193 | // Apply filter to adapter |
| 235 | - mCouponsAdapter.filterByStatus(status); | 194 | +// mCouponsAdapter.filterByStatus(status); |
| 236 | } | 195 | } |
| 237 | 196 | ||
| 238 | // =========================================================== | 197 | // =========================================================== |
| 239 | // Inner and Anonymous Classes | 198 | // Inner and Anonymous Classes |
| 240 | // =========================================================== | 199 | // =========================================================== |
| 200 | + | ||
| 201 | + private final CallbackReceiver<ArrayList<Coupon>> mCouponsCallback = new CallbackReceiver<ArrayList<Coupon>>() { | ||
| 202 | + @Override | ||
| 203 | + public void onSuccess(ArrayList<Coupon> result) { | ||
| 204 | + mPbLoading.setVisibility(View.GONE); | ||
| 205 | + setupMyCouponsSection(); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + @Override | ||
| 209 | + public void onFailure(int errorCode) { | ||
| 210 | + mPbLoading.setVisibility(View.GONE); | ||
| 211 | + } | ||
| 212 | + }; | ||
| 241 | } | 213 | } | ... | ... |
| ... | @@ -5,32 +5,40 @@ import android.content.ClipData; | ... | @@ -5,32 +5,40 @@ import android.content.ClipData; |
| 5 | import android.content.ClipboardManager; | 5 | import android.content.ClipboardManager; |
| 6 | import android.content.Context; | 6 | import android.content.Context; |
| 7 | import android.content.Intent; | 7 | import android.content.Intent; |
| 8 | -import android.graphics.Color; | ||
| 9 | -import android.os.Build; | ||
| 10 | import android.os.Bundle; | 8 | import android.os.Bundle; |
| 9 | +import android.text.TextUtils; | ||
| 11 | import android.view.View; | 10 | import android.view.View; |
| 12 | -import android.view.WindowInsetsController; | ||
| 13 | import android.widget.ImageView; | 11 | import android.widget.ImageView; |
| 14 | import android.widget.LinearLayout; | 12 | import android.widget.LinearLayout; |
| 15 | import android.widget.TextView; | 13 | import android.widget.TextView; |
| 16 | import android.widget.Toast; | 14 | import android.widget.Toast; |
| 17 | 15 | ||
| 16 | +import androidx.core.text.HtmlCompat; | ||
| 17 | + | ||
| 18 | +import com.bumptech.glide.Glide; | ||
| 19 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
| 20 | + | ||
| 21 | +import java.text.ParseException; | ||
| 22 | +import java.text.SimpleDateFormat; | ||
| 23 | +import java.util.Date; | ||
| 24 | +import java.util.Locale; | ||
| 25 | + | ||
| 18 | import ly.warp.sdk.R; | 26 | import ly.warp.sdk.R; |
| 19 | -import ly.warp.sdk.io.models.OfferItem; | 27 | +import ly.warp.sdk.io.models.Coupon; |
| 20 | import ly.warp.sdk.utils.WarpUtils; | 28 | import ly.warp.sdk.utils.WarpUtils; |
| 21 | 29 | ||
| 22 | public class SingleCouponActivity extends Activity implements View.OnClickListener { | 30 | public class SingleCouponActivity extends Activity implements View.OnClickListener { |
| 23 | // =========================================================== | 31 | // =========================================================== |
| 24 | // Constants | 32 | // Constants |
| 25 | // =========================================================== | 33 | // =========================================================== |
| 26 | - public static final String EXTRA_OFFER_ITEM = "offer_item"; | 34 | + public static final String EXTRA_OFFER_ITEM = "coupon_item"; |
| 27 | 35 | ||
| 28 | // =========================================================== | 36 | // =========================================================== |
| 29 | // Fields | 37 | // Fields |
| 30 | // =========================================================== | 38 | // =========================================================== |
| 31 | 39 | ||
| 32 | private ImageView mIvBack; | 40 | private ImageView mIvBack; |
| 33 | - private OfferItem mOfferItem; | 41 | + private Coupon mOfferItem; |
| 34 | private TextView mTvSmallDescription; | 42 | private TextView mTvSmallDescription; |
| 35 | private TextView mTvFullDescription; | 43 | private TextView mTvFullDescription; |
| 36 | private TextView mTvEndDate; | 44 | private TextView mTvEndDate; |
| ... | @@ -80,10 +88,9 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -80,10 +88,9 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 80 | super.onCreate(savedInstanceState); | 88 | super.onCreate(savedInstanceState); |
| 81 | setContentView(R.layout.activity_single_coupon); | 89 | setContentView(R.layout.activity_single_coupon); |
| 82 | 90 | ||
| 83 | - // Get offer item from intent | ||
| 84 | Intent intent = getIntent(); | 91 | Intent intent = getIntent(); |
| 85 | if (intent != null && intent.hasExtra(EXTRA_OFFER_ITEM)) { | 92 | if (intent != null && intent.hasExtra(EXTRA_OFFER_ITEM)) { |
| 86 | - mOfferItem = (OfferItem) intent.getSerializableExtra(EXTRA_OFFER_ITEM); | 93 | + mOfferItem = (Coupon) intent.getSerializableExtra(EXTRA_OFFER_ITEM); |
| 87 | } | 94 | } |
| 88 | 95 | ||
| 89 | initViews(); | 96 | initViews(); |
| ... | @@ -151,34 +158,35 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -151,34 +158,35 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 151 | mTvEndDate, mTvFullDescription, mTvCouponCodeTitle, mTvQrCodeTitle, mTvTermsText, | 158 | mTvEndDate, mTvFullDescription, mTvCouponCodeTitle, mTvQrCodeTitle, mTvTermsText, |
| 152 | mTVMoreTitle, mTvMoreButton); | 159 | mTVMoreTitle, mTvMoreButton); |
| 153 | 160 | ||
| 154 | - // Populate views with offer data | ||
| 155 | if (mOfferItem != null) { | 161 | if (mOfferItem != null) { |
| 156 | - mTvValue.setText(mOfferItem.getValue()); | 162 | + if (mOfferItem.getExpiration() != null && !mOfferItem.getExpiration().isEmpty()) { |
| 157 | -// mTvSmallDescription.setText(mOfferItem.getDescription()); | 163 | + String formattedDate = formatValidityDate(mOfferItem.getExpiration()); |
| 158 | - | ||
| 159 | - // Store the full description text | ||
| 160 | - mFullDescriptionText = mOfferItem.getFullDescription(); | ||
| 161 | - mTvFullDescription.setText(mFullDescriptionText); | ||
| 162 | - | ||
| 163 | - // Format and set the end date | ||
| 164 | - String endDate = mOfferItem.getEndDate(); | ||
| 165 | - if (endDate != null && !endDate.isEmpty()) { | ||
| 166 | - // Convert from DD/MM/YYYY to DD-MM-YYYY | ||
| 167 | - String formattedDate = endDate.replace("/", "-"); | ||
| 168 | mTvEndDate.setText(getString(R.string.demo_valid_until, formattedDate)); | 164 | mTvEndDate.setText(getString(R.string.demo_valid_until, formattedDate)); |
| 165 | + mTvEndDate.setVisibility(View.VISIBLE); | ||
| 166 | + } else { | ||
| 167 | + mTvEndDate.setVisibility(View.GONE); | ||
| 169 | } | 168 | } |
| 170 | 169 | ||
| 171 | - // Load image (in a real app, you would use an image loading library) | 170 | + if (mOfferItem.getCouponsetDetails() != null && mOfferItem.getCouponsetDetails().getImg_preview() != null && !TextUtils.isEmpty(mOfferItem.getCouponsetDetails().getImg_preview())) { |
| 172 | - // For demo purposes, we'll use a placeholder | 171 | + Glide.with(this) |
| 173 | - int imageResId = getResources().getIdentifier( | 172 | +// .setDefaultRequestOptions( |
| 174 | - mOfferItem.getImageUrl().replace(".png", ""), | 173 | +// RequestOptions |
| 175 | - "drawable", | 174 | +// .placeholderOf(R.drawable.demo_logo) |
| 176 | - getPackageName()); | 175 | +// .error(R.drawable.demo_logo)) |
| 177 | - | 176 | + .load(mOfferItem.getCouponsetDetails().getImg_preview()) |
| 178 | - if (imageResId != 0) { | 177 | + .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 179 | - mIvImage.setImageResource(imageResId); | 178 | + .into(mIvImage); |
| 180 | } | 179 | } |
| 181 | 180 | ||
| 181 | + if (mOfferItem.getCouponsetDetails() != null && mOfferItem.getCouponsetDetails().getName() != null && !TextUtils.isEmpty(mOfferItem.getCouponsetDetails().getName())) | ||
| 182 | + mTvValue.setText(mOfferItem.getCouponsetDetails().getName()); | ||
| 183 | + if (mOfferItem.getCouponsetDetails() != null && mOfferItem.getCouponsetDetails().getShort_description() != null && !TextUtils.isEmpty(mOfferItem.getCouponsetDetails().getShort_description())) | ||
| 184 | + mTvSmallDescription.setText(mOfferItem.getCouponsetDetails().getShort_description()); | ||
| 185 | + if (mOfferItem.getCouponsetDetails() != null && mOfferItem.getCouponsetDetails().getDescription() != null && !TextUtils.isEmpty(mOfferItem.getCouponsetDetails().getDescription())) | ||
| 186 | + mTvFullDescription.setText(HtmlCompat.fromHtml(mOfferItem.getCouponsetDetails().getDescription(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | ||
| 187 | + if (mOfferItem.getCouponsetDetails() != null && mOfferItem.getCouponsetDetails().getTerms() != null && !TextUtils.isEmpty(mOfferItem.getCouponsetDetails().getTerms())) | ||
| 188 | + mTvTermsText.setText(HtmlCompat.fromHtml(mOfferItem.getCouponsetDetails().getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | ||
| 189 | + | ||
| 182 | // Setup the More button | 190 | // Setup the More button |
| 183 | setupMoreButton(); | 191 | setupMoreButton(); |
| 184 | 192 | ||
| ... | @@ -193,18 +201,26 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -193,18 +201,26 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 193 | } | 201 | } |
| 194 | } | 202 | } |
| 195 | 203 | ||
| 196 | - /** | 204 | + private String formatValidityDate(String endDate) { |
| 197 | - * Sets up the coupon code expandable section | 205 | + try { |
| 198 | - */ | 206 | + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); |
| 199 | - private void setupCouponCodeSection() { | 207 | + Date date = inputFormat.parse(endDate); |
| 200 | - // Set coupon code - using a hardcoded value for demo purposes | 208 | + SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); |
| 201 | - // In a real app, this would come from the offer item | 209 | + return "έως " + outputFormat.format(date); |
| 202 | - String couponCode = "coupons_ab"; | 210 | + } catch (ParseException e) { |
| 203 | - if (mOfferItem != null && mOfferItem.getId() != null) { | 211 | + try { |
| 204 | - // Use offer ID as part of the coupon code for demo purposes | 212 | + SimpleDateFormat inputFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()); |
| 205 | - couponCode = "coupon_" + mOfferItem.getId().toLowerCase(); | 213 | + Date date = inputFormat2.parse(endDate); |
| 214 | + SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); | ||
| 215 | + return "έως " + outputFormat.format(date); | ||
| 216 | + } catch (ParseException e2) { | ||
| 217 | + return endDate; | ||
| 218 | + } | ||
| 206 | } | 219 | } |
| 207 | - mTvCouponCode.setText(couponCode); | 220 | + } |
| 221 | + | ||
| 222 | + private void setupCouponCodeSection() { | ||
| 223 | + mTvCouponCode.setText(mOfferItem.getCoupon()); | ||
| 208 | 224 | ||
| 209 | // Set click listener for the header to expand/collapse | 225 | // Set click listener for the header to expand/collapse |
| 210 | mCouponCodeHeader.setOnClickListener(new View.OnClickListener() { | 226 | mCouponCodeHeader.setOnClickListener(new View.OnClickListener() { |
| ... | @@ -231,9 +247,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -231,9 +247,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 231 | }); | 247 | }); |
| 232 | } | 248 | } |
| 233 | 249 | ||
| 234 | - /** | ||
| 235 | - * Toggles between expanded and collapsed states for the coupon code section | ||
| 236 | - */ | ||
| 237 | private void toggleCouponCodeExpansion() { | 250 | private void toggleCouponCodeExpansion() { |
| 238 | if (mIsCouponCodeExpanded) { | 251 | if (mIsCouponCodeExpanded) { |
| 239 | // Collapse the content | 252 | // Collapse the content |
| ... | @@ -248,9 +261,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -248,9 +261,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 248 | } | 261 | } |
| 249 | } | 262 | } |
| 250 | 263 | ||
| 251 | - /** | ||
| 252 | - * Copies the coupon code to the clipboard | ||
| 253 | - */ | ||
| 254 | private void copyCouponCodeToClipboard() { | 264 | private void copyCouponCodeToClipboard() { |
| 255 | String couponCode = mTvCouponCode.getText().toString(); | 265 | String couponCode = mTvCouponCode.getText().toString(); |
| 256 | 266 | ||
| ... | @@ -267,9 +277,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -267,9 +277,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 267 | Toast.makeText(this, R.string.demo_copy_success, Toast.LENGTH_SHORT).show(); | 277 | Toast.makeText(this, R.string.demo_copy_success, Toast.LENGTH_SHORT).show(); |
| 268 | } | 278 | } |
| 269 | 279 | ||
| 270 | - /** | ||
| 271 | - * Sets up the "More" button for expanding/collapsing the description text | ||
| 272 | - */ | ||
| 273 | private void setupMoreButton() { | 280 | private void setupMoreButton() { |
| 274 | // Wait for layout to be ready to check if text is truncated | 281 | // Wait for layout to be ready to check if text is truncated |
| 275 | mTvFullDescription.post(new Runnable() { | 282 | mTvFullDescription.post(new Runnable() { |
| ... | @@ -292,9 +299,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -292,9 +299,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 292 | }); | 299 | }); |
| 293 | } | 300 | } |
| 294 | 301 | ||
| 295 | - /** | ||
| 296 | - * Toggles between expanded and collapsed states for the description text | ||
| 297 | - */ | ||
| 298 | private void toggleDescriptionExpansion() { | 302 | private void toggleDescriptionExpansion() { |
| 299 | if (mIsDescriptionExpanded) { | 303 | if (mIsDescriptionExpanded) { |
| 300 | // Collapse the text | 304 | // Collapse the text |
| ... | @@ -309,9 +313,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -309,9 +313,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 309 | } | 313 | } |
| 310 | } | 314 | } |
| 311 | 315 | ||
| 312 | - /** | ||
| 313 | - * Sets up the QR code expandable section | ||
| 314 | - */ | ||
| 315 | private void setupQrCodeSection() { | 316 | private void setupQrCodeSection() { |
| 316 | // Set click listener for the header to expand/collapse | 317 | // Set click listener for the header to expand/collapse |
| 317 | mQrCodeHeader.setOnClickListener(new View.OnClickListener() { | 318 | mQrCodeHeader.setOnClickListener(new View.OnClickListener() { |
| ... | @@ -330,9 +331,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -330,9 +331,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 330 | }); | 331 | }); |
| 331 | } | 332 | } |
| 332 | 333 | ||
| 333 | - /** | ||
| 334 | - * Toggles between expanded and collapsed states for the QR code section | ||
| 335 | - */ | ||
| 336 | private void toggleQrCodeExpansion() { | 334 | private void toggleQrCodeExpansion() { |
| 337 | if (mIsQrCodeExpanded) { | 335 | if (mIsQrCodeExpanded) { |
| 338 | // Collapse the content | 336 | // Collapse the content |
| ... | @@ -347,9 +345,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -347,9 +345,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 347 | } | 345 | } |
| 348 | } | 346 | } |
| 349 | 347 | ||
| 350 | - /** | ||
| 351 | - * Sets up the Terms of Use expandable section | ||
| 352 | - */ | ||
| 353 | private void setupTermsSection() { | 348 | private void setupTermsSection() { |
| 354 | // Set click listener for the header to expand/collapse | 349 | // Set click listener for the header to expand/collapse |
| 355 | mTermsHeader.setOnClickListener(new View.OnClickListener() { | 350 | mTermsHeader.setOnClickListener(new View.OnClickListener() { |
| ... | @@ -368,9 +363,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen | ... | @@ -368,9 +363,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen |
| 368 | }); | 363 | }); |
| 369 | } | 364 | } |
| 370 | 365 | ||
| 371 | - /** | ||
| 372 | - * Toggles between expanded and collapsed states for the Terms of Use section | ||
| 373 | - */ | ||
| 374 | private void toggleTermsExpansion() { | 366 | private void toggleTermsExpansion() { |
| 375 | if (mIsTermsExpanded) { | 367 | if (mIsTermsExpanded) { |
| 376 | // Collapse the content | 368 | // Collapse the content | ... | ... |
| 1 | +package ly.warp.sdk.activities; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Intent; | ||
| 5 | +import android.os.Bundle; | ||
| 6 | +import android.text.TextUtils; | ||
| 7 | +import android.view.View; | ||
| 8 | +import android.widget.ImageView; | ||
| 9 | +import android.widget.LinearLayout; | ||
| 10 | +import android.widget.TextView; | ||
| 11 | + | ||
| 12 | +import androidx.core.text.HtmlCompat; | ||
| 13 | + | ||
| 14 | +import com.bumptech.glide.Glide; | ||
| 15 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
| 16 | + | ||
| 17 | +import java.text.ParseException; | ||
| 18 | +import java.text.SimpleDateFormat; | ||
| 19 | +import java.util.Date; | ||
| 20 | +import java.util.Locale; | ||
| 21 | + | ||
| 22 | +import ly.warp.sdk.R; | ||
| 23 | +import ly.warp.sdk.io.models.Couponset; | ||
| 24 | +import ly.warp.sdk.utils.WarpUtils; | ||
| 25 | + | ||
| 26 | +public class SingleCouponsetActivity extends Activity implements View.OnClickListener { | ||
| 27 | + // =========================================================== | ||
| 28 | + // Constants | ||
| 29 | + // =========================================================== | ||
| 30 | + public static final String EXTRA_OFFER_ITEM = "offer_item"; | ||
| 31 | + | ||
| 32 | + // =========================================================== | ||
| 33 | + // Fields | ||
| 34 | + // =========================================================== | ||
| 35 | + | ||
| 36 | + private ImageView mIvBack; | ||
| 37 | + private Couponset mOfferItem; | ||
| 38 | + private TextView mTvSmallDescription; | ||
| 39 | + private TextView mTvFullDescription; | ||
| 40 | + private TextView mTvEndDate; | ||
| 41 | + private TextView mTvValue; | ||
| 42 | + private TextView mTvMoreButton; | ||
| 43 | + private ImageView mIvImage; | ||
| 44 | + | ||
| 45 | + private boolean mIsDescriptionExpanded = false; | ||
| 46 | + | ||
| 47 | + // Terms of Use section | ||
| 48 | + private LinearLayout mTermsContainer; | ||
| 49 | + private LinearLayout mTermsHeader; | ||
| 50 | + private LinearLayout mTermsContent; | ||
| 51 | + private ImageView mIvTermsArrow; | ||
| 52 | + private TextView mTvTermsText; | ||
| 53 | + private boolean mIsTermsExpanded = false; | ||
| 54 | + | ||
| 55 | + private TextView mTvHeaderTitle, mTvTermsTitle, mTvShopsTitle, mTvWebsiteTitle, mTVMoreTitle; | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + // =========================================================== | ||
| 59 | + // Methods for/from SuperClass/Interfaces | ||
| 60 | + // =========================================================== | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void onCreate(Bundle savedInstanceState) { | ||
| 64 | + super.onCreate(savedInstanceState); | ||
| 65 | + setContentView(R.layout.activity_single_couponset); | ||
| 66 | + | ||
| 67 | + Intent intent = getIntent(); | ||
| 68 | + if (intent != null && intent.hasExtra(EXTRA_OFFER_ITEM)) { | ||
| 69 | + mOfferItem = (Couponset) intent.getSerializableExtra(EXTRA_OFFER_ITEM); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + initViews(); | ||
| 73 | + | ||
| 74 | + WarpUtils.applyEdgeToEdge(this, | ||
| 75 | + findViewById(R.id.header_layout), | ||
| 76 | + null); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Override | ||
| 80 | + public void onResume() { | ||
| 81 | + super.onResume(); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Override | ||
| 85 | + public void onClick(View v) { | ||
| 86 | + if (v.getId() == R.id.iv_back) { | ||
| 87 | + onBackPressed(); | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + // =========================================================== | ||
| 92 | + // Methods | ||
| 93 | + // =========================================================== | ||
| 94 | + | ||
| 95 | + private void initViews() { | ||
| 96 | + mIvBack = findViewById(R.id.iv_back); | ||
| 97 | + mIvBack.setOnClickListener(this); | ||
| 98 | + | ||
| 99 | + // Initialize views | ||
| 100 | + mTvSmallDescription = findViewById(R.id.tv_coupon_small_description); | ||
| 101 | + mTvFullDescription = findViewById(R.id.tv_coupon_full_description); | ||
| 102 | + mTvEndDate = findViewById(R.id.tv_coupon_end_date); | ||
| 103 | + mTvValue = findViewById(R.id.tv_coupon_value); | ||
| 104 | + mIvImage = findViewById(R.id.iv_coupon_image); | ||
| 105 | + mTvMoreButton = findViewById(R.id.tv_more_button); | ||
| 106 | + | ||
| 107 | + // Initialize Terms of Use section | ||
| 108 | + mTermsContainer = findViewById(R.id.terms_container); | ||
| 109 | + mTermsHeader = findViewById(R.id.terms_header); | ||
| 110 | + mTermsContent = findViewById(R.id.terms_content); | ||
| 111 | + mIvTermsArrow = findViewById(R.id.iv_terms_arrow); | ||
| 112 | + mTvTermsText = findViewById(R.id.tv_terms_text); | ||
| 113 | + | ||
| 114 | + mTvHeaderTitle = findViewById(R.id.tv_header_title); | ||
| 115 | + mTvTermsTitle = findViewById(R.id.tv_terms_title); | ||
| 116 | + mTvShopsTitle = findViewById(R.id.tv_shops_title); | ||
| 117 | + mTvWebsiteTitle = findViewById(R.id.tv_website_title); | ||
| 118 | + mTVMoreTitle = findViewById(R.id.tv_more_title); | ||
| 119 | + | ||
| 120 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, mTvHeaderTitle, mTvValue, | ||
| 121 | + mTvTermsTitle, mTvShopsTitle, mTvWebsiteTitle); | ||
| 122 | + | ||
| 123 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, mTvSmallDescription, | ||
| 124 | + mTvEndDate, mTvFullDescription, mTvTermsText, | ||
| 125 | + mTVMoreTitle, mTvMoreButton); | ||
| 126 | + | ||
| 127 | + if (mOfferItem != null) { | ||
| 128 | + if (mOfferItem.getEndDate() != null && !mOfferItem.getEndDate().isEmpty()) { | ||
| 129 | + String formattedDate = formatValidityDate(mOfferItem.getEndDate()); | ||
| 130 | + mTvEndDate.setText(getString(R.string.demo_valid_until, formattedDate)); | ||
| 131 | + mTvEndDate.setVisibility(View.VISIBLE); | ||
| 132 | + } else { | ||
| 133 | + mTvEndDate.setVisibility(View.GONE); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + if (!TextUtils.isEmpty(mOfferItem.getImg_preview())) { | ||
| 137 | + Glide.with(this) | ||
| 138 | +// .setDefaultRequestOptions( | ||
| 139 | +// RequestOptions | ||
| 140 | +// .placeholderOf(R.drawable.demo_logo) | ||
| 141 | +// .error(R.drawable.demo_logo)) | ||
| 142 | + .load(mOfferItem.getImg_preview()) | ||
| 143 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
| 144 | + .into(mIvImage); | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + if (!TextUtils.isEmpty(mOfferItem.getName())) | ||
| 148 | + mTvValue.setText(mOfferItem.getName()); | ||
| 149 | + if (!TextUtils.isEmpty(mOfferItem.getShort_description())) | ||
| 150 | + mTvSmallDescription.setText(mOfferItem.getShort_description()); | ||
| 151 | + if (!TextUtils.isEmpty(mOfferItem.getDescription())) | ||
| 152 | + mTvFullDescription.setText(HtmlCompat.fromHtml(mOfferItem.getDescription(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | ||
| 153 | + if (!TextUtils.isEmpty(mOfferItem.getTerms())) | ||
| 154 | + mTvTermsText.setText(HtmlCompat.fromHtml(mOfferItem.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | ||
| 155 | + | ||
| 156 | + // Setup the More button | ||
| 157 | + setupMoreButton(); | ||
| 158 | + | ||
| 159 | + // Setup Terms of Use section | ||
| 160 | + setupTermsSection(); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + private void setupMoreButton() { | ||
| 165 | + // Wait for layout to be ready to check if text is truncated | ||
| 166 | + mTvFullDescription.post(new Runnable() { | ||
| 167 | + @Override | ||
| 168 | + public void run() { | ||
| 169 | + // Check if text is truncated (more than 4 lines) | ||
| 170 | + if (mTvFullDescription.getLineCount() > 3) { | ||
| 171 | + // Show the More button | ||
| 172 | + mTvMoreButton.setVisibility(View.VISIBLE); | ||
| 173 | + | ||
| 174 | + // Set click listener for the More button | ||
| 175 | + mTvMoreButton.setOnClickListener(new View.OnClickListener() { | ||
| 176 | + @Override | ||
| 177 | + public void onClick(View v) { | ||
| 178 | + toggleDescriptionExpansion(); | ||
| 179 | + } | ||
| 180 | + }); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + }); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + private void toggleDescriptionExpansion() { | ||
| 187 | + if (mIsDescriptionExpanded) { | ||
| 188 | + // Collapse the text | ||
| 189 | + mTvFullDescription.setMaxLines(4); | ||
| 190 | + mTvMoreButton.setText(R.string.demo_more); | ||
| 191 | + mIsDescriptionExpanded = false; | ||
| 192 | + } else { | ||
| 193 | + // Expand the text | ||
| 194 | + mTvFullDescription.setMaxLines(Integer.MAX_VALUE); | ||
| 195 | + mTvMoreButton.setText(R.string.demo_less); | ||
| 196 | + mIsDescriptionExpanded = true; | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + private void setupTermsSection() { | ||
| 201 | + // Set click listener for the header to expand/collapse | ||
| 202 | + mTermsHeader.setOnClickListener(new View.OnClickListener() { | ||
| 203 | + @Override | ||
| 204 | + public void onClick(View v) { | ||
| 205 | + toggleTermsExpansion(); | ||
| 206 | + } | ||
| 207 | + }); | ||
| 208 | + | ||
| 209 | + // Set click listener for the entire container as well | ||
| 210 | + mTermsContainer.setOnClickListener(new View.OnClickListener() { | ||
| 211 | + @Override | ||
| 212 | + public void onClick(View v) { | ||
| 213 | + toggleTermsExpansion(); | ||
| 214 | + } | ||
| 215 | + }); | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + private void toggleTermsExpansion() { | ||
| 219 | + if (mIsTermsExpanded) { | ||
| 220 | + // Collapse the content | ||
| 221 | + mTermsContent.setVisibility(View.GONE); | ||
| 222 | + mIvTermsArrow.setImageResource(R.drawable.ic_arrow_down); | ||
| 223 | + mIsTermsExpanded = false; | ||
| 224 | + } else { | ||
| 225 | + // Expand the content | ||
| 226 | + mTermsContent.setVisibility(View.VISIBLE); | ||
| 227 | + mIvTermsArrow.setImageResource(R.drawable.ic_arrow_up); | ||
| 228 | + mIsTermsExpanded = true; | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + private String formatValidityDate(String endDate) { | ||
| 233 | + try { | ||
| 234 | + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); | ||
| 235 | + Date date = inputFormat.parse(endDate); | ||
| 236 | + SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); | ||
| 237 | + return "έως " + outputFormat.format(date); | ||
| 238 | + } catch (ParseException e) { | ||
| 239 | + try { | ||
| 240 | + SimpleDateFormat inputFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()); | ||
| 241 | + Date date = inputFormat2.parse(endDate); | ||
| 242 | + SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); | ||
| 243 | + return "έως " + outputFormat.format(date); | ||
| 244 | + } catch (ParseException e2) { | ||
| 245 | + return endDate; | ||
| 246 | + } | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + // =========================================================== | ||
| 251 | + // Inner and Anonymous Classes | ||
| 252 | + // =========================================================== | ||
| 253 | +} |
| 1 | package ly.warp.sdk.io.adapters; | 1 | package ly.warp.sdk.io.adapters; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | +import android.text.TextUtils; | ||
| 4 | import android.util.TypedValue; | 5 | import android.util.TypedValue; |
| 5 | import android.view.LayoutInflater; | 6 | import android.view.LayoutInflater; |
| 6 | import android.view.View; | 7 | import android.view.View; |
| ... | @@ -12,17 +13,17 @@ import androidx.annotation.NonNull; | ... | @@ -12,17 +13,17 @@ import androidx.annotation.NonNull; |
| 12 | import androidx.recyclerview.widget.RecyclerView; | 13 | import androidx.recyclerview.widget.RecyclerView; |
| 13 | 14 | ||
| 14 | import com.bumptech.glide.Glide; | 15 | import com.bumptech.glide.Glide; |
| 16 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
| 15 | import com.bumptech.glide.load.resource.bitmap.CenterCrop; | 17 | import com.bumptech.glide.load.resource.bitmap.CenterCrop; |
| 16 | 18 | ||
| 17 | import java.text.ParseException; | 19 | import java.text.ParseException; |
| 18 | import java.text.SimpleDateFormat; | 20 | import java.text.SimpleDateFormat; |
| 19 | import java.util.ArrayList; | 21 | import java.util.ArrayList; |
| 20 | import java.util.Date; | 22 | import java.util.Date; |
| 21 | -import java.util.List; | ||
| 22 | import java.util.Locale; | 23 | import java.util.Locale; |
| 23 | 24 | ||
| 24 | import ly.warp.sdk.R; | 25 | import ly.warp.sdk.R; |
| 25 | -import ly.warp.sdk.io.models.CouponItem; | 26 | +import ly.warp.sdk.io.models.Coupon; |
| 26 | import ly.warp.sdk.utils.TopRoundedCornersTransformation; | 27 | import ly.warp.sdk.utils.TopRoundedCornersTransformation; |
| 27 | import ly.warp.sdk.utils.WarpUtils; | 28 | import ly.warp.sdk.utils.WarpUtils; |
| 28 | 29 | ||
| ... | @@ -31,18 +32,19 @@ import ly.warp.sdk.utils.WarpUtils; | ... | @@ -31,18 +32,19 @@ import ly.warp.sdk.utils.WarpUtils; |
| 31 | */ | 32 | */ |
| 32 | public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponViewHolder> { | 33 | public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponViewHolder> { |
| 33 | 34 | ||
| 34 | - private final List<CouponItem> allCouponItems; | 35 | + private final ArrayList<Coupon> allCouponItems; |
| 35 | - private List<CouponItem> filteredCouponItems; | 36 | + private ArrayList<Coupon> filteredCouponItems; |
| 36 | private final Context context; | 37 | private final Context context; |
| 37 | private OnCouponClickListener listener; | 38 | private OnCouponClickListener listener; |
| 38 | - private String currentFilter = null; | 39 | + private int currentFilter = 0; |
| 39 | 40 | ||
| 40 | /** | 41 | /** |
| 41 | * Interface for handling coupon item clicks | 42 | * Interface for handling coupon item clicks |
| 42 | */ | 43 | */ |
| 43 | public interface OnCouponClickListener { | 44 | public interface OnCouponClickListener { |
| 44 | - void onCouponClick(CouponItem couponItem, int position); | 45 | + void onCouponClick(Coupon couponItem, int position); |
| 45 | - void onFavoriteClick(CouponItem couponItem, int position); | 46 | + |
| 47 | + void onFavoriteClick(Coupon couponItem, int position); | ||
| 46 | } | 48 | } |
| 47 | 49 | ||
| 48 | /** | 50 | /** |
| ... | @@ -51,10 +53,10 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView | ... | @@ -51,10 +53,10 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView |
| 51 | * @param context The context | 53 | * @param context The context |
| 52 | * @param couponItems List of coupon items to display | 54 | * @param couponItems List of coupon items to display |
| 53 | */ | 55 | */ |
| 54 | - public CouponAdapter(Context context, List<CouponItem> couponItems) { | 56 | + public CouponAdapter(Context context, ArrayList<Coupon> couponItems) { |
| 55 | this.context = context; | 57 | this.context = context; |
| 56 | this.allCouponItems = couponItems; | 58 | this.allCouponItems = couponItems; |
| 57 | - this.filteredCouponItems = new ArrayList<>(couponItems); | 59 | + this.filteredCouponItems = couponItems; |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | /** | 62 | /** |
| ... | @@ -71,22 +73,20 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView | ... | @@ -71,22 +73,20 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView |
| 71 | * | 73 | * |
| 72 | * @param status The status to filter by (active, favorite, redeemed) or null for all | 74 | * @param status The status to filter by (active, favorite, redeemed) or null for all |
| 73 | */ | 75 | */ |
| 74 | - public void filterByStatus(String status) { | 76 | + public void filterByStatus(int status) { |
| 75 | currentFilter = status; | 77 | currentFilter = status; |
| 76 | filteredCouponItems.clear(); | 78 | filteredCouponItems.clear(); |
| 77 | - | 79 | + |
| 78 | - if (status == null) { | 80 | + if (status == 0) { |
| 79 | - // Show all coupons | ||
| 80 | filteredCouponItems.addAll(allCouponItems); | 81 | filteredCouponItems.addAll(allCouponItems); |
| 81 | } else { | 82 | } else { |
| 82 | - // Filter by status | 83 | + for (Coupon coupon : allCouponItems) { |
| 83 | - for (CouponItem coupon : allCouponItems) { | 84 | + if (status == coupon.getStatus()) { |
| 84 | - if (status.equals(coupon.getStatus())) { | ||
| 85 | filteredCouponItems.add(coupon); | 85 | filteredCouponItems.add(coupon); |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | - | 89 | + |
| 90 | notifyDataSetChanged(); | 90 | notifyDataSetChanged(); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| ... | @@ -99,7 +99,7 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView | ... | @@ -99,7 +99,7 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView |
| 99 | 99 | ||
| 100 | @Override | 100 | @Override |
| 101 | public void onBindViewHolder(@NonNull CouponViewHolder holder, int position) { | 101 | public void onBindViewHolder(@NonNull CouponViewHolder holder, int position) { |
| 102 | - CouponItem couponItem = filteredCouponItems.get(position); | 102 | + Coupon couponItem = filteredCouponItems.get(position); |
| 103 | holder.bind(couponItem, position); | 103 | holder.bind(couponItem, position); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| ... | @@ -149,102 +149,71 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView | ... | @@ -149,102 +149,71 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView |
| 149 | }); | 149 | }); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | - void bind(CouponItem couponItem, int position) { | 152 | + void bind(Coupon couponItem, int position) { |
| 153 | - // Set coupon data to views | 153 | + tvTitle.setText(!TextUtils.isEmpty(couponItem.getCouponsetDetails().getName()) ? couponItem.getCouponsetDetails().getName() : ""); |
| 154 | - tvTitle.setText(couponItem.getTitle()); | 154 | + tvDescription.setText(!TextUtils.isEmpty(couponItem.getCouponsetDetails().getShort_description()) ? couponItem.getCouponsetDetails().getShort_description() : ""); |
| 155 | - tvDescription.setText(couponItem.getDescription()); | 155 | + tvPrice.setText(!TextUtils.isEmpty(couponItem.getDiscount()) ? couponItem.getDiscount() : ""); |
| 156 | - tvPrice.setText(couponItem.getValue()); | 156 | + if (couponItem.getCouponsetDetails().getEndDate() != null && !couponItem.getCouponsetDetails().getEndDate().isEmpty()) { |
| 157 | - tvValidity.setText(formatValidityDate(couponItem.getEndDate())); | 157 | + tvValidity.setText(formatValidityDate(couponItem.getCouponsetDetails().getEndDate())); |
| 158 | - | 158 | + tvValidity.setVisibility(View.VISIBLE); |
| 159 | - // Set heart icon based on favorite status | ||
| 160 | - if (couponItem.isFavorite()) { | ||
| 161 | - // Use pressed/filled heart for Favorites | ||
| 162 | - ivFavorite.setImageResource(R.drawable.demo_heart_pressed); | ||
| 163 | } else { | 159 | } else { |
| 164 | - // Use default/empty heart for other statuses | 160 | + tvValidity.setVisibility(View.GONE); |
| 165 | - ivFavorite.setImageResource(R.drawable.demo_heart); | ||
| 166 | } | 161 | } |
| 167 | 162 | ||
| 168 | - // Load images from resources | 163 | + // Set heart icon based on favorite status |
| 169 | - loadOfferImage(couponItem.getImageUrl()); | 164 | +// if (couponItem.isFavorite()) { |
| 170 | - loadLogoImage(couponItem.getLogoUrl()); | 165 | +// // Use pressed/filled heart for Favorites |
| 166 | +// ivFavorite.setImageResource(R.drawable.demo_heart_pressed); | ||
| 167 | +// } else { | ||
| 168 | +// // Use default/empty heart for other statuses | ||
| 169 | +// ivFavorite.setImageResource(R.drawable.demo_heart); | ||
| 170 | +// } | ||
| 171 | + | ||
| 172 | + loadCouponImage(couponItem.getCouponsetDetails().getImg_preview()); | ||
| 173 | + loadMerchantLogo(couponItem.getMerchantDetails().getImgPreview()); | ||
| 171 | } | 174 | } |
| 172 | 175 | ||
| 173 | - /** | ||
| 174 | - * Format the end date to "έως dd-MM" format | ||
| 175 | - * | ||
| 176 | - * @param endDate The end date in "dd/MM/yyyy" format | ||
| 177 | - * @return Formatted date string | ||
| 178 | - */ | ||
| 179 | private String formatValidityDate(String endDate) { | 176 | private String formatValidityDate(String endDate) { |
| 180 | try { | 177 | try { |
| 181 | - SimpleDateFormat inputFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault()); | 178 | + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); |
| 182 | Date date = inputFormat.parse(endDate); | 179 | Date date = inputFormat.parse(endDate); |
| 183 | - | ||
| 184 | SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); | 180 | SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); |
| 185 | return "έως " + outputFormat.format(date); | 181 | return "έως " + outputFormat.format(date); |
| 186 | - | ||
| 187 | } catch (ParseException e) { | 182 | } catch (ParseException e) { |
| 188 | - // Fallback to original if parsing fails | 183 | + try { |
| 189 | - return endDate; | 184 | + SimpleDateFormat inputFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()); |
| 185 | + Date date = inputFormat2.parse(endDate); | ||
| 186 | + SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); | ||
| 187 | + return "έως " + outputFormat.format(date); | ||
| 188 | + } catch (ParseException e2) { | ||
| 189 | + return endDate; | ||
| 190 | + } | ||
| 190 | } | 191 | } |
| 191 | } | 192 | } |
| 192 | 193 | ||
| 193 | - /** | 194 | + private void loadCouponImage(String imageUrl) { |
| 194 | - * Load offer image with rounded top corners using Glide | 195 | + if (imageUrl != null && !imageUrl.isEmpty()) { |
| 195 | - * | 196 | + int radiusInPixels = (int) TypedValue.applyDimension( |
| 196 | - * @param imageName The image resource name | 197 | + TypedValue.COMPLEX_UNIT_DIP, 9, |
| 197 | - */ | 198 | + context.getResources().getDisplayMetrics()); |
| 198 | - private void loadOfferImage(String imageName) { | 199 | + |
| 199 | - try { | 200 | + Glide.with(context) |
| 200 | - // Remove file extension if present | 201 | + .load(imageUrl) |
| 201 | - if (imageName.contains(".")) { | 202 | + .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 202 | - imageName = imageName.substring(0, imageName.lastIndexOf('.')); | 203 | + .transform(new CenterCrop(), new TopRoundedCornersTransformation(radiusInPixels)) |
| 203 | - } | 204 | + .into(ivOfferImage); |
| 204 | - | ||
| 205 | - // Get resource ID by name | ||
| 206 | - int resourceId = context.getResources().getIdentifier( | ||
| 207 | - imageName, "drawable", context.getPackageName()); | ||
| 208 | - | ||
| 209 | - if (resourceId != 0) { | ||
| 210 | - // Convert 9dp to pixels | ||
| 211 | - int radiusInPixels = (int) TypedValue.applyDimension( | ||
| 212 | - TypedValue.COMPLEX_UNIT_DIP, 9, | ||
| 213 | - context.getResources().getDisplayMetrics()); | ||
| 214 | - | ||
| 215 | - // Load with Glide and apply transformations | ||
| 216 | - Glide.with(context) | ||
| 217 | - .load(resourceId) | ||
| 218 | - .transform(new CenterCrop(), new TopRoundedCornersTransformation(radiusInPixels)) | ||
| 219 | - .into(ivOfferImage); | ||
| 220 | - } | ||
| 221 | - } catch (Exception e) { | ||
| 222 | - e.printStackTrace(); | ||
| 223 | } | 205 | } |
| 224 | } | 206 | } |
| 225 | - | 207 | + |
| 226 | - /** | 208 | + private void loadMerchantLogo(String logoUrl) { |
| 227 | - * Load logo image without transformations | 209 | + if (logoUrl != null && !logoUrl.isEmpty()) { |
| 228 | - * | 210 | + ivLogo.setVisibility(View.VISIBLE); |
| 229 | - * @param imageName The image resource name | 211 | + Glide.with(context) |
| 230 | - */ | 212 | + .load(logoUrl) |
| 231 | - private void loadLogoImage(String imageName) { | 213 | + .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 232 | - try { | 214 | + .into(ivLogo); |
| 233 | - // Remove file extension if present | 215 | + } else { |
| 234 | - if (imageName.contains(".")) { | 216 | + ivLogo.setVisibility(View.GONE); |
| 235 | - imageName = imageName.substring(0, imageName.lastIndexOf('.')); | ||
| 236 | - } | ||
| 237 | - | ||
| 238 | - // Get resource ID by name | ||
| 239 | - int resourceId = context.getResources().getIdentifier( | ||
| 240 | - imageName, "drawable", context.getPackageName()); | ||
| 241 | - | ||
| 242 | - if (resourceId != 0) { | ||
| 243 | - // Load logo normally without transformations | ||
| 244 | - ivLogo.setImageResource(resourceId); | ||
| 245 | - } | ||
| 246 | - } catch (Exception e) { | ||
| 247 | - e.printStackTrace(); | ||
| 248 | } | 217 | } |
| 249 | } | 218 | } |
| 250 | } | 219 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -5,7 +5,6 @@ import java.util.concurrent.TimeUnit; | ... | @@ -5,7 +5,6 @@ import java.util.concurrent.TimeUnit; |
| 5 | import ly.warp.sdk.Warply; | 5 | import ly.warp.sdk.Warply; |
| 6 | import ly.warp.sdk.utils.WarplyProperty; | 6 | import ly.warp.sdk.utils.WarplyProperty; |
| 7 | import okhttp3.OkHttpClient; | 7 | import okhttp3.OkHttpClient; |
| 8 | -import okhttp3.logging.HttpLoggingInterceptor; | ||
| 9 | import retrofit2.Retrofit; | 8 | import retrofit2.Retrofit; |
| 10 | import retrofit2.converter.gson.GsonConverterFactory; | 9 | import retrofit2.converter.gson.GsonConverterFactory; |
| 11 | 10 | ||
| ... | @@ -49,11 +48,11 @@ public class ApiClient { | ... | @@ -49,11 +48,11 @@ public class ApiClient { |
| 49 | 48 | ||
| 50 | private static OkHttpClient getClient() { | 49 | private static OkHttpClient getClient() { |
| 51 | /* Logs Enabled */ | 50 | /* Logs Enabled */ |
| 52 | - HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); | 51 | +// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); |
| 53 | - interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); | 52 | +// interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); |
| 54 | 53 | ||
| 55 | return new OkHttpClient.Builder() | 54 | return new OkHttpClient.Builder() |
| 56 | - .addInterceptor(interceptor) // Logs Enabled | 55 | +// .addInterceptor(interceptor) // Logs Enabled |
| 57 | .connectTimeout(30, TimeUnit.SECONDS) | 56 | .connectTimeout(30, TimeUnit.SECONDS) |
| 58 | .writeTimeout(30, TimeUnit.SECONDS) | 57 | .writeTimeout(30, TimeUnit.SECONDS) |
| 59 | .readTimeout(30, TimeUnit.SECONDS) | 58 | .readTimeout(30, TimeUnit.SECONDS) | ... | ... |
| ... | @@ -971,7 +971,7 @@ public class WarpUtils { | ... | @@ -971,7 +971,7 @@ public class WarpUtils { |
| 971 | if (topView != null) { | 971 | if (topView != null) { |
| 972 | topView.setPadding( | 972 | topView.setPadding( |
| 973 | topView.getPaddingLeft(), | 973 | topView.getPaddingLeft(), |
| 974 | - insets.top, | 974 | + topView.getPaddingTop() + insets.top, |
| 975 | topView.getPaddingRight(), | 975 | topView.getPaddingRight(), |
| 976 | topView.getPaddingBottom() | 976 | topView.getPaddingBottom() |
| 977 | ); | 977 | ); |
| ... | @@ -983,7 +983,7 @@ public class WarpUtils { | ... | @@ -983,7 +983,7 @@ public class WarpUtils { |
| 983 | bottomView.getPaddingLeft(), | 983 | bottomView.getPaddingLeft(), |
| 984 | bottomView.getPaddingTop(), | 984 | bottomView.getPaddingTop(), |
| 985 | bottomView.getPaddingRight(), | 985 | bottomView.getPaddingRight(), |
| 986 | - insets.bottom | 986 | + bottomView.getPaddingBottom() + insets.bottom |
| 987 | ); | 987 | ); |
| 988 | } | 988 | } |
| 989 | 989 | ... | ... |
| ... | @@ -35,6 +35,7 @@ import ly.warp.sdk.Warply; | ... | @@ -35,6 +35,7 @@ import ly.warp.sdk.Warply; |
| 35 | import ly.warp.sdk.db.WarplyDBHelper; | 35 | import ly.warp.sdk.db.WarplyDBHelper; |
| 36 | import ly.warp.sdk.io.models.BannerItem; | 36 | import ly.warp.sdk.io.models.BannerItem; |
| 37 | import ly.warp.sdk.io.models.Campaign; | 37 | import ly.warp.sdk.io.models.Campaign; |
| 38 | +import ly.warp.sdk.io.models.Coupon; | ||
| 38 | import ly.warp.sdk.io.models.CouponList; | 39 | import ly.warp.sdk.io.models.CouponList; |
| 39 | import ly.warp.sdk.io.models.Couponset; | 40 | import ly.warp.sdk.io.models.Couponset; |
| 40 | import ly.warp.sdk.utils.managers.WarplyManager; | 41 | import ly.warp.sdk.utils.managers.WarplyManager; |
| ... | @@ -54,6 +55,7 @@ public class WarplyManagerHelper { | ... | @@ -54,6 +55,7 @@ public class WarplyManagerHelper { |
| 54 | // =========================================================== | 55 | // =========================================================== |
| 55 | 56 | ||
| 56 | private static CouponList mCouponRedeemedList = new CouponList(); | 57 | private static CouponList mCouponRedeemedList = new CouponList(); |
| 58 | + private static ArrayList<Coupon> mCouponList = new ArrayList<Coupon>(); | ||
| 57 | private static ArrayList<Campaign> mCampaignListAll = new ArrayList<Campaign>(); | 59 | private static ArrayList<Campaign> mCampaignListAll = new ArrayList<Campaign>(); |
| 58 | private static ArrayList<BannerItem> mBannerListAll = new ArrayList<BannerItem>(); | 60 | private static ArrayList<BannerItem> mBannerListAll = new ArrayList<BannerItem>(); |
| 59 | private static LinkedHashMap<String, ArrayList<Couponset>> mCouponsetCategorizedMap = new LinkedHashMap<>(); | 61 | private static LinkedHashMap<String, ArrayList<Couponset>> mCouponsetCategorizedMap = new LinkedHashMap<>(); |
| ... | @@ -98,6 +100,15 @@ public class WarplyManagerHelper { | ... | @@ -98,6 +100,15 @@ public class WarplyManagerHelper { |
| 98 | mCouponRedeemedList.addAll(couponRedeemedList); | 100 | mCouponRedeemedList.addAll(couponRedeemedList); |
| 99 | } | 101 | } |
| 100 | 102 | ||
| 103 | + public static void setCoupons(ArrayList<Coupon> couponList) { | ||
| 104 | + mCouponList.clear(); | ||
| 105 | + mCouponList.addAll(couponList); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public static ArrayList<Coupon> getCoupons() { | ||
| 109 | + return mCouponList; | ||
| 110 | + } | ||
| 111 | + | ||
| 101 | public static String constructCampaignUrl(Campaign item) { | 112 | public static String constructCampaignUrl(Campaign item) { |
| 102 | WarplyManager.getSingleCampaign(item.getSessionUUID()); | 113 | WarplyManager.getSingleCampaign(item.getSessionUUID()); |
| 103 | String url = item.getIndexUrl(); | 114 | String url = item.getIndexUrl(); | ... | ... |
| ... | @@ -49,7 +49,6 @@ public class WarplyProperty { | ... | @@ -49,7 +49,6 @@ public class WarplyProperty { |
| 49 | public static final String KEY_LOGIN_TYPE = "LoginType"; | 49 | public static final String KEY_LOGIN_TYPE = "LoginType"; |
| 50 | public static final String KEY_DL_URL_SCHEME = "DL_URL_SCHEME"; | 50 | public static final String KEY_DL_URL_SCHEME = "DL_URL_SCHEME"; |
| 51 | public static final String KEY_BASE_URL = "BaseURL"; | 51 | public static final String KEY_BASE_URL = "BaseURL"; |
| 52 | - public static final String KEY_VERIFY_URL = "VerifyURL"; | ||
| 53 | 52 | ||
| 54 | // =========================================================== | 53 | // =========================================================== |
| 55 | // Methods | 54 | // Methods |
| ... | @@ -204,10 +203,6 @@ public class WarplyProperty { | ... | @@ -204,10 +203,6 @@ public class WarplyProperty { |
| 204 | return getWarplyProperty(context, KEY_BASE_URL); | 203 | return getWarplyProperty(context, KEY_BASE_URL); |
| 205 | } | 204 | } |
| 206 | 205 | ||
| 207 | - public static String getVerifyUrl(Context context) { | ||
| 208 | - return getWarplyProperty(context, KEY_VERIFY_URL); | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | public static boolean isSendPackages(Context context) { | 206 | public static boolean isSendPackages(Context context) { |
| 212 | return Boolean.parseBoolean(getWarplyProperty(context, KEY_SEND_PACKAGES)); | 207 | return Boolean.parseBoolean(getWarplyProperty(context, KEY_SEND_PACKAGES)); |
| 213 | } | 208 | } | ... | ... |
| ... | @@ -61,7 +61,6 @@ import ly.warp.sdk.io.models.BannerItem; | ... | @@ -61,7 +61,6 @@ import ly.warp.sdk.io.models.BannerItem; |
| 61 | import ly.warp.sdk.io.models.Campaign; | 61 | import ly.warp.sdk.io.models.Campaign; |
| 62 | import ly.warp.sdk.io.models.Content; | 62 | import ly.warp.sdk.io.models.Content; |
| 63 | import ly.warp.sdk.io.models.Coupon; | 63 | import ly.warp.sdk.io.models.Coupon; |
| 64 | -import ly.warp.sdk.io.models.CouponList; | ||
| 65 | import ly.warp.sdk.io.models.Couponset; | 64 | import ly.warp.sdk.io.models.Couponset; |
| 66 | import ly.warp.sdk.io.models.Merchant; | 65 | import ly.warp.sdk.io.models.Merchant; |
| 67 | import ly.warp.sdk.io.models.User; | 66 | import ly.warp.sdk.io.models.User; |
| ... | @@ -371,7 +370,7 @@ public class WarplyManager { | ... | @@ -371,7 +370,7 @@ public class WarplyManager { |
| 371 | }); | 370 | }); |
| 372 | } | 371 | } |
| 373 | 372 | ||
| 374 | - public static void getUserCouponsWithCouponsets(final CallbackReceiver<CouponList> receiver) { | 373 | + public static void getCoupons(final CallbackReceiver<ArrayList<Coupon>> receiver) { |
| 375 | WarpUtils.log("************* WARPLY User Coupons Request ********************"); | 374 | WarpUtils.log("************* WARPLY User Coupons Request ********************"); |
| 376 | WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active"); | 375 | WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active"); |
| 377 | WarpUtils.log("**************************************************"); | 376 | WarpUtils.log("**************************************************"); |
| ... | @@ -379,18 +378,18 @@ public class WarplyManager { | ... | @@ -379,18 +378,18 @@ public class WarplyManager { |
| 379 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | 378 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); |
| 380 | ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1)); | 379 | ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1)); |
| 381 | 380 | ||
| 382 | - SettableFuture<CouponList> futureUniversal = SettableFuture.create(); | 381 | + SettableFuture<ArrayList<Coupon>> futureUniversal = SettableFuture.create(); |
| 383 | - ListenableFuture<CouponList> futureCoupons = getCouponsUniversalRetro(service, 0, futureUniversal); | 382 | + ListenableFuture<ArrayList<Coupon>> futureCoupons = getCouponsUniversalRetro(service, 0, futureUniversal); |
| 384 | 383 | ||
| 385 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCoupons); | 384 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCoupons); |
| 386 | - ListenableFuture<CouponList> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { | 385 | + ListenableFuture<ArrayList<Coupon>> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { |
| 387 | - CouponList resultCoupons = (CouponList) results.get(0); | 386 | + ArrayList<Coupon> resultCoupons = (ArrayList<Coupon>) results.get(0); |
| 388 | return executorService.submit(() -> resultCoupons); | 387 | return executorService.submit(() -> resultCoupons); |
| 389 | }, executorService); | 388 | }, executorService); |
| 390 | 389 | ||
| 391 | - Futures.addCallback(mergedResultFuture, new FutureCallback<CouponList>() { | 390 | + Futures.addCallback(mergedResultFuture, new FutureCallback<ArrayList<Coupon>>() { |
| 392 | @Override | 391 | @Override |
| 393 | - public void onSuccess(CouponList mergedResult) { | 392 | + public void onSuccess(ArrayList<Coupon> mergedResult) { |
| 394 | executorService.shutdownNow(); | 393 | executorService.shutdownNow(); |
| 395 | new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mergedResult)); | 394 | new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mergedResult)); |
| 396 | } | 395 | } |
| ... | @@ -463,7 +462,7 @@ public class WarplyManager { | ... | @@ -463,7 +462,7 @@ public class WarplyManager { |
| 463 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | 462 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); |
| 464 | ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2)); | 463 | ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2)); |
| 465 | 464 | ||
| 466 | - ListenableFuture<ArrayList<Couponset>> futureCouponsets = getCouponsetsRetro(service); | 465 | + ListenableFuture<ArrayList<Couponset>> futureCouponsets = getCouponsetsRetro(service, 0); |
| 467 | ListenableFuture<ArrayList<Merchant>> futureMerchants = getMerchantsRetro(service); | 466 | ListenableFuture<ArrayList<Merchant>> futureMerchants = getMerchantsRetro(service); |
| 468 | 467 | ||
| 469 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCouponsets, futureMerchants); | 468 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCouponsets, futureMerchants); |
| ... | @@ -488,7 +487,7 @@ public class WarplyManager { | ... | @@ -488,7 +487,7 @@ public class WarplyManager { |
| 488 | }, executorService); | 487 | }, executorService); |
| 489 | } | 488 | } |
| 490 | 489 | ||
| 491 | - private static ListenableFuture<ArrayList<Couponset>> getCouponsetsRetro(ApiService service/*, Callback<ResponseBody> callback*/) { | 490 | + private static ListenableFuture<ArrayList<Couponset>> getCouponsetsRetro(ApiService service, int tries/*, Callback<ResponseBody> callback*/) { |
| 492 | SettableFuture<ArrayList<Couponset>> future = SettableFuture.create(); | 491 | SettableFuture<ArrayList<Couponset>> future = SettableFuture.create(); |
| 493 | 492 | ||
| 494 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); | 493 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); |
| ... | @@ -550,6 +549,31 @@ public class WarplyManager { | ... | @@ -550,6 +549,31 @@ public class WarplyManager { |
| 550 | } else { | 549 | } else { |
| 551 | future.set(new ArrayList<Couponset>()); | 550 | future.set(new ArrayList<Couponset>()); |
| 552 | } | 551 | } |
| 552 | + } else if (response.code() == 401) { | ||
| 553 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
| 554 | + @Override | ||
| 555 | + public void onSuccess(JSONObject result) { | ||
| 556 | + int status = result.optInt("status", 2); | ||
| 557 | + if (status == 1) | ||
| 558 | + getCouponsetsRetro(service, tries); | ||
| 559 | + else { | ||
| 560 | + if (tries < MAX_RETRIES) { | ||
| 561 | + getCouponsetsRetro(service, (tries + 1)); | ||
| 562 | + } else { | ||
| 563 | + future.setException(new Throwable()); | ||
| 564 | + } | ||
| 565 | + } | ||
| 566 | + } | ||
| 567 | + | ||
| 568 | + @Override | ||
| 569 | + public void onFailure(int errorCode) { | ||
| 570 | + if (tries < MAX_RETRIES) { | ||
| 571 | + getCouponsetsRetro(service, (tries + 1)); | ||
| 572 | + } else { | ||
| 573 | + future.setException(new Throwable()); | ||
| 574 | + } | ||
| 575 | + } | ||
| 576 | + }); | ||
| 553 | } else if (String.valueOf(response.code()).startsWith("5")) { | 577 | } else if (String.valueOf(response.code()).startsWith("5")) { |
| 554 | future.set(new ArrayList<Couponset>()); | 578 | future.set(new ArrayList<Couponset>()); |
| 555 | } else { | 579 | } else { |
| ... | @@ -985,7 +1009,7 @@ public class WarplyManager { | ... | @@ -985,7 +1009,7 @@ public class WarplyManager { |
| 985 | return future; | 1009 | return future; |
| 986 | } | 1010 | } |
| 987 | 1011 | ||
| 988 | - private static ListenableFuture<CouponList> getCouponsUniversalRetro(ApiService service, int tries, SettableFuture<CouponList> future) { | 1012 | + private static ListenableFuture<ArrayList<Coupon>> getCouponsUniversalRetro(ApiService service, int tries, SettableFuture<ArrayList<Coupon>> future) { |
| 989 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); | 1013 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); |
| 990 | String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); | 1014 | String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); |
| 991 | String webId = WarpUtils.getWebId(Warply.getWarplyContext()); | 1015 | String webId = WarpUtils.getWebId(Warply.getWarplyContext()); |
| ... | @@ -995,17 +1019,8 @@ public class WarplyManager { | ... | @@ -995,17 +1019,8 @@ public class WarplyManager { |
| 995 | jsonParams.put("action", "user_coupons"); | 1019 | jsonParams.put("action", "user_coupons"); |
| 996 | JSONArray jArr = new JSONArray(); | 1020 | JSONArray jArr = new JSONArray(); |
| 997 | jArr.put("merchant"); | 1021 | jArr.put("merchant"); |
| 998 | - jArr.put("redemption"); | ||
| 999 | jsonParams.put("details", jArr); | 1022 | jsonParams.put("details", jArr); |
| 1000 | - jsonParams.put("language", WarpUtils.getApplicationLocale(Warply.getWarplyContext())); | 1023 | +// jsonParams.put("language", WarpUtils.getApplicationLocale(Warply.getWarplyContext())); |
| 1001 | -// JSONObject jPagination= new JSONObject(); | ||
| 1002 | -// try { | ||
| 1003 | -// jPagination.putOpt("page",1); | ||
| 1004 | -// jPagination.putOpt("per_page", 10); | ||
| 1005 | -// } catch (JSONException e) { | ||
| 1006 | -// throw new RuntimeException(e); | ||
| 1007 | -// } | ||
| 1008 | -// jsonParams.put("pagination", jPagination); | ||
| 1009 | 1024 | ||
| 1010 | jsonParamsCoupons.put("coupon", jsonParams); | 1025 | jsonParamsCoupons.put("coupon", jsonParams); |
| 1011 | RequestBody couponsRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCoupons)).toString()); | 1026 | RequestBody couponsRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCoupons)).toString()); |
| ... | @@ -1032,32 +1047,29 @@ public class WarplyManager { | ... | @@ -1032,32 +1047,29 @@ public class WarplyManager { |
| 1032 | } | 1047 | } |
| 1033 | 1048 | ||
| 1034 | if (jCouponsBody != null) { | 1049 | if (jCouponsBody != null) { |
| 1035 | - CouponList mCouponRedeemedList = new CouponList(); | 1050 | + ArrayList<Coupon> mCouponList = new ArrayList<Coupon>(); |
| 1036 | 1051 | ||
| 1037 | final ExecutorService executorCoupons = Executors.newFixedThreadPool(1); | 1052 | final ExecutorService executorCoupons = Executors.newFixedThreadPool(1); |
| 1038 | JSONArray finalJCouponsBody = jCouponsBody; | 1053 | JSONArray finalJCouponsBody = jCouponsBody; |
| 1039 | executorCoupons.submit(() -> { | 1054 | executorCoupons.submit(() -> { |
| 1040 | for (int i = 0; i < finalJCouponsBody.length(); ++i) { | 1055 | for (int i = 0; i < finalJCouponsBody.length(); ++i) { |
| 1041 | Coupon tempCoupon = new Coupon(finalJCouponsBody.optJSONObject(i), true); | 1056 | Coupon tempCoupon = new Coupon(finalJCouponsBody.optJSONObject(i), true); |
| 1042 | - | 1057 | + mCouponList.add(tempCoupon); |
| 1043 | - if (tempCoupon.getStatus() == 0) { | ||
| 1044 | - mCouponRedeemedList.add(tempCoupon); | ||
| 1045 | - } | ||
| 1046 | } | 1058 | } |
| 1047 | 1059 | ||
| 1048 | - WarplyManagerHelper.setCouponRedeemedList(mCouponRedeemedList); | 1060 | + WarplyManagerHelper.setCoupons(mCouponList); |
| 1049 | 1061 | ||
| 1050 | - Collections.sort(mCouponRedeemedList, (coupon1, coupon2) -> coupon1.getExpirationDate().compareTo(coupon2.getExpirationDate())); | 1062 | + Collections.sort(mCouponList, (coupon1, coupon2) -> coupon1.getExpirationDate().compareTo(coupon2.getExpirationDate())); |
| 1051 | 1063 | ||
| 1052 | executorCoupons.shutdownNow(); | 1064 | executorCoupons.shutdownNow(); |
| 1053 | 1065 | ||
| 1054 | - future.set(mCouponRedeemedList); | 1066 | + future.set(mCouponList); |
| 1055 | }); | 1067 | }); |
| 1056 | } else { | 1068 | } else { |
| 1057 | - future.set(new CouponList()); | 1069 | + future.set(new ArrayList<Coupon>()); |
| 1058 | } | 1070 | } |
| 1059 | } else { | 1071 | } else { |
| 1060 | - future.set(new CouponList()); | 1072 | + future.set(new ArrayList<Coupon>()); |
| 1061 | } | 1073 | } |
| 1062 | } else if (response.code() == 401) { | 1074 | } else if (response.code() == 401) { |
| 1063 | refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | 1075 | refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { |
| ... | @@ -1071,7 +1083,7 @@ public class WarplyManager { | ... | @@ -1071,7 +1083,7 @@ public class WarplyManager { |
| 1071 | if (tries < MAX_RETRIES) { | 1083 | if (tries < MAX_RETRIES) { |
| 1072 | getCouponsUniversalRetro(service, (tries + 1), future); | 1084 | getCouponsUniversalRetro(service, (tries + 1), future); |
| 1073 | } else { | 1085 | } else { |
| 1074 | -// future.set(new CouponList()); | 1086 | +// future.set(new ArrayList<Coupon>()); |
| 1075 | future.setException(new Throwable()); | 1087 | future.setException(new Throwable()); |
| 1076 | } | 1088 | } |
| 1077 | } | 1089 | } |
| ... | @@ -1083,20 +1095,20 @@ public class WarplyManager { | ... | @@ -1083,20 +1095,20 @@ public class WarplyManager { |
| 1083 | if (tries < MAX_RETRIES) { | 1095 | if (tries < MAX_RETRIES) { |
| 1084 | getCouponsUniversalRetro(service, (tries + 1), future); | 1096 | getCouponsUniversalRetro(service, (tries + 1), future); |
| 1085 | } else { | 1097 | } else { |
| 1086 | -// future.set(new CouponList()); | 1098 | +// future.set(new ArrayList<Coupon>()); |
| 1087 | future.setException(new Throwable()); | 1099 | future.setException(new Throwable()); |
| 1088 | } | 1100 | } |
| 1089 | } | 1101 | } |
| 1090 | }); | 1102 | }); |
| 1091 | } else { | 1103 | } else { |
| 1092 | -// future.set(new CouponList()); | 1104 | +// future.set(new ArrayList<Coupon>()); |
| 1093 | future.setException(new Throwable()); | 1105 | future.setException(new Throwable()); |
| 1094 | } | 1106 | } |
| 1095 | } | 1107 | } |
| 1096 | 1108 | ||
| 1097 | @Override | 1109 | @Override |
| 1098 | public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) { | 1110 | public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) { |
| 1099 | -// future.set(new CouponList()); | 1111 | +// future.set(new ArrayList<Coupon>()); |
| 1100 | future.setException(new Throwable()); | 1112 | future.setException(new Throwable()); |
| 1101 | } | 1113 | } |
| 1102 | }); | 1114 | }); | ... | ... |
17.6 KB
| ... | @@ -25,7 +25,8 @@ | ... | @@ -25,7 +25,8 @@ |
| 25 | android:background="@color/custom_grey_light" | 25 | android:background="@color/custom_grey_light" |
| 26 | android:orientation="horizontal" | 26 | android:orientation="horizontal" |
| 27 | android:paddingHorizontal="16dp" | 27 | android:paddingHorizontal="16dp" |
| 28 | - android:paddingVertical="16dp"> | 28 | + android:paddingBottom="16dp" |
| 29 | + android:paddingTop="16dp"> | ||
| 29 | 30 | ||
| 30 | <LinearLayout | 31 | <LinearLayout |
| 31 | android:layout_width="0dp" | 32 | android:layout_width="0dp" |
| ... | @@ -104,12 +105,19 @@ | ... | @@ -104,12 +105,19 @@ |
| 104 | </RelativeLayout> | 105 | </RelativeLayout> |
| 105 | </androidx.constraintlayout.widget.ConstraintLayout> | 106 | </androidx.constraintlayout.widget.ConstraintLayout> |
| 106 | 107 | ||
| 108 | + <LinearLayout | ||
| 109 | + android:id="@+id/ll_sections_container" | ||
| 110 | + android:layout_width="match_parent" | ||
| 111 | + android:layout_height="wrap_content" | ||
| 112 | + android:layout_marginBottom="48dp" | ||
| 113 | + android:paddingBottom="16dp" | ||
| 114 | + android:orientation="vertical" /> | ||
| 115 | + | ||
| 107 | <RelativeLayout | 116 | <RelativeLayout |
| 108 | android:id="@+id/rl_sections_loading" | 117 | android:id="@+id/rl_sections_loading" |
| 109 | android:layout_width="match_parent" | 118 | android:layout_width="match_parent" |
| 110 | android:layout_height="wrap_content" | 119 | android:layout_height="wrap_content" |
| 111 | android:background="@android:color/transparent" | 120 | android:background="@android:color/transparent" |
| 112 | - android:layout_marginTop="48dp" | ||
| 113 | android:translationZ="100dp" | 121 | android:translationZ="100dp" |
| 114 | android:visibility="gone" | 122 | android:visibility="gone" |
| 115 | tools:visibility="visible"> | 123 | tools:visibility="visible"> |
| ... | @@ -122,13 +130,6 @@ | ... | @@ -122,13 +130,6 @@ |
| 122 | android:indeterminateTint="@color/custom_light_blue" | 130 | android:indeterminateTint="@color/custom_light_blue" |
| 123 | android:indeterminateTintMode="src_atop" /> | 131 | android:indeterminateTintMode="src_atop" /> |
| 124 | </RelativeLayout> | 132 | </RelativeLayout> |
| 125 | - | ||
| 126 | - <LinearLayout | ||
| 127 | - android:id="@+id/ll_sections_container" | ||
| 128 | - android:layout_width="match_parent" | ||
| 129 | - android:layout_height="wrap_content" | ||
| 130 | - android:layout_marginBottom="48dp" | ||
| 131 | - android:orientation="vertical" /> | ||
| 132 | </LinearLayout> | 133 | </LinearLayout> |
| 133 | </androidx.core.widget.NestedScrollView> | 134 | </androidx.core.widget.NestedScrollView> |
| 134 | </RelativeLayout> | 135 | </RelativeLayout> | ... | ... |
| ... | @@ -223,6 +223,25 @@ | ... | @@ -223,6 +223,25 @@ |
| 223 | android:clipToPadding="false" | 223 | android:clipToPadding="false" |
| 224 | android:nestedScrollingEnabled="false" | 224 | android:nestedScrollingEnabled="false" |
| 225 | android:paddingHorizontal="16dp" /> | 225 | android:paddingHorizontal="16dp" /> |
| 226 | + | ||
| 227 | + <RelativeLayout | ||
| 228 | + android:id="@+id/pb_loading" | ||
| 229 | + android:layout_width="match_parent" | ||
| 230 | + android:layout_height="wrap_content" | ||
| 231 | + android:background="@android:color/transparent" | ||
| 232 | + android:layout_marginTop="64dp" | ||
| 233 | + android:translationZ="100dp" | ||
| 234 | + android:visibility="gone" | ||
| 235 | + tools:visibility="visible"> | ||
| 236 | + | ||
| 237 | + <ProgressBar | ||
| 238 | + android:layout_width="40dp" | ||
| 239 | + android:layout_height="40dp" | ||
| 240 | + android:layout_centerInParent="true" | ||
| 241 | + android:indeterminate="true" | ||
| 242 | + android:indeterminateTint="@color/custom_light_blue" | ||
| 243 | + android:indeterminateTintMode="src_atop" /> | ||
| 244 | + </RelativeLayout> | ||
| 226 | </RelativeLayout> | 245 | </RelativeLayout> |
| 227 | </LinearLayout> | 246 | </LinearLayout> |
| 228 | </androidx.core.widget.NestedScrollView> | 247 | </androidx.core.widget.NestedScrollView> | ... | ... |
| ... | @@ -59,8 +59,7 @@ | ... | @@ -59,8 +59,7 @@ |
| 59 | android:id="@+id/iv_coupon_image" | 59 | android:id="@+id/iv_coupon_image" |
| 60 | android:layout_width="match_parent" | 60 | android:layout_width="match_parent" |
| 61 | android:layout_height="match_parent" | 61 | android:layout_height="match_parent" |
| 62 | - android:scaleType="fitXY" | 62 | + android:scaleType="centerCrop" |
| 63 | - tools:src="@drawable/demo_home_banner1" | ||
| 64 | app:layout_constraintBottom_toBottomOf="parent" | 63 | app:layout_constraintBottom_toBottomOf="parent" |
| 65 | app:layout_constraintEnd_toEndOf="parent" | 64 | app:layout_constraintEnd_toEndOf="parent" |
| 66 | app:layout_constraintStart_toStartOf="parent" | 65 | app:layout_constraintStart_toStartOf="parent" |
| ... | @@ -280,7 +279,7 @@ | ... | @@ -280,7 +279,7 @@ |
| 280 | android:layout_width="0dp" | 279 | android:layout_width="0dp" |
| 281 | android:layout_height="wrap_content" | 280 | android:layout_height="wrap_content" |
| 282 | android:layout_weight="1" | 281 | android:layout_weight="1" |
| 283 | - android:text="@string/demo_qr_code" | 282 | + android:text="@string/demo_barcode_code" |
| 284 | android:textColor="@color/custom_black2" | 283 | android:textColor="@color/custom_black2" |
| 285 | android:textSize="15sp" /> | 284 | android:textSize="15sp" /> |
| 286 | 285 | ||
| ... | @@ -303,10 +302,10 @@ | ... | @@ -303,10 +302,10 @@ |
| 303 | <ImageView | 302 | <ImageView |
| 304 | android:id="@+id/iv_qr_code" | 303 | android:id="@+id/iv_qr_code" |
| 305 | android:layout_width="200dp" | 304 | android:layout_width="200dp" |
| 306 | - android:layout_height="200dp" | 305 | + android:layout_height="120dp" |
| 307 | android:layout_marginVertical="16dp" | 306 | android:layout_marginVertical="16dp" |
| 308 | android:scaleType="fitCenter" | 307 | android:scaleType="fitCenter" |
| 309 | - android:src="@drawable/demo_qr" /> | 308 | + android:src="@drawable/demo_barcode" /> |
| 310 | </LinearLayout> | 309 | </LinearLayout> |
| 311 | </LinearLayout> | 310 | </LinearLayout> |
| 312 | 311 | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -87,7 +87,6 @@ | ... | @@ -87,7 +87,6 @@ |
| 87 | app:layout_constraintBottom_toBottomOf="parent" | 87 | app:layout_constraintBottom_toBottomOf="parent" |
| 88 | tools:text="έως 30-09" /> | 88 | tools:text="έως 30-09" /> |
| 89 | 89 | ||
| 90 | - <!-- Brand Logo --> | ||
| 91 | <ImageView | 90 | <ImageView |
| 92 | android:id="@+id/iv_logo" | 91 | android:id="@+id/iv_logo" |
| 93 | android:layout_width="80dp" | 92 | android:layout_width="80dp" | ... | ... |
| ... | @@ -16,7 +16,8 @@ | ... | @@ -16,7 +16,8 @@ |
| 16 | android:layout_height="wrap_content" | 16 | android:layout_height="wrap_content" |
| 17 | android:background="@android:color/white" | 17 | android:background="@android:color/white" |
| 18 | android:paddingHorizontal="16dp" | 18 | android:paddingHorizontal="16dp" |
| 19 | - android:paddingVertical="16dp"> | 19 | + android:paddingBottom="16dp" |
| 20 | + android:paddingTop="16dp"> | ||
| 20 | 21 | ||
| 21 | <ImageView | 22 | <ImageView |
| 22 | android:id="@+id/user_img" | 23 | android:id="@+id/user_img" | ... | ... |
| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | <string name="demo_valid_until">Η προσφορά ισχύει έως %1$s</string> | 15 | <string name="demo_valid_until">Η προσφορά ισχύει έως %1$s</string> |
| 16 | <string name="demo_coupon_code">Κωδικός Κουπονιού</string> | 16 | <string name="demo_coupon_code">Κωδικός Κουπονιού</string> |
| 17 | <string name="demo_qr_code">QR Κουπονιού</string> | 17 | <string name="demo_qr_code">QR Κουπονιού</string> |
| 18 | + <string name="demo_barcode_code">Barcode Κουπονιού</string> | ||
| 18 | <string name="demo_terms">Όροι Χρήσης</string> | 19 | <string name="demo_terms">Όροι Χρήσης</string> |
| 19 | <string name="demo_copy_success">Ο κωδικός αντιγράφηκε στο πρόχειρο</string> | 20 | <string name="demo_copy_success">Ο κωδικός αντιγράφηκε στο πρόχειρο</string> |
| 20 | <string name="demo_lorem_ipsum">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</string> | 21 | <string name="demo_lorem_ipsum">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</string> | ... | ... |
-
Please register or login to post a comment