Showing
13 changed files
with
438 additions
and
14 deletions
| ... | @@ -21,7 +21,6 @@ import ly.warp.sdk.io.models.Couponset; | ... | @@ -21,7 +21,6 @@ import ly.warp.sdk.io.models.Couponset; |
| 21 | import ly.warp.sdk.utils.WarpUtils; | 21 | import ly.warp.sdk.utils.WarpUtils; |
| 22 | import ly.warp.sdk.utils.WarplyManagerHelper; | 22 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| 23 | import ly.warp.sdk.views.GridSpaceItemDecoration; | 23 | import ly.warp.sdk.views.GridSpaceItemDecoration; |
| 24 | -import ly.warp.sdk.views.VerticalSpaceItemDecoration; | ||
| 25 | 24 | ||
| 26 | public class CouponsetsActivity extends Activity implements View.OnClickListener { | 25 | public class CouponsetsActivity extends Activity implements View.OnClickListener { |
| 27 | // =========================================================== | 26 | // =========================================================== | ... | ... |
| ... | @@ -14,6 +14,7 @@ import android.widget.ImageView; | ... | @@ -14,6 +14,7 @@ import android.widget.ImageView; |
| 14 | import android.widget.LinearLayout; | 14 | import android.widget.LinearLayout; |
| 15 | import android.widget.RelativeLayout; | 15 | import android.widget.RelativeLayout; |
| 16 | import android.widget.TextView; | 16 | import android.widget.TextView; |
| 17 | +import android.widget.Toast; | ||
| 17 | 18 | ||
| 18 | import androidx.appcompat.content.res.AppCompatResources; | 19 | import androidx.appcompat.content.res.AppCompatResources; |
| 19 | import androidx.constraintlayout.widget.ConstraintLayout; | 20 | import androidx.constraintlayout.widget.ConstraintLayout; |
| ... | @@ -36,6 +37,7 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver; | ... | @@ -36,6 +37,7 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 36 | import ly.warp.sdk.io.models.CarouselItem; | 37 | import ly.warp.sdk.io.models.CarouselItem; |
| 37 | import ly.warp.sdk.io.models.Coupon; | 38 | import ly.warp.sdk.io.models.Coupon; |
| 38 | import ly.warp.sdk.io.models.Couponset; | 39 | import ly.warp.sdk.io.models.Couponset; |
| 40 | +import ly.warp.sdk.io.models.Filter; | ||
| 39 | import ly.warp.sdk.io.models.User; | 41 | import ly.warp.sdk.io.models.User; |
| 40 | import ly.warp.sdk.utils.WarpUtils; | 42 | import ly.warp.sdk.utils.WarpUtils; |
| 41 | import ly.warp.sdk.utils.WarplyManagerHelper; | 43 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| ... | @@ -55,7 +57,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -55,7 +57,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 55 | // =========================================================== | 57 | // =========================================================== |
| 56 | 58 | ||
| 57 | private RelativeLayout mPbLoading; | 59 | private RelativeLayout mPbLoading; |
| 58 | - private TextView mTvHeaderTitle, mTvMyCouponsTitle, mTvMyCouponsValue; | 60 | + private TextView mTvHeaderTitle, mTvMyCouponsTitle, mTvMyCouponsValue, mTvSearchTitle; |
| 59 | private LinearLayout mLlUserTags, mLlMyCoupons; | 61 | private LinearLayout mLlUserTags, mLlMyCoupons; |
| 60 | /* View Pager */ | 62 | /* View Pager */ |
| 61 | // private ViewPager2 mBannerViewPager; | 63 | // private ViewPager2 mBannerViewPager; |
| ... | @@ -92,6 +94,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -92,6 +94,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 92 | WarplyManager.getCoupons(mCouponsCallback); | 94 | WarplyManager.getCoupons(mCouponsCallback); |
| 93 | WarplyManager.getCarousel(mCarouselCallback); | 95 | WarplyManager.getCarousel(mCarouselCallback); |
| 94 | WarplyManager.getCouponsets(null, null, mCouponsetsCallback); | 96 | WarplyManager.getCouponsets(null, null, mCouponsetsCallback); |
| 97 | + WarplyManager.getFilters(mFiltersCallback); | ||
| 95 | } | 98 | } |
| 96 | 99 | ||
| 97 | @Override | 100 | @Override |
| ... | @@ -145,9 +148,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -145,9 +148,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 145 | mTvHeaderTitle = findViewById(R.id.tv_header_title); | 148 | mTvHeaderTitle = findViewById(R.id.tv_header_title); |
| 146 | mLlUserTags = findViewById(R.id.ll_user_tags); | 149 | mLlUserTags = findViewById(R.id.ll_user_tags); |
| 147 | mRvBannerViewPager = findViewById(R.id.banner_viewpager); | 150 | mRvBannerViewPager = findViewById(R.id.banner_viewpager); |
| 151 | + mTvSearchTitle = findViewById(R.id.tv_search_title); | ||
| 148 | 152 | ||
| 149 | WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, mTvHeaderTitle, mTvMyCouponsValue); | 153 | WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, mTvHeaderTitle, mTvMyCouponsValue); |
| 150 | - WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, mTvMyCouponsTitle); | 154 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, mTvMyCouponsTitle, mTvSearchTitle); |
| 151 | } | 155 | } |
| 152 | 156 | ||
| 153 | private void setUpUser() { | 157 | private void setUpUser() { |
| ... | @@ -403,6 +407,8 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -403,6 +407,8 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 403 | private final CallbackReceiver<ArrayList<Coupon>> mCouponsCallback = new CallbackReceiver<ArrayList<Coupon>>() { | 407 | private final CallbackReceiver<ArrayList<Coupon>> mCouponsCallback = new CallbackReceiver<ArrayList<Coupon>>() { |
| 404 | @Override | 408 | @Override |
| 405 | public void onSuccess(ArrayList<Coupon> result) { | 409 | public void onSuccess(ArrayList<Coupon> result) { |
| 410 | + Toast.makeText(HomeActivity.this, "COUPONS SUCCESS", Toast.LENGTH_SHORT).show(); | ||
| 411 | + | ||
| 406 | int activeCoupons = 0; | 412 | int activeCoupons = 0; |
| 407 | for (Coupon coupon : result) { | 413 | for (Coupon coupon : result) { |
| 408 | if (coupon.getStatus() == 1) activeCoupons++; | 414 | if (coupon.getStatus() == 1) activeCoupons++; |
| ... | @@ -412,7 +418,19 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -412,7 +418,19 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 412 | 418 | ||
| 413 | @Override | 419 | @Override |
| 414 | public void onFailure(int errorCode) { | 420 | public void onFailure(int errorCode) { |
| 421 | + Toast.makeText(HomeActivity.this, "COUPONS ERROR", Toast.LENGTH_SHORT).show(); | ||
| 422 | + } | ||
| 423 | + }; | ||
| 424 | + | ||
| 425 | + private final CallbackReceiver<Filter> mFiltersCallback = new CallbackReceiver<Filter>() { | ||
| 426 | + @Override | ||
| 427 | + public void onSuccess(Filter result) { | ||
| 428 | + Toast.makeText(HomeActivity.this, "FILTERS SUCCESS", Toast.LENGTH_SHORT).show(); | ||
| 429 | + } | ||
| 415 | 430 | ||
| 431 | + @Override | ||
| 432 | + public void onFailure(int errorCode) { | ||
| 433 | + Toast.makeText(HomeActivity.this, "FILTERS ERROR", Toast.LENGTH_SHORT).show(); | ||
| 416 | } | 434 | } |
| 417 | }; | 435 | }; |
| 418 | } | 436 | } | ... | ... |
| ... | @@ -8,6 +8,7 @@ import org.json.JSONObject; | ... | @@ -8,6 +8,7 @@ import org.json.JSONObject; |
| 8 | import java.io.Serializable; | 8 | import java.io.Serializable; |
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | + * Created by Panagiotis Triantafyllou on 17-Mar-26. | ||
| 11 | * Model representing a single item from the carousel (get_carousel) API response. | 12 | * Model representing a single item from the carousel (get_carousel) API response. |
| 12 | */ | 13 | */ |
| 13 | public class CarouselItem implements Parcelable, Serializable { | 14 | public class CarouselItem implements Parcelable, Serializable { | ... | ... |
| 1 | +package ly.warp.sdk.io.models; | ||
| 2 | + | ||
| 3 | +import android.os.Parcel; | ||
| 4 | +import android.os.Parcelable; | ||
| 5 | + | ||
| 6 | +import org.json.JSONArray; | ||
| 7 | +import org.json.JSONException; | ||
| 8 | +import org.json.JSONObject; | ||
| 9 | + | ||
| 10 | +import java.io.Serializable; | ||
| 11 | +import java.util.ArrayList; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by Panagiotis Triantafyllou on 17-Mar-26. | ||
| 15 | + * Model representing the response from the getFilters API. | ||
| 16 | + * Contains offer categories (with children) and regions. | ||
| 17 | + */ | ||
| 18 | +public class Filter implements Parcelable, Serializable { | ||
| 19 | + | ||
| 20 | + private static final long serialVersionUID = 3312345678901234567L; | ||
| 21 | + | ||
| 22 | + private static final String OFFER_CATEGORIES = "offer_categories"; | ||
| 23 | + private static final String REGIONS = "regions"; | ||
| 24 | + | ||
| 25 | + private ArrayList<OfferCategory> offerCategories; | ||
| 26 | + private ArrayList<String> regions; | ||
| 27 | + | ||
| 28 | + // ================================================================================ | ||
| 29 | + // Inner class | ||
| 30 | + // ================================================================================ | ||
| 31 | + | ||
| 32 | + public static class OfferCategory { | ||
| 33 | + | ||
| 34 | + private static final String ADMIN_NAME = "admin_name"; | ||
| 35 | + private static final String NAME = "name"; | ||
| 36 | + private static final String IMAGE = "image"; | ||
| 37 | + private static final String UUID = "uuid"; | ||
| 38 | + private static final String PARENT = "parent"; | ||
| 39 | + private static final String CHILDREN = "children"; | ||
| 40 | + | ||
| 41 | + private String adminName; | ||
| 42 | + private String name; | ||
| 43 | + private String image; | ||
| 44 | + private String uuid; | ||
| 45 | + private String parent; | ||
| 46 | + private ArrayList<OfferCategory> children; | ||
| 47 | + | ||
| 48 | + private static String optNullableString(JSONObject json, String key) { | ||
| 49 | + return json.isNull(key) ? null : json.optString(key); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public OfferCategory() { | ||
| 53 | + this.adminName = null; | ||
| 54 | + this.name = null; | ||
| 55 | + this.image = null; | ||
| 56 | + this.uuid = null; | ||
| 57 | + this.parent = null; | ||
| 58 | + this.children = new ArrayList<>(); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public OfferCategory(JSONObject json) { | ||
| 62 | + if (json != null) { | ||
| 63 | + this.adminName = optNullableString(json, ADMIN_NAME); | ||
| 64 | + this.name = optNullableString(json, NAME); | ||
| 65 | + this.image = optNullableString(json, IMAGE); | ||
| 66 | + this.uuid = optNullableString(json, UUID); | ||
| 67 | + this.parent = optNullableString(json, PARENT); | ||
| 68 | + this.children = new ArrayList<>(); | ||
| 69 | + JSONArray childrenArray = json.optJSONArray(CHILDREN); | ||
| 70 | + if (childrenArray != null) { | ||
| 71 | + for (int i = 0; i < childrenArray.length(); i++) { | ||
| 72 | + JSONObject childJson = childrenArray.optJSONObject(i); | ||
| 73 | + if (childJson != null) { | ||
| 74 | + this.children.add(new OfferCategory(childJson)); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public JSONObject toJSONObject() { | ||
| 82 | + JSONObject jObj = new JSONObject(); | ||
| 83 | + try { | ||
| 84 | + jObj.put(ADMIN_NAME, this.adminName != null ? this.adminName : JSONObject.NULL); | ||
| 85 | + jObj.put(NAME, this.name != null ? this.name : JSONObject.NULL); | ||
| 86 | + jObj.put(IMAGE, this.image != null ? this.image : JSONObject.NULL); | ||
| 87 | + jObj.put(UUID, this.uuid != null ? this.uuid : JSONObject.NULL); | ||
| 88 | + jObj.put(PARENT, this.parent != null ? this.parent : JSONObject.NULL); | ||
| 89 | + JSONArray childrenArray = new JSONArray(); | ||
| 90 | + if (this.children != null) { | ||
| 91 | + for (OfferCategory child : this.children) { | ||
| 92 | + childrenArray.put(child.toJSONObject()); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + jObj.put(CHILDREN, childrenArray); | ||
| 96 | + } catch (JSONException e) { | ||
| 97 | + e.printStackTrace(); | ||
| 98 | + } | ||
| 99 | + return jObj; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + // Getters | ||
| 103 | + public String getAdminName() { return adminName; } | ||
| 104 | + public String getName() { return name; } | ||
| 105 | + public String getImage() { return image; } | ||
| 106 | + public String getUuid() { return uuid; } | ||
| 107 | + public String getParent() { return parent; } | ||
| 108 | + public ArrayList<OfferCategory> getChildren() { return children; } | ||
| 109 | + | ||
| 110 | + // Setters | ||
| 111 | + public void setAdminName(String adminName) { this.adminName = adminName; } | ||
| 112 | + public void setName(String name) { this.name = name; } | ||
| 113 | + public void setImage(String image) { this.image = image; } | ||
| 114 | + public void setUuid(String uuid) { this.uuid = uuid; } | ||
| 115 | + public void setParent(String parent) { this.parent = parent; } | ||
| 116 | + public void setChildren(ArrayList<OfferCategory> children) { this.children = children; } | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + // ================================================================================ | ||
| 120 | + // Constructors | ||
| 121 | + // ================================================================================ | ||
| 122 | + | ||
| 123 | + public Filter() { | ||
| 124 | + this.offerCategories = new ArrayList<>(); | ||
| 125 | + this.regions = new ArrayList<>(); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public Filter(JSONObject json) { | ||
| 129 | + this.offerCategories = new ArrayList<>(); | ||
| 130 | + this.regions = new ArrayList<>(); | ||
| 131 | + | ||
| 132 | + if (json != null) { | ||
| 133 | + JSONArray categoriesArray = json.optJSONArray(OFFER_CATEGORIES); | ||
| 134 | + if (categoriesArray != null) { | ||
| 135 | + for (int i = 0; i < categoriesArray.length(); i++) { | ||
| 136 | + JSONObject categoryJson = categoriesArray.optJSONObject(i); | ||
| 137 | + if (categoryJson != null) { | ||
| 138 | + this.offerCategories.add(new OfferCategory(categoryJson)); | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + JSONArray regionsArray = json.optJSONArray(REGIONS); | ||
| 144 | + if (regionsArray != null) { | ||
| 145 | + for (int i = 0; i < regionsArray.length(); i++) { | ||
| 146 | + String region = regionsArray.optString(i, null); | ||
| 147 | + if (region != null && !region.isEmpty()) { | ||
| 148 | + this.regions.add(region); | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + public Filter(Parcel source) { | ||
| 156 | + this.regions = new ArrayList<>(); | ||
| 157 | + source.readStringList(this.regions); | ||
| 158 | + | ||
| 159 | + this.offerCategories = new ArrayList<>(); | ||
| 160 | + try { | ||
| 161 | + String categoriesStr = source.readString(); | ||
| 162 | + if (categoriesStr != null) { | ||
| 163 | + JSONArray categoriesArray = new JSONArray(categoriesStr); | ||
| 164 | + for (int i = 0; i < categoriesArray.length(); i++) { | ||
| 165 | + JSONObject categoryJson = categoriesArray.optJSONObject(i); | ||
| 166 | + if (categoryJson != null) { | ||
| 167 | + this.offerCategories.add(new OfferCategory(categoryJson)); | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + } catch (JSONException e) { | ||
| 172 | + e.printStackTrace(); | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + @Override | ||
| 177 | + public void writeToParcel(Parcel dest, int flags) { | ||
| 178 | + dest.writeStringList(this.regions); | ||
| 179 | + JSONArray categoriesArray = new JSONArray(); | ||
| 180 | + if (this.offerCategories != null) { | ||
| 181 | + for (OfferCategory category : this.offerCategories) { | ||
| 182 | + categoriesArray.put(category.toJSONObject()); | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + dest.writeString(categoriesArray.toString()); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + @Override | ||
| 189 | + public int describeContents() { | ||
| 190 | + return 0; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + public static final Creator<Filter> CREATOR = new Creator<Filter>() { | ||
| 194 | + @Override | ||
| 195 | + public Filter createFromParcel(Parcel source) { | ||
| 196 | + return new Filter(source); | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + @Override | ||
| 200 | + public Filter[] newArray(int size) { | ||
| 201 | + return new Filter[size]; | ||
| 202 | + } | ||
| 203 | + }; | ||
| 204 | + | ||
| 205 | + // ================================================================================ | ||
| 206 | + // Getters | ||
| 207 | + // ================================================================================ | ||
| 208 | + | ||
| 209 | + public ArrayList<OfferCategory> getOfferCategories() { | ||
| 210 | + return offerCategories; | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + public ArrayList<String> getRegions() { | ||
| 214 | + return regions; | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + // ================================================================================ | ||
| 218 | + // Setters | ||
| 219 | + // ================================================================================ | ||
| 220 | + | ||
| 221 | + public void setOfferCategories(ArrayList<OfferCategory> offerCategories) { | ||
| 222 | + this.offerCategories = offerCategories; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + public void setRegions(ArrayList<String> regions) { | ||
| 226 | + this.regions = regions; | ||
| 227 | + } | ||
| 228 | +} |
| ... | @@ -180,6 +180,18 @@ public interface ApiService { | ... | @@ -180,6 +180,18 @@ public interface ApiService { |
| 180 | @Header(WarpConstants.HEADER_WEB_ID) String webId, | 180 | @Header(WarpConstants.HEADER_WEB_ID) String webId, |
| 181 | @Header(WarpConstants.HEADER_SIGNATURE) String signature); | 181 | @Header(WarpConstants.HEADER_SIGNATURE) String signature); |
| 182 | 182 | ||
| 183 | + @Headers("Content-Type: application/json") | ||
| 184 | + @POST("/oauth/{appUuid}/context") | ||
| 185 | + Call<ResponseBody> getFilters(@Path("appUuid") String appUuid, | ||
| 186 | + @Body RequestBody request, | ||
| 187 | + @Header(WarpConstants.HEADER_DATE) String timeStamp, | ||
| 188 | + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, | ||
| 189 | + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | ||
| 190 | + @Header(WarpConstants.HEADER_CHANNEL) String channel, | ||
| 191 | + @Header(WarpConstants.HEADER_WEB_ID) String webId, | ||
| 192 | + @Header(WarpConstants.HEADER_SIGNATURE) String signature, | ||
| 193 | + @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer); | ||
| 194 | + | ||
| 183 | // =========================================================== | 195 | // =========================================================== |
| 184 | // Getter & Setter | 196 | // Getter & Setter |
| 185 | // =========================================================== | 197 | // =========================================================== | ... | ... |
| ... | @@ -39,6 +39,7 @@ import ly.warp.sdk.io.models.CarouselItem; | ... | @@ -39,6 +39,7 @@ import ly.warp.sdk.io.models.CarouselItem; |
| 39 | import ly.warp.sdk.io.models.Coupon; | 39 | import ly.warp.sdk.io.models.Coupon; |
| 40 | import ly.warp.sdk.io.models.CouponList; | 40 | import ly.warp.sdk.io.models.CouponList; |
| 41 | import ly.warp.sdk.io.models.Couponset; | 41 | import ly.warp.sdk.io.models.Couponset; |
| 42 | +import ly.warp.sdk.io.models.Filter; | ||
| 42 | import ly.warp.sdk.io.models.User; | 43 | import ly.warp.sdk.io.models.User; |
| 43 | import ly.warp.sdk.utils.managers.WarplyManager; | 44 | import ly.warp.sdk.utils.managers.WarplyManager; |
| 44 | 45 | ||
| ... | @@ -63,6 +64,7 @@ public class WarplyManagerHelper { | ... | @@ -63,6 +64,7 @@ public class WarplyManagerHelper { |
| 63 | private static ArrayList<CarouselItem> mCarouselListAll = new ArrayList<>(); | 64 | private static ArrayList<CarouselItem> mCarouselListAll = new ArrayList<>(); |
| 64 | private static LinkedHashMap<String, ArrayList<Couponset>> mCouponsetCategorizedMap = new LinkedHashMap<>(); | 65 | private static LinkedHashMap<String, ArrayList<Couponset>> mCouponsetCategorizedMap = new LinkedHashMap<>(); |
| 65 | private static User mUser = null; | 66 | private static User mUser = null; |
| 67 | + private static Filter mFilter = null; | ||
| 66 | 68 | ||
| 67 | // =========================================================== | 69 | // =========================================================== |
| 68 | // Methods for/from SuperClass/Interfaces | 70 | // Methods for/from SuperClass/Interfaces |
| ... | @@ -80,6 +82,14 @@ public class WarplyManagerHelper { | ... | @@ -80,6 +82,14 @@ public class WarplyManagerHelper { |
| 80 | return mUser; | 82 | return mUser; |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 85 | + public static void setFilter(Filter filter) { | ||
| 86 | + mFilter = filter; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public static Filter getFilter() { | ||
| 90 | + return mFilter; | ||
| 91 | + } | ||
| 92 | + | ||
| 83 | public static void setCampaignList(ArrayList<Campaign> campaignList) { | 93 | public static void setCampaignList(ArrayList<Campaign> campaignList) { |
| 84 | mCampaignListAll.clear(); | 94 | mCampaignListAll.clear(); |
| 85 | mCampaignListAll.addAll(campaignList); | 95 | mCampaignListAll.addAll(campaignList); | ... | ... |
| ... | @@ -65,6 +65,7 @@ import ly.warp.sdk.io.models.Campaign; | ... | @@ -65,6 +65,7 @@ import ly.warp.sdk.io.models.Campaign; |
| 65 | import ly.warp.sdk.io.models.Content; | 65 | import ly.warp.sdk.io.models.Content; |
| 66 | import ly.warp.sdk.io.models.Coupon; | 66 | import ly.warp.sdk.io.models.Coupon; |
| 67 | import ly.warp.sdk.io.models.Couponset; | 67 | import ly.warp.sdk.io.models.Couponset; |
| 68 | +import ly.warp.sdk.io.models.Filter; | ||
| 68 | import ly.warp.sdk.io.models.Merchant; | 69 | import ly.warp.sdk.io.models.Merchant; |
| 69 | import ly.warp.sdk.io.models.User; | 70 | import ly.warp.sdk.io.models.User; |
| 70 | import ly.warp.sdk.io.request.WarplyRefreshTokenRequest; | 71 | import ly.warp.sdk.io.request.WarplyRefreshTokenRequest; |
| ... | @@ -1425,4 +1426,107 @@ public class WarplyManager { | ... | @@ -1425,4 +1426,107 @@ public class WarplyManager { |
| 1425 | } | 1426 | } |
| 1426 | }); | 1427 | }); |
| 1427 | } | 1428 | } |
| 1429 | + | ||
| 1430 | + public static void getFilters(final CallbackReceiver<Filter> receiver) { | ||
| 1431 | + WarpUtils.log("************* WARPLY Filters Request ********************"); | ||
| 1432 | + WarpUtils.log("[WARP Trace] WARPLY Filters Request is active"); | ||
| 1433 | + WarpUtils.log("**************************************************"); | ||
| 1434 | + | ||
| 1435 | + ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | ||
| 1436 | + ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1)); | ||
| 1437 | + | ||
| 1438 | + ListenableFuture<Filter> futureFilters = getFiltersRetro(service); | ||
| 1439 | + | ||
| 1440 | + ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureFilters); | ||
| 1441 | + ListenableFuture<Filter> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { | ||
| 1442 | + Filter resultFilters = (Filter) results.get(0); | ||
| 1443 | + return executorService.submit(() -> resultFilters); | ||
| 1444 | + }, executorService); | ||
| 1445 | + | ||
| 1446 | + Futures.addCallback(mergedResultFuture, new FutureCallback<Filter>() { | ||
| 1447 | + @Override | ||
| 1448 | + public void onSuccess(Filter mergedResult) { | ||
| 1449 | + executorService.shutdownNow(); | ||
| 1450 | + new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mergedResult)); | ||
| 1451 | + } | ||
| 1452 | + | ||
| 1453 | + @Override | ||
| 1454 | + public void onFailure(Throwable throwable) { | ||
| 1455 | + executorService.shutdownNow(); | ||
| 1456 | + new Handler(Looper.getMainLooper()).post(() -> receiver.onFailure(2)); | ||
| 1457 | + } | ||
| 1458 | + }, executorService); | ||
| 1459 | + } | ||
| 1460 | + | ||
| 1461 | + private static ListenableFuture<Filter> getFiltersRetro(ApiService service/*, Callback<ResponseBody> callback*/) { | ||
| 1462 | + SettableFuture<Filter> future = SettableFuture.create(); | ||
| 1463 | + | ||
| 1464 | + String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); | ||
| 1465 | + String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); | ||
| 1466 | + String webId = WarpUtils.getWebId(Warply.getWarplyContext()); | ||
| 1467 | + | ||
| 1468 | + Map<String, Object> jsonParamsFilters = new ArrayMap<>(); | ||
| 1469 | + Map<String, Object> jsonParams = new ArrayMap<>(); | ||
| 1470 | + jsonParams.put("action", "get_filters"); | ||
| 1471 | + jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext())); | ||
| 1472 | + jsonParamsFilters.put("coupon", jsonParams); | ||
| 1473 | + | ||
| 1474 | + RequestBody filtersRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsFilters)).toString()); | ||
| 1475 | + Call<ResponseBody> filtersCall = service.getFilters( | ||
| 1476 | + WarplyProperty.getAppUuid(Warply.getWarplyContext()), | ||
| 1477 | + filtersRequest, | ||
| 1478 | + timeStamp, | ||
| 1479 | + "android:" + Warply.getWarplyContext().getPackageName(), | ||
| 1480 | + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | ||
| 1481 | + "mobile", | ||
| 1482 | + webId, | ||
| 1483 | + WarpUtils.produceSignature(apiKey + timeStamp), | ||
| 1484 | + "Bearer " + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | ||
| 1485 | + ); | ||
| 1486 | + filtersCall.enqueue(new Callback<ResponseBody>() { | ||
| 1487 | + @Override | ||
| 1488 | + public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { | ||
| 1489 | + if (response.code() == 200 && response.body() != null) { | ||
| 1490 | + JSONObject jobjFiltersResponse = null; | ||
| 1491 | + try { | ||
| 1492 | + jobjFiltersResponse = new JSONObject(response.body().string()); | ||
| 1493 | + } catch (Exception e) { | ||
| 1494 | + e.printStackTrace(); | ||
| 1495 | + } | ||
| 1496 | + if (jobjFiltersResponse != null && jobjFiltersResponse.has("status") && jobjFiltersResponse.optString("status", "2").equals("1")) { | ||
| 1497 | + JSONObject jFiltersBody = null; | ||
| 1498 | + try { | ||
| 1499 | + jFiltersBody = jobjFiltersResponse.optJSONObject("result"); | ||
| 1500 | + } catch (Exception e) { | ||
| 1501 | + e.printStackTrace(); | ||
| 1502 | + } | ||
| 1503 | + | ||
| 1504 | + if (jFiltersBody != null) { | ||
| 1505 | + try { | ||
| 1506 | + Filter filter = new Filter(jFiltersBody); | ||
| 1507 | + WarplyManagerHelper.setFilter(filter); | ||
| 1508 | + future.set(filter); | ||
| 1509 | + } catch (Exception e) { | ||
| 1510 | + future.setException(e); | ||
| 1511 | + } | ||
| 1512 | + } | ||
| 1513 | + } else { | ||
| 1514 | + future.set(new Filter()); | ||
| 1515 | + } | ||
| 1516 | + } else if (String.valueOf(response.code()).startsWith("5")) { | ||
| 1517 | + future.set(new Filter()); | ||
| 1518 | + } else { | ||
| 1519 | +// future.set(new CouponsetsList()); | ||
| 1520 | + future.setException(new Throwable()); | ||
| 1521 | + } | ||
| 1522 | + } | ||
| 1523 | + | ||
| 1524 | + @Override | ||
| 1525 | + public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) { | ||
| 1526 | +// future.set(new CouponsetsList()); | ||
| 1527 | + future.setException(new Throwable()); | ||
| 1528 | + } | ||
| 1529 | + }); | ||
| 1530 | + return future; | ||
| 1531 | + } | ||
| 1428 | } | 1532 | } | ... | ... |
228 Bytes
| ... | @@ -72,7 +72,7 @@ | ... | @@ -72,7 +72,7 @@ |
| 72 | <androidx.recyclerview.widget.RecyclerView | 72 | <androidx.recyclerview.widget.RecyclerView |
| 73 | android:id="@+id/banner_viewpager" | 73 | android:id="@+id/banner_viewpager" |
| 74 | android:layout_width="match_parent" | 74 | android:layout_width="match_parent" |
| 75 | - android:layout_height="wrap_content" | 75 | + android:layout_height="130dp" |
| 76 | android:clipToPadding="false" | 76 | android:clipToPadding="false" |
| 77 | android:orientation="horizontal" | 77 | android:orientation="horizontal" |
| 78 | android:paddingHorizontal="16dp" | 78 | android:paddingHorizontal="16dp" |
| ... | @@ -125,6 +125,55 @@ | ... | @@ -125,6 +125,55 @@ |
| 125 | </RelativeLayout> | 125 | </RelativeLayout> |
| 126 | </androidx.constraintlayout.widget.ConstraintLayout> | 126 | </androidx.constraintlayout.widget.ConstraintLayout> |
| 127 | 127 | ||
| 128 | + <RelativeLayout | ||
| 129 | + android:id="@+id/header_layout2" | ||
| 130 | + android:layout_width="match_parent" | ||
| 131 | + android:layout_height="wrap_content" | ||
| 132 | + android:layout_marginTop="24dp" | ||
| 133 | + android:background="@color/white" | ||
| 134 | + android:gravity="center_vertical" | ||
| 135 | + android:paddingHorizontal="16dp"> | ||
| 136 | + | ||
| 137 | + <LinearLayout | ||
| 138 | + android:id="@+id/ll_search_filter_button" | ||
| 139 | + android:layout_width="wrap_content" | ||
| 140 | + android:layout_height="wrap_content" | ||
| 141 | + android:layout_alignParentStart="true" | ||
| 142 | + android:background="@drawable/shape_rectangle_rounded_grey4" | ||
| 143 | + android:gravity="center" | ||
| 144 | + android:paddingHorizontal="20dp" | ||
| 145 | + android:paddingVertical="12dp"> | ||
| 146 | + | ||
| 147 | + <TextView | ||
| 148 | + android:id="@+id/tv_search_title" | ||
| 149 | + android:layout_width="wrap_content" | ||
| 150 | + android:layout_height="wrap_content" | ||
| 151 | + android:gravity="center" | ||
| 152 | + android:includeFontPadding="false" | ||
| 153 | + android:text="@string/demo_search_title" | ||
| 154 | + android:textColor="@color/custom_black6" | ||
| 155 | + android:textSize="14sp" /> | ||
| 156 | + | ||
| 157 | + <View | ||
| 158 | + android:layout_width="12dp" | ||
| 159 | + android:layout_height="match_parent" /> | ||
| 160 | + | ||
| 161 | + <ImageView | ||
| 162 | + android:layout_width="16dp" | ||
| 163 | + android:layout_height="16dp" | ||
| 164 | + android:src="@drawable/demo_filter" /> | ||
| 165 | + </LinearLayout> | ||
| 166 | + | ||
| 167 | + <ImageView | ||
| 168 | + android:id="@+id/location_icon" | ||
| 169 | + android:layout_width="46dp" | ||
| 170 | + android:layout_height="46dp" | ||
| 171 | + android:layout_alignParentEnd="true" | ||
| 172 | + android:background="@drawable/shape_rectangle_rounded_grey" | ||
| 173 | + android:padding="14dp" | ||
| 174 | + android:src="@drawable/demo_location_black" /> | ||
| 175 | + </RelativeLayout> | ||
| 176 | + | ||
| 128 | <LinearLayout | 177 | <LinearLayout |
| 129 | android:id="@+id/ll_sections_container" | 178 | android:id="@+id/ll_sections_container" |
| 130 | android:layout_width="match_parent" | 179 | android:layout_width="match_parent" |
| ... | @@ -184,9 +233,9 @@ | ... | @@ -184,9 +233,9 @@ |
| 184 | <LinearLayout | 233 | <LinearLayout |
| 185 | android:layout_width="21dp" | 234 | android:layout_width="21dp" |
| 186 | android:layout_height="21dp" | 235 | android:layout_height="21dp" |
| 187 | - android:orientation="horizontal" | 236 | + android:background="@drawable/shape_rounded_transparent_white_border" |
| 188 | android:gravity="center" | 237 | android:gravity="center" |
| 189 | - android:background="@drawable/shape_rounded_transparent_white_border"> | 238 | + android:orientation="horizontal"> |
| 190 | 239 | ||
| 191 | <TextView | 240 | <TextView |
| 192 | android:id="@+id/tv_my_coupons_value" | 241 | android:id="@+id/tv_my_coupons_value" | ... | ... |
| ... | @@ -27,6 +27,7 @@ | ... | @@ -27,6 +27,7 @@ |
| 27 | android:layout_width="match_parent" | 27 | android:layout_width="match_parent" |
| 28 | android:layout_height="match_parent" | 28 | android:layout_height="match_parent" |
| 29 | android:scaleType="centerCrop" | 29 | android:scaleType="centerCrop" |
| 30 | + android:background="@color/custom_skyblue3" | ||
| 30 | app:layout_constraintBottom_toBottomOf="parent" | 31 | app:layout_constraintBottom_toBottomOf="parent" |
| 31 | app:layout_constraintEnd_toEndOf="parent" | 32 | app:layout_constraintEnd_toEndOf="parent" |
| 32 | app:layout_constraintStart_toStartOf="parent" | 33 | app:layout_constraintStart_toStartOf="parent" | ... | ... |
| ... | @@ -27,6 +27,7 @@ | ... | @@ -27,6 +27,7 @@ |
| 27 | android:layout_width="match_parent" | 27 | android:layout_width="match_parent" |
| 28 | android:layout_height="match_parent" | 28 | android:layout_height="match_parent" |
| 29 | android:scaleType="centerCrop" | 29 | android:scaleType="centerCrop" |
| 30 | + android:background="@color/custom_skyblue3" | ||
| 30 | app:layout_constraintBottom_toBottomOf="parent" | 31 | app:layout_constraintBottom_toBottomOf="parent" |
| 31 | app:layout_constraintEnd_toEndOf="parent" | 32 | app:layout_constraintEnd_toEndOf="parent" |
| 32 | app:layout_constraintStart_toStartOf="parent" | 33 | app:layout_constraintStart_toStartOf="parent" | ... | ... |
| ... | @@ -2,7 +2,8 @@ | ... | @@ -2,7 +2,8 @@ |
| 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | xmlns:tools="http://schemas.android.com/tools" | 3 | xmlns:tools="http://schemas.android.com/tools" |
| 4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
| 5 | - android:layout_height="wrap_content"> | 5 | + android:layout_height="wrap_content" |
| 6 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| 6 | 7 | ||
| 7 | <LinearLayout | 8 | <LinearLayout |
| 8 | android:id="@+id/ll_section_header" | 9 | android:id="@+id/ll_section_header" |
| ... | @@ -10,7 +11,7 @@ | ... | @@ -10,7 +11,7 @@ |
| 10 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
| 11 | android:layout_gravity="center" | 12 | android:layout_gravity="center" |
| 12 | android:orientation="horizontal" | 13 | android:orientation="horizontal" |
| 13 | - android:paddingHorizontal="16dp"> | 14 | + android:paddingHorizontal="24dp"> |
| 14 | 15 | ||
| 15 | <TextView | 16 | <TextView |
| 16 | android:id="@+id/tv_section_title" | 17 | android:id="@+id/tv_section_title" |
| ... | @@ -28,7 +29,7 @@ | ... | @@ -28,7 +29,7 @@ |
| 28 | android:layout_height="wrap_content" | 29 | android:layout_height="wrap_content" |
| 29 | android:orientation="horizontal" | 30 | android:orientation="horizontal" |
| 30 | android:gravity="center" | 31 | android:gravity="center" |
| 31 | - android:paddingHorizontal="16dp"> | 32 | + android:paddingStart="16dp"> |
| 32 | 33 | ||
| 33 | <TextView | 34 | <TextView |
| 34 | android:id="@+id/tv_section_all" | 35 | android:id="@+id/tv_section_all" |
| ... | @@ -36,7 +37,7 @@ | ... | @@ -36,7 +37,7 @@ |
| 36 | android:layout_height="wrap_content" | 37 | android:layout_height="wrap_content" |
| 37 | android:text="@string/demo_all" | 38 | android:text="@string/demo_all" |
| 38 | android:includeFontPadding="false" | 39 | android:includeFontPadding="false" |
| 39 | - android:textColor="@color/custom_black3" | 40 | + android:textColor="@color/custom_blue" |
| 40 | android:textSize="15sp" /> | 41 | android:textSize="15sp" /> |
| 41 | 42 | ||
| 42 | <View | 43 | <View |
| ... | @@ -44,10 +45,9 @@ | ... | @@ -44,10 +45,9 @@ |
| 44 | android:layout_height="match_parent" /> | 45 | android:layout_height="match_parent" /> |
| 45 | 46 | ||
| 46 | <ImageView | 47 | <ImageView |
| 47 | - android:layout_width="8dp" | 48 | + android:layout_width="wrap_content" |
| 48 | - android:layout_height="4dp" | 49 | + android:layout_height="wrap_content" |
| 49 | - android:rotation="270" | 50 | + android:src="@drawable/ic_arrow_right_blue"/> |
| 50 | - android:src="@drawable/ic_arrow_down"/> | ||
| 51 | </LinearLayout> | 51 | </LinearLayout> |
| 52 | </LinearLayout> | 52 | </LinearLayout> |
| 53 | 53 | ... | ... |
| ... | @@ -43,4 +43,5 @@ | ... | @@ -43,4 +43,5 @@ |
| 43 | <color name="custom_grey9">#ADB3B8</color> | 43 | <color name="custom_grey9">#ADB3B8</color> |
| 44 | <color name="custom_grey10">#ECEDEF</color> | 44 | <color name="custom_grey10">#ECEDEF</color> |
| 45 | <color name="custom_grey11">#E7E7E7</color> | 45 | <color name="custom_grey11">#E7E7E7</color> |
| 46 | + <color name="custom_blue">#004E6E</color> | ||
| 46 | </resources> | 47 | </resources> | ... | ... |
-
Please register or login to post a comment