deh requests, new models, dynamic couponsets in home activity
Showing
18 changed files
with
2183 additions
and
1453 deletions
| ... | @@ -4,6 +4,7 @@ import android.app.Activity; | ... | @@ -4,6 +4,7 @@ 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.util.TypedValue; | 6 | import android.util.TypedValue; |
| 7 | +import android.view.LayoutInflater; | ||
| 7 | import android.view.View; | 8 | import android.view.View; |
| 8 | import android.widget.ImageView; | 9 | import android.widget.ImageView; |
| 9 | import android.widget.LinearLayout; | 10 | import android.widget.LinearLayout; |
| ... | @@ -19,27 +20,28 @@ import com.bumptech.glide.Glide; | ... | @@ -19,27 +20,28 @@ import com.bumptech.glide.Glide; |
| 19 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | 20 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| 20 | 21 | ||
| 21 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
| 23 | +import java.util.LinkedHashMap; | ||
| 22 | import java.util.List; | 24 | import java.util.List; |
| 25 | +import java.util.Map; | ||
| 23 | 26 | ||
| 24 | import ly.warp.sdk.R; | 27 | import ly.warp.sdk.R; |
| 25 | import ly.warp.sdk.io.adapters.BannerAdapter; | 28 | import ly.warp.sdk.io.adapters.BannerAdapter; |
| 26 | -import ly.warp.sdk.io.adapters.OfferAdapter; | 29 | +import ly.warp.sdk.io.adapters.CouponsetAdapter; |
| 27 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 30 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 28 | import ly.warp.sdk.io.models.BannerItem; | 31 | import ly.warp.sdk.io.models.BannerItem; |
| 29 | import ly.warp.sdk.io.models.Couponset; | 32 | import ly.warp.sdk.io.models.Couponset; |
| 30 | -import ly.warp.sdk.io.models.DummyDataProvider; | ||
| 31 | -import ly.warp.sdk.io.models.OfferCategory; | ||
| 32 | -import ly.warp.sdk.io.models.OfferItem; | ||
| 33 | import ly.warp.sdk.utils.WarpUtils; | 33 | import ly.warp.sdk.utils.WarpUtils; |
| 34 | import ly.warp.sdk.utils.WarplyManagerHelper; | 34 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| 35 | import ly.warp.sdk.utils.managers.WarplyManager; | 35 | import ly.warp.sdk.utils.managers.WarplyManager; |
| 36 | import ly.warp.sdk.views.HorizontalSpaceItemDecoration; | 36 | import ly.warp.sdk.views.HorizontalSpaceItemDecoration; |
| 37 | 37 | ||
| 38 | -public class HomeActivity extends Activity implements View.OnClickListener, OfferAdapter.OnOfferClickListener { | 38 | +public class HomeActivity extends Activity implements View.OnClickListener, CouponsetAdapter.OnCouponsetClickListener { |
| 39 | // =========================================================== | 39 | // =========================================================== |
| 40 | // Constants | 40 | // Constants |
| 41 | // =========================================================== | 41 | // =========================================================== |
| 42 | 42 | ||
| 43 | + private static final int MAX_ITEMS_PER_SECTION = 5; | ||
| 44 | + | ||
| 43 | // =========================================================== | 45 | // =========================================================== |
| 44 | // Fields | 46 | // Fields |
| 45 | // =========================================================== | 47 | // =========================================================== |
| ... | @@ -50,44 +52,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -50,44 +52,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
| 50 | private BannerAdapter mBannerAdapter; | 52 | private BannerAdapter mBannerAdapter; |
| 51 | private LinearLayout mDotsContainer; | 53 | private LinearLayout mDotsContainer; |
| 52 | private List<ImageView> mDots; | 54 | private List<ImageView> mDots; |
| 53 | - | ||
| 54 | - // Category sections | ||
| 55 | - private TextView mTvCategoryTopOffers; | ||
| 56 | - private RecyclerView mRvTopOffers; | ||
| 57 | - private OfferAdapter mTopOffersAdapter; | ||
| 58 | - | ||
| 59 | - private TextView mTvCategoryFavorites; | ||
| 60 | - private RecyclerView mRvFavorites; | ||
| 61 | - private OfferAdapter mFavoritesAdapter; | ||
| 62 | - | ||
| 63 | - private TextView mTvCategoryViability; | ||
| 64 | - private RecyclerView mRvViability; | ||
| 65 | - private OfferAdapter mViabilityAdapter; | ||
| 66 | - | ||
| 67 | - private TextView mTvCategoryFamily; | ||
| 68 | - private RecyclerView mRvFamily; | ||
| 69 | - private OfferAdapter mFamilyAdapter; | ||
| 70 | - | ||
| 71 | - private TextView mTvCategoryFoodCoffee; | ||
| 72 | - private RecyclerView mRvFoodCoffee; | ||
| 73 | - private OfferAdapter mFoodCoffeeAdapter; | ||
| 74 | - | ||
| 75 | - private TextView mTvCategoryTravelling; | ||
| 76 | - private RecyclerView mRvTravelling; | ||
| 77 | - private OfferAdapter mTravellingAdapter; | ||
| 78 | - | ||
| 79 | - private TextView mTvCategoryKids; | ||
| 80 | - private RecyclerView mRvKids; | ||
| 81 | - private OfferAdapter mKidsAdapter; | ||
| 82 | - | ||
| 83 | - private TextView mTvCategoryPurchases; | ||
| 84 | - private RecyclerView mRvPurchases; | ||
| 85 | - private OfferAdapter mPurchasesAdapter; | ||
| 86 | - | ||
| 87 | - private TextView mTvAllOffers, mTvAllFavorites, mTvAllViability, mTvAllFamily, | ||
| 88 | - mTvAllCoffee, mTvAllTravelling, mTvAllKids, mTvAllPurchases; | ||
| 89 | private ImageView mIvProfile; | 55 | private ImageView mIvProfile; |
| 90 | private ConstraintLayout mViewPager; | 56 | private ConstraintLayout mViewPager; |
| 57 | + private LinearLayout mSectionsContainer; | ||
| 58 | + private RelativeLayout mSectionsLoading; | ||
| 91 | 59 | ||
| 92 | // =========================================================== | 60 | // =========================================================== |
| 93 | // Methods for/from SuperClass/Interfaces | 61 | // Methods for/from SuperClass/Interfaces |
| ... | @@ -105,18 +73,9 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -105,18 +73,9 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
| 105 | null); | 73 | null); |
| 106 | 74 | ||
| 107 | mPbLoading.setVisibility(View.VISIBLE); | 75 | mPbLoading.setVisibility(View.VISIBLE); |
| 76 | + mSectionsLoading.setVisibility(View.VISIBLE); | ||
| 108 | WarplyManager.getCampaigns(mCampaignsCallback); | 77 | WarplyManager.getCampaigns(mCampaignsCallback); |
| 109 | WarplyManager.getCouponsets(mCouponsetsCallback); | 78 | WarplyManager.getCouponsets(mCouponsetsCallback); |
| 110 | - | ||
| 111 | - // Setup all category sections | ||
| 112 | - setupTopOffersSection(); | ||
| 113 | - setupFavoritesSection(); | ||
| 114 | - setupViabilitySection(); | ||
| 115 | - setupFamilySection(); | ||
| 116 | - setupFoodCoffeeSection(); | ||
| 117 | - setupTravellingSection(); | ||
| 118 | - setupKidsSection(); | ||
| 119 | - setupPurchasesSection(); | ||
| 120 | } | 79 | } |
| 121 | 80 | ||
| 122 | @Override | 81 | @Override |
| ... | @@ -133,15 +92,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -133,15 +92,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
| 133 | } | 92 | } |
| 134 | 93 | ||
| 135 | @Override | 94 | @Override |
| 136 | - public void onOfferClick(OfferItem offerItem, int position) { | 95 | + public void onCouponsetClick(Couponset couponset, int position) { |
| 137 | - Intent myIntent = new Intent(HomeActivity.this, SingleCouponActivity.class); | 96 | +// Intent myIntent = new Intent(HomeActivity.this, SingleCouponActivity.class); |
| 138 | - myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, offerItem); | 97 | +// myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, couponset); |
| 139 | - startActivity(myIntent); | 98 | +// startActivity(myIntent); |
| 140 | - } | ||
| 141 | - | ||
| 142 | - @Override | ||
| 143 | - public void onFavoriteClick(OfferItem offerItem, int position) { | ||
| 144 | -// Toast.makeText(this, "Favorite clicked for: " + offerItem.getTitle(), Toast.LENGTH_SHORT).show(); | ||
| 145 | } | 99 | } |
| 146 | 100 | ||
| 147 | // =========================================================== | 101 | // =========================================================== |
| ... | @@ -153,281 +107,66 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -153,281 +107,66 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
| 153 | mPbLoading.setOnTouchListener((v, event) -> true); | 107 | mPbLoading.setOnTouchListener((v, event) -> true); |
| 154 | 108 | ||
| 155 | mViewPager = findViewById(R.id.cl_viewpager); | 109 | mViewPager = findViewById(R.id.cl_viewpager); |
| 110 | + mSectionsContainer = findViewById(R.id.ll_sections_container); | ||
| 111 | + mSectionsLoading = findViewById(R.id.rl_sections_loading); | ||
| 156 | 112 | ||
| 157 | mIvProfile = findViewById(R.id.profile_icon); | 113 | mIvProfile = findViewById(R.id.profile_icon); |
| 158 | mIvProfile.setOnClickListener(this); | 114 | mIvProfile.setOnClickListener(this); |
| 159 | - | ||
| 160 | - // Initialize Top Offers section | ||
| 161 | - mTvCategoryTopOffers = findViewById(R.id.tv_recycler_category1); | ||
| 162 | - mRvTopOffers = findViewById(R.id.rl_recycler1); | ||
| 163 | - mTvAllOffers = findViewById(R.id.tv_recycler_all1); | ||
| 164 | - | ||
| 165 | - // Initialize Favorites section | ||
| 166 | - mTvCategoryFavorites = findViewById(R.id.tv_recycler_category2); | ||
| 167 | - mRvFavorites = findViewById(R.id.rl_recycler2); | ||
| 168 | - mTvAllFavorites = findViewById(R.id.tv_recycler_all2); | ||
| 169 | - | ||
| 170 | - // Initialize Viability section | ||
| 171 | - mTvCategoryViability = findViewById(R.id.tv_recycler_category3); | ||
| 172 | - mRvViability = findViewById(R.id.rl_recycler3); | ||
| 173 | - mTvAllViability = findViewById(R.id.tv_recycler_all3); | ||
| 174 | - | ||
| 175 | - // Initialize Family section | ||
| 176 | - mTvCategoryFamily = findViewById(R.id.tv_recycler_category4); | ||
| 177 | - mRvFamily = findViewById(R.id.rl_recycler4); | ||
| 178 | - mTvAllFamily = findViewById(R.id.tv_recycler_all4); | ||
| 179 | - | ||
| 180 | - // Initialize Food & Coffee section | ||
| 181 | - mTvCategoryFoodCoffee = findViewById(R.id.tv_recycler_category5); | ||
| 182 | - mRvFoodCoffee = findViewById(R.id.rl_recycler5); | ||
| 183 | - mTvAllCoffee = findViewById(R.id.tv_recycler_all5); | ||
| 184 | - | ||
| 185 | - // Initialize Travelling section | ||
| 186 | - mTvCategoryTravelling = findViewById(R.id.tv_recycler_category6); | ||
| 187 | - mRvTravelling = findViewById(R.id.rl_recycler6); | ||
| 188 | - mTvAllTravelling = findViewById(R.id.tv_recycler_all6); | ||
| 189 | - | ||
| 190 | - // Initialize Kids section | ||
| 191 | - mTvCategoryKids = findViewById(R.id.tv_recycler_category7); | ||
| 192 | - mRvKids = findViewById(R.id.rl_recycler7); | ||
| 193 | - mTvAllKids = findViewById(R.id.tv_recycler_all7); | ||
| 194 | - | ||
| 195 | - // Initialize Purchases section | ||
| 196 | - mTvCategoryPurchases = findViewById(R.id.tv_recycler_category8); | ||
| 197 | - mRvPurchases = findViewById(R.id.rl_recycler8); | ||
| 198 | - mTvAllPurchases = findViewById(R.id.tv_recycler_all8); | ||
| 199 | - | ||
| 200 | - WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, mTvCategoryTopOffers, | ||
| 201 | - mTvCategoryFavorites, mTvCategoryViability, mTvCategoryFamily, mTvCategoryFoodCoffee, | ||
| 202 | - mTvCategoryTravelling, mTvCategoryKids, mTvCategoryPurchases); | ||
| 203 | - | ||
| 204 | - WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, mTvAllOffers, mTvAllFavorites, | ||
| 205 | - mTvAllViability, mTvAllFamily, mTvAllCoffee, mTvAllTravelling, mTvAllKids, mTvAllPurchases); | ||
| 206 | } | 115 | } |
| 207 | 116 | ||
| 208 | - /** | 117 | + private void setupCouponsetSections(LinkedHashMap<String, ArrayList<Couponset>> categorizedMap) { |
| 209 | - * Set up the Top Offers section with dummy data | 118 | + mSectionsContainer.removeAllViews(); |
| 210 | - */ | ||
| 211 | - private void setupTopOffersSection() { | ||
| 212 | - // Get Top Offers data | ||
| 213 | - OfferCategory topOffersCategory = DummyDataProvider.getTopOffers(); | ||
| 214 | - | ||
| 215 | - // Set category title with item count | ||
| 216 | - String categoryTitle = topOffersCategory.getName() + " (" + topOffersCategory.getItems().size() + ")"; | ||
| 217 | - mTvCategoryTopOffers.setText(categoryTitle); | ||
| 218 | - | ||
| 219 | - // Set up RecyclerView | ||
| 220 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | ||
| 221 | - mRvTopOffers.setLayoutManager(layoutManager); | ||
| 222 | - mRvTopOffers.setHasFixedSize(true); | ||
| 223 | - | ||
| 224 | - // Add spacing between items | ||
| 225 | - int spacingInPixels = (int) TypedValue.applyDimension( | ||
| 226 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 227 | - mRvTopOffers.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 228 | 119 | ||
| 229 | - // Create and set adapter | 120 | + if (categorizedMap == null || categorizedMap.isEmpty()) { |
| 230 | - mTopOffersAdapter = new OfferAdapter(this, topOffersCategory.getItems()); | 121 | + mSectionsLoading.setVisibility(View.GONE); |
| 231 | - mTopOffersAdapter.setOnOfferClickListener(this); | 122 | + return; |
| 232 | - mRvTopOffers.setAdapter(mTopOffersAdapter); | ||
| 233 | } | 123 | } |
| 234 | 124 | ||
| 235 | - /** | 125 | + LayoutInflater inflater = LayoutInflater.from(this); |
| 236 | - * Set up the Favorites section with dummy data | ||
| 237 | - */ | ||
| 238 | - private void setupFavoritesSection() { | ||
| 239 | - // Get Favorites data | ||
| 240 | - OfferCategory favoritesCategory = DummyDataProvider.getFavorites(); | ||
| 241 | - | ||
| 242 | - // Set category title with item count | ||
| 243 | - String categoryTitle = favoritesCategory.getName() + " (" + favoritesCategory.getItems().size() + ")"; | ||
| 244 | - mTvCategoryFavorites.setText(categoryTitle); | ||
| 245 | - | ||
| 246 | - // Set up RecyclerView | ||
| 247 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | ||
| 248 | - mRvFavorites.setLayoutManager(layoutManager); | ||
| 249 | - mRvFavorites.setHasFixedSize(true); | ||
| 250 | - | ||
| 251 | - // Add spacing between items | ||
| 252 | int spacingInPixels = (int) TypedValue.applyDimension( | 126 | int spacingInPixels = (int) TypedValue.applyDimension( |
| 253 | TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | 127 | TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); |
| 254 | - mRvFavorites.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 255 | - | ||
| 256 | - // Create and set adapter | ||
| 257 | - mFavoritesAdapter = new OfferAdapter(this, favoritesCategory.getItems()); | ||
| 258 | - mFavoritesAdapter.setOnOfferClickListener(this); | ||
| 259 | - mRvFavorites.setAdapter(mFavoritesAdapter); | ||
| 260 | - } | ||
| 261 | - | ||
| 262 | - /** | ||
| 263 | - * Set up the Viability section with dummy data | ||
| 264 | - */ | ||
| 265 | - private void setupViabilitySection() { | ||
| 266 | - // Get Viability data | ||
| 267 | - OfferCategory viabilityCategory = DummyDataProvider.getViability(); | ||
| 268 | - | ||
| 269 | - // Set category title with item count | ||
| 270 | - String categoryTitle = viabilityCategory.getName() + " (" + viabilityCategory.getItems().size() + ")"; | ||
| 271 | - mTvCategoryViability.setText(categoryTitle); | ||
| 272 | 128 | ||
| 273 | - // Set up RecyclerView | 129 | + for (Map.Entry<String, ArrayList<Couponset>> entry : categorizedMap.entrySet()) { |
| 274 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | 130 | + String categoryName = entry.getKey(); |
| 275 | - mRvViability.setLayoutManager(layoutManager); | 131 | + ArrayList<Couponset> couponsets = entry.getValue(); |
| 276 | - mRvViability.setHasFixedSize(true); | ||
| 277 | 132 | ||
| 278 | - // Add spacing between items | 133 | + if (couponsets == null || couponsets.isEmpty()) { |
| 279 | - int spacingInPixels = (int) TypedValue.applyDimension( | 134 | + continue; |
| 280 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 281 | - mRvViability.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 282 | - | ||
| 283 | - // Create and set adapter | ||
| 284 | - mViabilityAdapter = new OfferAdapter(this, viabilityCategory.getItems()); | ||
| 285 | - mViabilityAdapter.setOnOfferClickListener(this); | ||
| 286 | - mRvViability.setAdapter(mViabilityAdapter); | ||
| 287 | } | 135 | } |
| 288 | 136 | ||
| 289 | - /** | 137 | + View sectionView = inflater.inflate(R.layout.item_couponset_section, mSectionsContainer, false); |
| 290 | - * Set up the Family section with dummy data | ||
| 291 | - */ | ||
| 292 | - private void setupFamilySection() { | ||
| 293 | - // Get Family data | ||
| 294 | - OfferCategory familyCategory = DummyDataProvider.getFamily(); | ||
| 295 | - | ||
| 296 | - // Set category title with item count | ||
| 297 | - String categoryTitle = familyCategory.getName() + " (" + familyCategory.getItems().size() + ")"; | ||
| 298 | - mTvCategoryFamily.setText(categoryTitle); | ||
| 299 | 138 | ||
| 300 | - // Set up RecyclerView | 139 | + TextView tvTitle = sectionView.findViewById(R.id.tv_section_title); |
| 301 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | 140 | + String titleText = categoryName + " (" + couponsets.size() + ")"; |
| 302 | - mRvFamily.setLayoutManager(layoutManager); | 141 | + tvTitle.setText(titleText); |
| 303 | - mRvFamily.setHasFixedSize(true); | 142 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, tvTitle); |
| 304 | 143 | ||
| 305 | - // Add spacing between items | 144 | + TextView tvAll = sectionView.findViewById(R.id.tv_section_all); |
| 306 | - int spacingInPixels = (int) TypedValue.applyDimension( | 145 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, tvAll); |
| 307 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 308 | - mRvFamily.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 309 | - | ||
| 310 | - // Create and set adapter | ||
| 311 | - mFamilyAdapter = new OfferAdapter(this, familyCategory.getItems()); | ||
| 312 | - mFamilyAdapter.setOnOfferClickListener(this); | ||
| 313 | - mRvFamily.setAdapter(mFamilyAdapter); | ||
| 314 | - } | ||
| 315 | 146 | ||
| 316 | - /** | 147 | + RecyclerView rvSection = sectionView.findViewById(R.id.rv_section_list); |
| 317 | - * Set up the Food & Coffee section with dummy data | ||
| 318 | - */ | ||
| 319 | - private void setupFoodCoffeeSection() { | ||
| 320 | - // Get Food & Coffee data | ||
| 321 | - OfferCategory foodCoffeeCategory = DummyDataProvider.getFoodAndCoffee(); | ||
| 322 | - | ||
| 323 | - // Set category title with item count | ||
| 324 | - String categoryTitle = foodCoffeeCategory.getName() + " (" + foodCoffeeCategory.getItems().size() + ")"; | ||
| 325 | - mTvCategoryFoodCoffee.setText(categoryTitle); | ||
| 326 | - | ||
| 327 | - // Set up RecyclerView | ||
| 328 | LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | 148 | LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); |
| 329 | - mRvFoodCoffee.setLayoutManager(layoutManager); | 149 | + rvSection.setLayoutManager(layoutManager); |
| 330 | - mRvFoodCoffee.setHasFixedSize(true); | 150 | + rvSection.setHasFixedSize(true); |
| 331 | - | 151 | + rvSection.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); |
| 332 | - // Add spacing between items | ||
| 333 | - int spacingInPixels = (int) TypedValue.applyDimension( | ||
| 334 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 335 | - mRvFoodCoffee.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 336 | 152 | ||
| 337 | - // Create and set adapter | 153 | + List<Couponset> displayList = couponsets.size() > MAX_ITEMS_PER_SECTION |
| 338 | - mFoodCoffeeAdapter = new OfferAdapter(this, foodCoffeeCategory.getItems()); | 154 | + ? new ArrayList<>(couponsets.subList(0, MAX_ITEMS_PER_SECTION)) |
| 339 | - mFoodCoffeeAdapter.setOnOfferClickListener(this); | 155 | + : couponsets; |
| 340 | - mRvFoodCoffee.setAdapter(mFoodCoffeeAdapter); | ||
| 341 | - } | ||
| 342 | - | ||
| 343 | - /** | ||
| 344 | - * Set up the Travelling section with dummy data | ||
| 345 | - */ | ||
| 346 | - private void setupTravellingSection() { | ||
| 347 | - // Get Travelling data | ||
| 348 | - OfferCategory travellingCategory = DummyDataProvider.getTravelling(); | ||
| 349 | - | ||
| 350 | - // Set category title with item count | ||
| 351 | - String categoryTitle = travellingCategory.getName() + " (" + travellingCategory.getItems().size() + ")"; | ||
| 352 | - mTvCategoryTravelling.setText(categoryTitle); | ||
| 353 | - | ||
| 354 | - // Set up RecyclerView | ||
| 355 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | ||
| 356 | - mRvTravelling.setLayoutManager(layoutManager); | ||
| 357 | - mRvTravelling.setHasFixedSize(true); | ||
| 358 | 156 | ||
| 359 | - // Add spacing between items | 157 | + CouponsetAdapter adapter = new CouponsetAdapter(this, displayList); |
| 360 | - int spacingInPixels = (int) TypedValue.applyDimension( | 158 | + adapter.setOnCouponsetClickListener(this); |
| 361 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | 159 | + rvSection.setAdapter(adapter); |
| 362 | - mRvTravelling.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 363 | 160 | ||
| 364 | - // Create and set adapter | 161 | + mSectionsContainer.addView(sectionView); |
| 365 | - mTravellingAdapter = new OfferAdapter(this, travellingCategory.getItems()); | ||
| 366 | - mTravellingAdapter.setOnOfferClickListener(this); | ||
| 367 | - mRvTravelling.setAdapter(mTravellingAdapter); | ||
| 368 | } | 162 | } |
| 369 | - | 163 | + mSectionsLoading.setVisibility(View.GONE); |
| 370 | - /** | ||
| 371 | - * Set up the Kids section with dummy data | ||
| 372 | - */ | ||
| 373 | - private void setupKidsSection() { | ||
| 374 | - // Get Kids data | ||
| 375 | - OfferCategory kidsCategory = DummyDataProvider.getKids(); | ||
| 376 | - | ||
| 377 | - // Set category title with item count | ||
| 378 | - String categoryTitle = kidsCategory.getName() + " (" + kidsCategory.getItems().size() + ")"; | ||
| 379 | - mTvCategoryKids.setText(categoryTitle); | ||
| 380 | - | ||
| 381 | - // Set up RecyclerView | ||
| 382 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | ||
| 383 | - mRvKids.setLayoutManager(layoutManager); | ||
| 384 | - mRvKids.setHasFixedSize(true); | ||
| 385 | - | ||
| 386 | - // Add spacing between items | ||
| 387 | - int spacingInPixels = (int) TypedValue.applyDimension( | ||
| 388 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 389 | - mRvKids.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 390 | - | ||
| 391 | - // Create and set adapter | ||
| 392 | - mKidsAdapter = new OfferAdapter(this, kidsCategory.getItems()); | ||
| 393 | - mKidsAdapter.setOnOfferClickListener(this); | ||
| 394 | - mRvKids.setAdapter(mKidsAdapter); | ||
| 395 | - } | ||
| 396 | - | ||
| 397 | - /** | ||
| 398 | - * Set up the Purchases section with dummy data | ||
| 399 | - */ | ||
| 400 | - private void setupPurchasesSection() { | ||
| 401 | - // Get Purchases data | ||
| 402 | - OfferCategory purchasesCategory = DummyDataProvider.getPurchases(); | ||
| 403 | - | ||
| 404 | - // Set category title with item count | ||
| 405 | - String categoryTitle = purchasesCategory.getName() + " (" + purchasesCategory.getItems().size() + ")"; | ||
| 406 | - mTvCategoryPurchases.setText(categoryTitle); | ||
| 407 | - | ||
| 408 | - // Set up RecyclerView | ||
| 409 | - LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); | ||
| 410 | - mRvPurchases.setLayoutManager(layoutManager); | ||
| 411 | - mRvPurchases.setHasFixedSize(true); | ||
| 412 | - | ||
| 413 | - // Add spacing between items | ||
| 414 | - int spacingInPixels = (int) TypedValue.applyDimension( | ||
| 415 | - TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); | ||
| 416 | - mRvPurchases.addItemDecoration(new HorizontalSpaceItemDecoration(spacingInPixels)); | ||
| 417 | - | ||
| 418 | - // Create and set adapter | ||
| 419 | - mPurchasesAdapter = new OfferAdapter(this, purchasesCategory.getItems()); | ||
| 420 | - mPurchasesAdapter.setOnOfferClickListener(this); | ||
| 421 | - mRvPurchases.setAdapter(mPurchasesAdapter); | ||
| 422 | } | 164 | } |
| 423 | 165 | ||
| 424 | // =========================================================== | 166 | // =========================================================== |
| 425 | - // Methods | 167 | + // Banner Methods |
| 426 | // =========================================================== | 168 | // =========================================================== |
| 427 | 169 | ||
| 428 | - /** | ||
| 429 | - * Sets up the banner carousel with ViewPager2 and pagination dots | ||
| 430 | - */ | ||
| 431 | private void setupBannerCarousel() { | 170 | private void setupBannerCarousel() { |
| 432 | mBannerViewPager = findViewById(R.id.banner_viewpager); | 171 | mBannerViewPager = findViewById(R.id.banner_viewpager); |
| 433 | mDotsContainer = findViewById(R.id.dots_container); | 172 | mDotsContainer = findViewById(R.id.dots_container); |
| ... | @@ -442,13 +181,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -442,13 +181,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
| 442 | 181 | ||
| 443 | // Set the number of pages to preload for adjacent items | 182 | // Set the number of pages to preload for adjacent items |
| 444 | mBannerViewPager.setOffscreenPageLimit(5); | 183 | mBannerViewPager.setOffscreenPageLimit(5); |
| 445 | - | ||
| 446 | mBannerViewPager.setAdapter(mBannerAdapter); | 184 | mBannerViewPager.setAdapter(mBannerAdapter); |
| 447 | 185 | ||
| 448 | - // Setup pagination dots | ||
| 449 | setupPaginationDots(WarplyManagerHelper.getBannerList().size()); | 186 | setupPaginationDots(WarplyManagerHelper.getBannerList().size()); |
| 450 | 187 | ||
| 451 | - // Handle page changes | ||
| 452 | mBannerViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { | 188 | mBannerViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
| 453 | @Override | 189 | @Override |
| 454 | public void onPageSelected(int position) { | 190 | public void onPageSelected(int position) { |
| ... | @@ -457,50 +193,38 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -457,50 +193,38 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
| 457 | }); | 193 | }); |
| 458 | } | 194 | } |
| 459 | 195 | ||
| 460 | - /** | ||
| 461 | - * Sets up the pagination dots | ||
| 462 | - * | ||
| 463 | - * @param count Number of dots to display | ||
| 464 | - */ | ||
| 465 | private void setupPaginationDots(int count) { | 196 | private void setupPaginationDots(int count) { |
| 466 | mDots = new ArrayList<>(); | 197 | mDots = new ArrayList<>(); |
| 467 | mDotsContainer.removeAllViews(); | 198 | mDotsContainer.removeAllViews(); |
| 468 | 199 | ||
| 469 | - // Create dots | ||
| 470 | for (int i = 0; i < count; i++) { | 200 | for (int i = 0; i < count; i++) { |
| 471 | ImageView dot = new ImageView(this); | 201 | ImageView dot = new ImageView(this); |
| 472 | 202 | ||
| 473 | - // Set dot appearance | ||
| 474 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( | 203 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( |
| 475 | LinearLayout.LayoutParams.WRAP_CONTENT, | 204 | LinearLayout.LayoutParams.WRAP_CONTENT, |
| 476 | LinearLayout.LayoutParams.WRAP_CONTENT | 205 | LinearLayout.LayoutParams.WRAP_CONTENT |
| 477 | ); | 206 | ); |
| 478 | - | ||
| 479 | - // Add margin between dots | ||
| 480 | params.setMargins(8, 0, 8, 0); | 207 | params.setMargins(8, 0, 8, 0); |
| 481 | dot.setLayoutParams(params); | 208 | dot.setLayoutParams(params); |
| 482 | 209 | ||
| 483 | - // Set initial state (first dot active, others inactive) | ||
| 484 | dot.setImageResource(i == 0 ? R.drawable.dot_active : R.drawable.dot_inactive); | 210 | dot.setImageResource(i == 0 ? R.drawable.dot_active : R.drawable.dot_inactive); |
| 485 | 211 | ||
| 486 | - // Add to container and list | ||
| 487 | mDotsContainer.addView(dot); | 212 | mDotsContainer.addView(dot); |
| 488 | mDots.add(dot); | 213 | mDots.add(dot); |
| 489 | } | 214 | } |
| 490 | } | 215 | } |
| 491 | 216 | ||
| 492 | - /** | ||
| 493 | - * Updates the dots to reflect the current page | ||
| 494 | - * | ||
| 495 | - * @param position Current page position | ||
| 496 | - */ | ||
| 497 | private void updateDots(int position) { | 217 | private void updateDots(int position) { |
| 498 | for (int i = 0; i < mDots.size(); i++) { | 218 | for (int i = 0; i < mDots.size(); i++) { |
| 499 | mDots.get(i).setImageResource(i == position ? R.drawable.dot_active : R.drawable.dot_inactive); | 219 | mDots.get(i).setImageResource(i == position ? R.drawable.dot_active : R.drawable.dot_inactive); |
| 500 | } | 220 | } |
| 501 | } | 221 | } |
| 502 | 222 | ||
| 503 | - private CallbackReceiver<ArrayList<BannerItem>> mCampaignsCallback = new CallbackReceiver<ArrayList<BannerItem>>() { | 223 | + // =========================================================== |
| 224 | + // Callbacks | ||
| 225 | + // =========================================================== | ||
| 226 | + | ||
| 227 | + private final CallbackReceiver<ArrayList<BannerItem>> mCampaignsCallback = new CallbackReceiver<ArrayList<BannerItem>>() { | ||
| 504 | @Override | 228 | @Override |
| 505 | public void onSuccess(ArrayList<BannerItem> result) { | 229 | public void onSuccess(ArrayList<BannerItem> result) { |
| 506 | mPbLoading.setVisibility(View.GONE); | 230 | mPbLoading.setVisibility(View.GONE); |
| ... | @@ -526,15 +250,18 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -526,15 +250,18 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
| 526 | } | 250 | } |
| 527 | }; | 251 | }; |
| 528 | 252 | ||
| 529 | - private CallbackReceiver<ArrayList<Couponset>> mCouponsetsCallback = new CallbackReceiver<ArrayList<Couponset>>() { | 253 | + private final CallbackReceiver<LinkedHashMap<String, ArrayList<Couponset>>> mCouponsetsCallback = new CallbackReceiver<LinkedHashMap<String, ArrayList<Couponset>>>() { |
| 530 | @Override | 254 | @Override |
| 531 | - public void onSuccess(ArrayList<Couponset> result) { | 255 | + public void onSuccess(LinkedHashMap<String, ArrayList<Couponset>> result) { |
| 532 | - mPbLoading.setVisibility(View.GONE); | 256 | + mSectionsLoading.setVisibility(View.GONE); |
| 257 | + if (result != null && !result.isEmpty()) { | ||
| 258 | + setupCouponsetSections(result); | ||
| 259 | + } | ||
| 533 | } | 260 | } |
| 534 | 261 | ||
| 535 | @Override | 262 | @Override |
| 536 | public void onFailure(int errorCode) { | 263 | public void onFailure(int errorCode) { |
| 537 | - mPbLoading.setVisibility(View.GONE); | 264 | + mSectionsLoading.setVisibility(View.GONE); |
| 538 | } | 265 | } |
| 539 | }; | 266 | }; |
| 540 | } | 267 | } | ... | ... |
| ... | @@ -5,6 +5,7 @@ import android.os.Bundle; | ... | @@ -5,6 +5,7 @@ import android.os.Bundle; |
| 5 | import android.view.LayoutInflater; | 5 | import android.view.LayoutInflater; |
| 6 | import android.view.View; | 6 | import android.view.View; |
| 7 | import android.view.ViewGroup; | 7 | import android.view.ViewGroup; |
| 8 | +import android.widget.EditText; | ||
| 8 | import android.widget.LinearLayout; | 9 | import android.widget.LinearLayout; |
| 9 | import android.widget.RelativeLayout; | 10 | import android.widget.RelativeLayout; |
| 10 | import android.widget.Toast; | 11 | import android.widget.Toast; |
| ... | @@ -17,12 +18,15 @@ import org.json.JSONObject; | ... | @@ -17,12 +18,15 @@ import org.json.JSONObject; |
| 17 | import ly.warp.sdk.R; | 18 | import ly.warp.sdk.R; |
| 18 | import ly.warp.sdk.activities.HomeActivity; | 19 | import ly.warp.sdk.activities.HomeActivity; |
| 19 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 20 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 21 | +import ly.warp.sdk.io.models.User; | ||
| 20 | import ly.warp.sdk.utils.WarpUtils; | 22 | import ly.warp.sdk.utils.WarpUtils; |
| 21 | import ly.warp.sdk.utils.managers.WarplyManager; | 23 | import ly.warp.sdk.utils.managers.WarplyManager; |
| 22 | 24 | ||
| 23 | public class HomeFragment extends Fragment implements View.OnClickListener { | 25 | public class HomeFragment extends Fragment implements View.OnClickListener { |
| 24 | private RelativeLayout mPbLoading; | 26 | private RelativeLayout mPbLoading; |
| 25 | private LinearLayout mRlSmFlow; | 27 | private LinearLayout mRlSmFlow; |
| 28 | + private EditText mEtLogin; | ||
| 29 | + private LinearLayout mLlLogin; | ||
| 26 | 30 | ||
| 27 | @Override | 31 | @Override |
| 28 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | 32 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
| ... | @@ -36,15 +40,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -36,15 +40,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
| 36 | mPbLoading.setOnTouchListener((v, event) -> true); | 40 | mPbLoading.setOnTouchListener((v, event) -> true); |
| 37 | mRlSmFlow = view.findViewById(R.id.ll_sm_flow); | 41 | mRlSmFlow = view.findViewById(R.id.ll_sm_flow); |
| 38 | mRlSmFlow.setOnClickListener(this); | 42 | mRlSmFlow.setOnClickListener(this); |
| 43 | + mEtLogin = view.findViewById(R.id.et_login); | ||
| 44 | + mLlLogin = view.findViewById(R.id.ll_login); | ||
| 45 | + mLlLogin.setOnClickListener(this); | ||
| 39 | 46 | ||
| 40 | WarpUtils.applyEdgeToEdge(getActivity(), | 47 | WarpUtils.applyEdgeToEdge(getActivity(), |
| 41 | view.findViewById(R.id.rl_header), | 48 | view.findViewById(R.id.rl_header), |
| 42 | null); | 49 | null); |
| 43 | - | ||
| 44 | - // 6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826 | ||
| 45 | - // prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282, live 3000136179 | ||
| 46 | -// mPbLoading.setVisibility(View.VISIBLE); | ||
| 47 | -// WarplyManager.getDehUser("aggeliki@warp.ly", mLoginReceiver); | ||
| 48 | } | 50 | } |
| 49 | 51 | ||
| 50 | @Override | 52 | @Override |
| ... | @@ -59,6 +61,11 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -59,6 +61,11 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
| 59 | // WarplyManager.logout(mLogoutReceiver); | 61 | // WarplyManager.logout(mLogoutReceiver); |
| 60 | // return; | 62 | // return; |
| 61 | // } | 63 | // } |
| 64 | + if (view.getId() == R.id.ll_login) { | ||
| 65 | + mPbLoading.setVisibility(View.VISIBLE); | ||
| 66 | + WarplyManager.login(mEtLogin.getText().toString(), mLoginReceiver); | ||
| 67 | + return; | ||
| 68 | + } | ||
| 62 | if (view.getId() == R.id.ll_sm_flow) { | 69 | if (view.getId() == R.id.ll_sm_flow) { |
| 63 | Intent myIntent = new Intent(getContext(), HomeActivity.class); | 70 | Intent myIntent = new Intent(getContext(), HomeActivity.class); |
| 64 | startActivity(myIntent); | 71 | startActivity(myIntent); |
| ... | @@ -87,8 +94,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -87,8 +94,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
| 87 | private final CallbackReceiver<JSONObject> mLoginReceiver = new CallbackReceiver<JSONObject>() { | 94 | private final CallbackReceiver<JSONObject> mLoginReceiver = new CallbackReceiver<JSONObject>() { |
| 88 | @Override | 95 | @Override |
| 89 | public void onSuccess(JSONObject result) { | 96 | public void onSuccess(JSONObject result) { |
| 90 | - mPbLoading.setVisibility(View.GONE); | 97 | +// mPbLoading.setVisibility(View.GONE); |
| 91 | Toast.makeText(getActivity(), "LOGIN SUCCESS", Toast.LENGTH_SHORT).show(); | 98 | Toast.makeText(getActivity(), "LOGIN SUCCESS", Toast.LENGTH_SHORT).show(); |
| 99 | + WarplyManager.getUser(mUserReceiver); | ||
| 92 | } | 100 | } |
| 93 | 101 | ||
| 94 | @Override | 102 | @Override |
| ... | @@ -97,4 +105,20 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -97,4 +105,20 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
| 97 | Toast.makeText(getActivity(), "LOGIN ERROR", Toast.LENGTH_SHORT).show(); | 105 | Toast.makeText(getActivity(), "LOGIN ERROR", Toast.LENGTH_SHORT).show(); |
| 98 | } | 106 | } |
| 99 | }; | 107 | }; |
| 108 | + | ||
| 109 | + private final CallbackReceiver<User> mUserReceiver = new CallbackReceiver<User>() { | ||
| 110 | + @Override | ||
| 111 | + public void onSuccess(User user) { | ||
| 112 | + mPbLoading.setVisibility(View.GONE); | ||
| 113 | + Toast.makeText(getActivity(), "USER SUCCESS", Toast.LENGTH_SHORT).show(); | ||
| 114 | + Intent myIntent = new Intent(getContext(), HomeActivity.class); | ||
| 115 | + startActivity(myIntent); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + @Override | ||
| 119 | + public void onFailure(int errorCode) { | ||
| 120 | + mPbLoading.setVisibility(View.GONE); | ||
| 121 | + Toast.makeText(getActivity(), "USER ERROR", Toast.LENGTH_SHORT).show(); | ||
| 122 | + } | ||
| 123 | + }; | ||
| 100 | } | 124 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -47,6 +47,24 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView | ... | @@ -47,6 +47,24 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView |
| 47 | this.mListenerContent = listener; | 47 | this.mListenerContent = listener; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | + private String getCampaignImage(BannerItem item) { | ||
| 51 | + if (item.getCampaign().getExtraFields() != null) { | ||
| 52 | + if (!item.getCampaign().getExtraFields().isNull("banner_img_mobile")) { | ||
| 53 | + return item.getCampaign().getExtraFields().optString("banner_img_mobile", ""); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + return item.getCampaign().getLogoUrl(); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + private String getContentImage(BannerItem item) { | ||
| 61 | + if (!item.getContent().getImg().isEmpty()) { | ||
| 62 | + return item.getContent().getImg().get(0); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + return item.getContent().getImgPreview(); | ||
| 66 | + } | ||
| 67 | + | ||
| 50 | @NonNull | 68 | @NonNull |
| 51 | @Override | 69 | @Override |
| 52 | public BannerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | 70 | public BannerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
| ... | @@ -64,7 +82,7 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView | ... | @@ -64,7 +82,7 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView |
| 64 | // RequestOptions | 82 | // RequestOptions |
| 65 | // .placeholderOf(R.drawable.demo_logo) | 83 | // .placeholderOf(R.drawable.demo_logo) |
| 66 | // .error(R.drawable.demo_logo)) | 84 | // .error(R.drawable.demo_logo)) |
| 67 | - .load(bannerItem.getCampaign().getLogoUrl()) | 85 | + .load(getCampaignImage(bannerItem)) |
| 68 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 86 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 69 | .into(holder.imageView); | 87 | .into(holder.imageView); |
| 70 | 88 | ||
| ... | @@ -79,7 +97,7 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView | ... | @@ -79,7 +97,7 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView |
| 79 | // RequestOptions | 97 | // RequestOptions |
| 80 | // .placeholderOf(R.drawable.demo_logo) | 98 | // .placeholderOf(R.drawable.demo_logo) |
| 81 | // .error(R.drawable.demo_logo)) | 99 | // .error(R.drawable.demo_logo)) |
| 82 | - .load(bannerItem.getContent().getImgPreview()) | 100 | + .load(getContentImage(bannerItem)) |
| 83 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 101 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 84 | .into(holder.imageView); | 102 | .into(holder.imageView); |
| 85 | 103 | ... | ... |
| 1 | +package ly.warp.sdk.io.adapters; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.util.TypedValue; | ||
| 5 | +import android.view.LayoutInflater; | ||
| 6 | +import android.view.View; | ||
| 7 | +import android.view.ViewGroup; | ||
| 8 | +import android.widget.ImageView; | ||
| 9 | +import android.widget.TextView; | ||
| 10 | + | ||
| 11 | +import androidx.annotation.NonNull; | ||
| 12 | +import androidx.recyclerview.widget.RecyclerView; | ||
| 13 | + | ||
| 14 | +import com.bumptech.glide.Glide; | ||
| 15 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
| 16 | +import com.bumptech.glide.load.resource.bitmap.CenterCrop; | ||
| 17 | + | ||
| 18 | +import java.text.ParseException; | ||
| 19 | +import java.text.SimpleDateFormat; | ||
| 20 | +import java.util.Date; | ||
| 21 | +import java.util.List; | ||
| 22 | +import java.util.Locale; | ||
| 23 | + | ||
| 24 | +import ly.warp.sdk.R; | ||
| 25 | +import ly.warp.sdk.io.models.Couponset; | ||
| 26 | +import ly.warp.sdk.utils.TopRoundedCornersTransformation; | ||
| 27 | +import ly.warp.sdk.utils.WarpUtils; | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +public class CouponsetAdapter extends RecyclerView.Adapter<CouponsetAdapter.CouponsetViewHolder> { | ||
| 31 | + | ||
| 32 | + private final List<Couponset> couponsets; | ||
| 33 | + private final Context context; | ||
| 34 | + private OnCouponsetClickListener listener; | ||
| 35 | + | ||
| 36 | + public interface OnCouponsetClickListener { | ||
| 37 | + void onCouponsetClick(Couponset couponset, int position); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public CouponsetAdapter(Context context, List<Couponset> couponsets) { | ||
| 41 | + this.context = context; | ||
| 42 | + this.couponsets = couponsets; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public void setOnCouponsetClickListener(OnCouponsetClickListener listener) { | ||
| 46 | + this.listener = listener; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @NonNull | ||
| 50 | + @Override | ||
| 51 | + public CouponsetViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
| 52 | + View view = LayoutInflater.from(context).inflate(R.layout.demo_item_offer, parent, false); | ||
| 53 | + return new CouponsetViewHolder(view); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public void onBindViewHolder(@NonNull CouponsetViewHolder holder, int position) { | ||
| 58 | + Couponset couponset = couponsets.get(position); | ||
| 59 | + holder.bind(couponset, position); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public int getItemCount() { | ||
| 64 | + return couponsets.size(); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public class CouponsetViewHolder extends RecyclerView.ViewHolder { | ||
| 68 | + private final ImageView ivOfferImage; | ||
| 69 | + private final ImageView ivFavorite; | ||
| 70 | + private final ImageView ivLogo; | ||
| 71 | + private final TextView tvPrice; | ||
| 72 | + private final TextView tvTitle; | ||
| 73 | + private final TextView tvDescription; | ||
| 74 | + private final TextView tvValidity; | ||
| 75 | + | ||
| 76 | + CouponsetViewHolder(@NonNull View itemView) { | ||
| 77 | + super(itemView); | ||
| 78 | + ivOfferImage = itemView.findViewById(R.id.iv_offer_image); | ||
| 79 | + ivFavorite = itemView.findViewById(R.id.iv_favorite); | ||
| 80 | + ivLogo = itemView.findViewById(R.id.iv_logo); | ||
| 81 | + tvPrice = itemView.findViewById(R.id.tv_price); | ||
| 82 | + tvTitle = itemView.findViewById(R.id.tv_title); | ||
| 83 | + tvDescription = itemView.findViewById(R.id.tv_description); | ||
| 84 | + tvValidity = itemView.findViewById(R.id.tv_validity); | ||
| 85 | + | ||
| 86 | + WarpUtils.renderCustomFont(context, R.font.ping_lcg_bold, tvPrice, tvTitle); | ||
| 87 | + WarpUtils.renderCustomFont(context, R.font.ping_lcg_regular, tvDescription, tvValidity); | ||
| 88 | + | ||
| 89 | + itemView.setOnClickListener(v -> { | ||
| 90 | + int position = getAdapterPosition(); | ||
| 91 | + if (listener != null && position != RecyclerView.NO_POSITION) { | ||
| 92 | + listener.onCouponsetClick(couponsets.get(position), position); | ||
| 93 | + } | ||
| 94 | + }); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + private void bind(Couponset couponset, int position) { | ||
| 98 | + tvTitle.setText(couponset.getName() != null ? couponset.getName() : ""); | ||
| 99 | + tvDescription.setText(couponset.getShortDescription() != null ? couponset.getShortDescription() : ""); | ||
| 100 | + tvPrice.setText(couponset.getDiscount() != null ? couponset.getDiscount() : ""); | ||
| 101 | + | ||
| 102 | + if (couponset.getEndDate() != null && !couponset.getEndDate().isEmpty()) { | ||
| 103 | + tvValidity.setText(formatValidityDate(couponset.getEndDate())); | ||
| 104 | + tvValidity.setVisibility(View.VISIBLE); | ||
| 105 | + } else { | ||
| 106 | + tvValidity.setVisibility(View.GONE); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + ivFavorite.setImageResource(R.drawable.demo_heart); | ||
| 110 | + | ||
| 111 | + loadCouponsetImage(couponset.getImgPreview()); | ||
| 112 | + | ||
| 113 | + if (couponset.getMerchant() != null && couponset.getMerchant().getImgPreview() != null) { | ||
| 114 | + loadMerchantLogo(couponset.getMerchant().getImgPreview()); | ||
| 115 | + } else { | ||
| 116 | + ivLogo.setVisibility(View.GONE); | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + private String formatValidityDate(String endDate) { | ||
| 121 | + try { | ||
| 122 | + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); | ||
| 123 | + Date date = inputFormat.parse(endDate); | ||
| 124 | + SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); | ||
| 125 | + return "έως " + outputFormat.format(date); | ||
| 126 | + } catch (ParseException e) { | ||
| 127 | + try { | ||
| 128 | + SimpleDateFormat inputFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()); | ||
| 129 | + Date date = inputFormat2.parse(endDate); | ||
| 130 | + SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault()); | ||
| 131 | + return "έως " + outputFormat.format(date); | ||
| 132 | + } catch (ParseException e2) { | ||
| 133 | + return endDate; | ||
| 134 | + } | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + private void loadCouponsetImage(String imageUrl) { | ||
| 139 | + if (imageUrl != null && !imageUrl.isEmpty()) { | ||
| 140 | + int radiusInPixels = (int) TypedValue.applyDimension( | ||
| 141 | + TypedValue.COMPLEX_UNIT_DIP, 9, | ||
| 142 | + context.getResources().getDisplayMetrics()); | ||
| 143 | + | ||
| 144 | + Glide.with(context) | ||
| 145 | + .load(imageUrl) | ||
| 146 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
| 147 | + .transform(new CenterCrop(), new TopRoundedCornersTransformation(radiusInPixels)) | ||
| 148 | + .into(ivOfferImage); | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + private void loadMerchantLogo(String logoUrl) { | ||
| 153 | + if (logoUrl != null && !logoUrl.isEmpty()) { | ||
| 154 | + ivLogo.setVisibility(View.VISIBLE); | ||
| 155 | + Glide.with(context) | ||
| 156 | + .load(logoUrl) | ||
| 157 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
| 158 | + .into(ivLogo); | ||
| 159 | + } else { | ||
| 160 | + ivLogo.setVisibility(View.GONE); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | +} |
| ... | @@ -42,6 +42,10 @@ import ly.warp.sdk.utils.WarpUtils; | ... | @@ -42,6 +42,10 @@ import ly.warp.sdk.utils.WarpUtils; |
| 42 | import ly.warp.sdk.utils.WarplyProperty; | 42 | import ly.warp.sdk.utils.WarplyProperty; |
| 43 | import ly.warp.sdk.utils.constants.WarpConstants; | 43 | import ly.warp.sdk.utils.constants.WarpConstants; |
| 44 | 44 | ||
| 45 | +/** | ||
| 46 | + * Created by Panagiotis Triantafyllou on 27-Feb-26. | ||
| 47 | + */ | ||
| 48 | + | ||
| 45 | public class Campaign implements Parcelable, Serializable { | 49 | public class Campaign implements Parcelable, Serializable { |
| 46 | 50 | ||
| 47 | private static final long serialVersionUID = -4754964462459705285L; | 51 | private static final long serialVersionUID = -4754964462459705285L; |
| ... | @@ -74,6 +78,16 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -74,6 +78,16 @@ public class Campaign implements Parcelable, Serializable { |
| 74 | private static final String CAMPAIGN_TYPE_SETTINGS = "campaign_type_settings"; | 78 | private static final String CAMPAIGN_TYPE_SETTINGS = "campaign_type_settings"; |
| 75 | private static final String CATEGORY_ID = "category_id"; | 79 | private static final String CATEGORY_ID = "category_id"; |
| 76 | private static final String COUPON_AVAILABILITY = "coupon_availability"; | 80 | private static final String COUPON_AVAILABILITY = "coupon_availability"; |
| 81 | + private static final String COMMUNICATION_UUID = "communication_uuid"; | ||
| 82 | + private static final String COMMUNICATION_NAME = "communication_name"; | ||
| 83 | + private static final String COMMUNICATION_CATEGORY = "communication_category"; | ||
| 84 | + private static final String CATEGORY = "category"; | ||
| 85 | + private static final String DESCRIPTION = "description"; | ||
| 86 | + private static final String WORKFLOW_SETTINGS = "workflow_settings"; | ||
| 87 | + private static final String SETTINGS = "settings"; | ||
| 88 | + private static final String AUDIENCE = "audience"; | ||
| 89 | + private static final String START_DATE = "start_date"; | ||
| 90 | + private static final String END_DATE = "end_date"; | ||
| 77 | 91 | ||
| 78 | /* Member variables of the Campaign object */ | 92 | /* Member variables of the Campaign object */ |
| 79 | 93 | ||
| ... | @@ -91,7 +105,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -91,7 +105,7 @@ public class Campaign implements Parcelable, Serializable { |
| 91 | private int opened; | 105 | private int opened; |
| 92 | private boolean isNew; | 106 | private boolean isNew; |
| 93 | private String logoUrl; | 107 | private String logoUrl; |
| 94 | - private String extraFields; | 108 | + private JSONObject extraFields; |
| 95 | private String type; | 109 | private String type; |
| 96 | private boolean expired; | 110 | private boolean expired; |
| 97 | private boolean show; | 111 | private boolean show; |
| ... | @@ -103,10 +117,27 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -103,10 +117,27 @@ public class Campaign implements Parcelable, Serializable { |
| 103 | private String campaignTypeSettings; | 117 | private String campaignTypeSettings; |
| 104 | private String categoryId; | 118 | private String categoryId; |
| 105 | private Integer couponAvailability; | 119 | private Integer couponAvailability; |
| 106 | - private String endDate, startDate; | 120 | + private String endDate; |
| 121 | + private String startDate; | ||
| 107 | private boolean showExpiration; | 122 | private boolean showExpiration; |
| 108 | private String couponImg; | 123 | private String couponImg; |
| 109 | - private String filter = ""; | 124 | + private String filter; |
| 125 | + private String communicationUuid; | ||
| 126 | + private String communicationName; | ||
| 127 | + private String communicationCategory; | ||
| 128 | + private String category; | ||
| 129 | + private String description; | ||
| 130 | + private JSONObject workflowSettings; | ||
| 131 | + private JSONObject settings; | ||
| 132 | + private String audience; | ||
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * Helper method to get a nullable String from a JSONObject. | ||
| 136 | + * Returns null if the JSON value is null, otherwise returns the String value. | ||
| 137 | + */ | ||
| 138 | + private static String optNullableString(JSONObject json, String key) { | ||
| 139 | + return json.isNull(key) ? null : json.optString(key); | ||
| 140 | + } | ||
| 110 | 141 | ||
| 111 | /** | 142 | /** |
| 112 | * Basic constructor used to create an object from a String, representing a | 143 | * Basic constructor used to create an object from a String, representing a |
| ... | @@ -123,33 +154,41 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -123,33 +154,41 @@ public class Campaign implements Parcelable, Serializable { |
| 123 | this.action = 0; | 154 | this.action = 0; |
| 124 | this.delivered = 0.0d; | 155 | this.delivered = 0.0d; |
| 125 | this.expires = 0.0d; | 156 | this.expires = 0.0d; |
| 126 | - this.message = ""; | 157 | + this.message = null; |
| 127 | - this.offerCategory = ""; | 158 | + this.offerCategory = null; |
| 128 | - this.offerMessage = ""; | 159 | + this.offerMessage = null; |
| 129 | - this.sessionUUID = ""; | 160 | + this.sessionUUID = null; |
| 130 | this.starts = 0.0d; | 161 | this.starts = 0.0d; |
| 131 | - this.subtitle = ""; | 162 | + this.subtitle = null; |
| 132 | - this.title = ""; | 163 | + this.title = null; |
| 133 | this.sorting = 0; | 164 | this.sorting = 0; |
| 134 | this.opened = 0; | 165 | this.opened = 0; |
| 135 | this.isNew = true; | 166 | this.isNew = true; |
| 136 | - this.logoUrl = ""; | 167 | + this.logoUrl = null; |
| 137 | - this.extraFields = ""; | 168 | + this.extraFields = null; |
| 138 | - this.type = ""; | 169 | + this.type = null; |
| 139 | this.expired = false; | 170 | this.expired = false; |
| 140 | this.show = true; | 171 | this.show = true; |
| 141 | - this.deliveryMethod = ""; | 172 | + this.deliveryMethod = null; |
| 142 | - this.displayType = ""; | 173 | + this.displayType = null; |
| 143 | - this.indexUrl = ""; | 174 | + this.indexUrl = null; |
| 144 | - this.busId = ""; | 175 | + this.busId = null; |
| 145 | this.actions = new ArrayList<>(); | 176 | this.actions = new ArrayList<>(); |
| 146 | - this.campaignTypeSettings = ""; | 177 | + this.campaignTypeSettings = null; |
| 147 | this.couponAvailability = null; | 178 | this.couponAvailability = null; |
| 148 | - this.categoryId = ""; | 179 | + this.categoryId = null; |
| 149 | - this.endDate = ""; | 180 | + this.endDate = null; |
| 150 | - this.startDate = ""; | 181 | + this.startDate = null; |
| 151 | this.showExpiration = false; | 182 | this.showExpiration = false; |
| 152 | - this.couponImg = ""; | 183 | + this.couponImg = null; |
| 184 | + this.communicationUuid = null; | ||
| 185 | + this.communicationName = null; | ||
| 186 | + this.communicationCategory = null; | ||
| 187 | + this.category = null; | ||
| 188 | + this.description = null; | ||
| 189 | + this.workflowSettings = null; | ||
| 190 | + this.settings = null; | ||
| 191 | + this.audience = null; | ||
| 153 | } | 192 | } |
| 154 | 193 | ||
| 155 | /** | 194 | /** |
| ... | @@ -158,35 +197,35 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -158,35 +197,35 @@ public class Campaign implements Parcelable, Serializable { |
| 158 | * @param json JSON Object used to create the Campaign | 197 | * @param json JSON Object used to create the Campaign |
| 159 | */ | 198 | */ |
| 160 | public Campaign(JSONObject json) { | 199 | public Campaign(JSONObject json) { |
| 161 | - this.indexUrl = json.optString(INDEX_URL); | 200 | + this.indexUrl = optNullableString(json, INDEX_URL); |
| 162 | - this.logoUrl = json.optString(LOGO_URL); | 201 | + this.logoUrl = optNullableString(json, LOGO_URL); |
| 163 | this.delivered = json.optDouble(DELIVERED); | 202 | this.delivered = json.optDouble(DELIVERED); |
| 164 | - this.sessionUUID = json.optString(SESSION_UUID); | 203 | + this.sessionUUID = optNullableString(json, SESSION_UUID); |
| 165 | - this.subtitle = json.optString(SUBTITLE); | 204 | + this.subtitle = optNullableString(json, SUBTITLE); |
| 166 | this.starts = json.optDouble(STARTS); | 205 | this.starts = json.optDouble(STARTS); |
| 167 | - this.message = json.optString(MESSAGE); | 206 | + this.message = optNullableString(json, MESSAGE); |
| 168 | this.opened = json.optInt(OPENED); | 207 | this.opened = json.optInt(OPENED); |
| 169 | this.expires = json.optDouble(EXPIRES); | 208 | this.expires = json.optDouble(EXPIRES); |
| 170 | - this.offerCategory = json.optString(OFFER_CATEGORY); | 209 | + this.offerCategory = optNullableString(json, OFFER_CATEGORY); |
| 171 | 210 | ||
| 172 | if (belongsInCategory(WarpConstants.MICROAPP_CAMPAIGNS_STANDARD_OFFER_NO_DATE)) { | 211 | if (belongsInCategory(WarpConstants.MICROAPP_CAMPAIGNS_STANDARD_OFFER_NO_DATE)) { |
| 173 | this.expires = 0; | 212 | this.expires = 0; |
| 174 | this.offerCategory = WarpConstants.MICROAPP_CAMPAIGNS_STANDARD_OFFER; | 213 | this.offerCategory = WarpConstants.MICROAPP_CAMPAIGNS_STANDARD_OFFER; |
| 175 | } | 214 | } |
| 176 | 215 | ||
| 177 | - this.title = json.optString(TITLE); | 216 | + this.title = optNullableString(json, TITLE); |
| 178 | this.action = json.optInt(ACTION); | 217 | this.action = json.optInt(ACTION); |
| 179 | - this.offerMessage = json.optString(OFFER_MESSAGE); | 218 | + this.offerMessage = optNullableString(json, OFFER_MESSAGE); |
| 180 | this.isNew = json.optBoolean(IS_NEW); | 219 | this.isNew = json.optBoolean(IS_NEW); |
| 181 | this.sorting = json.optInt(SORTING); | 220 | this.sorting = json.optInt(SORTING); |
| 182 | - this.extraFields = json.optString(EXTRA_FIELDS); | 221 | + this.extraFields = json.optJSONObject(EXTRA_FIELDS); |
| 183 | - this.type = json.optString(TYPE); | 222 | + this.type = optNullableString(json, TYPE); |
| 184 | this.expired = json.optBoolean(EXPIRED); | 223 | this.expired = json.optBoolean(EXPIRED); |
| 185 | this.show = json.optBoolean(SHOW); | 224 | this.show = json.optBoolean(SHOW); |
| 186 | - this.deliveryMethod = json.optString(DELIVERY_METHOD); | 225 | + this.deliveryMethod = optNullableString(json, DELIVERY_METHOD); |
| 187 | - this.displayType = json.optString(DISPLAY_TYPE); | 226 | + this.displayType = optNullableString(json, DISPLAY_TYPE); |
| 188 | - this.busId = json.optString(BUS_ID); | 227 | + this.busId = optNullableString(json, BUS_ID); |
| 189 | - this.campaignTypeSettings = json.optString(CAMPAIGN_TYPE_SETTINGS); | 228 | + this.campaignTypeSettings = optNullableString(json, CAMPAIGN_TYPE_SETTINGS); |
| 190 | 229 | ||
| 191 | JSONArray actions = json.optJSONArray(ACTIONS); | 230 | JSONArray actions = json.optJSONArray(ACTIONS); |
| 192 | if (actions != null) { | 231 | if (actions != null) { |
| ... | @@ -196,8 +235,18 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -196,8 +235,18 @@ public class Campaign implements Parcelable, Serializable { |
| 196 | } else { | 235 | } else { |
| 197 | this.actions = null; | 236 | this.actions = null; |
| 198 | } | 237 | } |
| 199 | - this.categoryId = json.optString(CATEGORY_ID); | 238 | + this.categoryId = optNullableString(json, CATEGORY_ID); |
| 200 | this.couponAvailability = json.optInt(COUPON_AVAILABILITY); | 239 | this.couponAvailability = json.optInt(COUPON_AVAILABILITY); |
| 240 | + this.communicationUuid = optNullableString(json, COMMUNICATION_UUID); | ||
| 241 | + this.communicationName = optNullableString(json, COMMUNICATION_NAME); | ||
| 242 | + this.communicationCategory = optNullableString(json, COMMUNICATION_CATEGORY); | ||
| 243 | + this.category = optNullableString(json, CATEGORY); | ||
| 244 | + this.description = optNullableString(json, DESCRIPTION); | ||
| 245 | + this.workflowSettings = json.optJSONObject(WORKFLOW_SETTINGS); | ||
| 246 | + this.settings = json.optJSONObject(SETTINGS); | ||
| 247 | + this.audience = optNullableString(json, AUDIENCE); | ||
| 248 | + this.startDate = optNullableString(json, START_DATE); | ||
| 249 | + this.endDate = optNullableString(json, END_DATE); | ||
| 201 | } | 250 | } |
| 202 | 251 | ||
| 203 | public Campaign(Parcel source) { | 252 | public Campaign(Parcel source) { |
| ... | @@ -216,7 +265,12 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -216,7 +265,12 @@ public class Campaign implements Parcelable, Serializable { |
| 216 | this.opened = source.readInt(); | 265 | this.opened = source.readInt(); |
| 217 | this.isNew = source.readInt() > 0; | 266 | this.isNew = source.readInt() > 0; |
| 218 | this.logoUrl = source.readString(); | 267 | this.logoUrl = source.readString(); |
| 219 | - this.extraFields = source.readString(); | 268 | + try { |
| 269 | + String extraFieldsStr = source.readString(); | ||
| 270 | + this.extraFields = extraFieldsStr != null ? new JSONObject(extraFieldsStr) : null; | ||
| 271 | + } catch (JSONException e) { | ||
| 272 | + this.extraFields = null; | ||
| 273 | + } | ||
| 220 | this.type = source.readString(); | 274 | this.type = source.readString(); |
| 221 | this.expired = source.readInt() > 0; | 275 | this.expired = source.readInt() > 0; |
| 222 | this.show = source.readInt() > 0; | 276 | this.show = source.readInt() > 0; |
| ... | @@ -227,6 +281,26 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -227,6 +281,26 @@ public class Campaign implements Parcelable, Serializable { |
| 227 | this.campaignTypeSettings = source.readString(); | 281 | this.campaignTypeSettings = source.readString(); |
| 228 | this.categoryId = source.readString(); | 282 | this.categoryId = source.readString(); |
| 229 | this.couponAvailability = source.readInt(); | 283 | this.couponAvailability = source.readInt(); |
| 284 | + this.communicationUuid = source.readString(); | ||
| 285 | + this.communicationName = source.readString(); | ||
| 286 | + this.communicationCategory = source.readString(); | ||
| 287 | + this.category = source.readString(); | ||
| 288 | + this.description = source.readString(); | ||
| 289 | + try { | ||
| 290 | + String workflowSettingsStr = source.readString(); | ||
| 291 | + this.workflowSettings = workflowSettingsStr != null ? new JSONObject(workflowSettingsStr) : null; | ||
| 292 | + } catch (JSONException e) { | ||
| 293 | + this.workflowSettings = null; | ||
| 294 | + } | ||
| 295 | + try { | ||
| 296 | + String settingsStr = source.readString(); | ||
| 297 | + this.settings = settingsStr != null ? new JSONObject(settingsStr) : null; | ||
| 298 | + } catch (JSONException e) { | ||
| 299 | + this.settings = null; | ||
| 300 | + } | ||
| 301 | + this.audience = source.readString(); | ||
| 302 | + this.startDate = source.readString(); | ||
| 303 | + this.endDate = source.readString(); | ||
| 230 | } | 304 | } |
| 231 | 305 | ||
| 232 | @Override | 306 | @Override |
| ... | @@ -246,7 +320,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -246,7 +320,7 @@ public class Campaign implements Parcelable, Serializable { |
| 246 | dest.writeInt(this.opened); | 320 | dest.writeInt(this.opened); |
| 247 | dest.writeInt(this.isNew ? 1 : 0); | 321 | dest.writeInt(this.isNew ? 1 : 0); |
| 248 | dest.writeString(this.logoUrl); | 322 | dest.writeString(this.logoUrl); |
| 249 | - dest.writeString(this.extraFields); | 323 | + dest.writeString(this.extraFields != null ? this.extraFields.toString() : null); |
| 250 | dest.writeString(this.type); | 324 | dest.writeString(this.type); |
| 251 | dest.writeInt(this.expired ? 1 : 0); | 325 | dest.writeInt(this.expired ? 1 : 0); |
| 252 | dest.writeInt(this.show ? 1 : 0); | 326 | dest.writeInt(this.show ? 1 : 0); |
| ... | @@ -257,6 +331,16 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -257,6 +331,16 @@ public class Campaign implements Parcelable, Serializable { |
| 257 | dest.writeString(this.campaignTypeSettings); | 331 | dest.writeString(this.campaignTypeSettings); |
| 258 | dest.writeInt(this.couponAvailability); | 332 | dest.writeInt(this.couponAvailability); |
| 259 | dest.writeString(this.categoryId); | 333 | dest.writeString(this.categoryId); |
| 334 | + dest.writeString(this.communicationUuid); | ||
| 335 | + dest.writeString(this.communicationName); | ||
| 336 | + dest.writeString(this.communicationCategory); | ||
| 337 | + dest.writeString(this.category); | ||
| 338 | + dest.writeString(this.description); | ||
| 339 | + dest.writeString(this.workflowSettings != null ? this.workflowSettings.toString() : null); | ||
| 340 | + dest.writeString(this.settings != null ? this.settings.toString() : null); | ||
| 341 | + dest.writeString(this.audience); | ||
| 342 | + dest.writeString(this.startDate); | ||
| 343 | + dest.writeString(this.endDate); | ||
| 260 | } | 344 | } |
| 261 | 345 | ||
| 262 | /** | 346 | /** |
| ... | @@ -267,32 +351,41 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -267,32 +351,41 @@ public class Campaign implements Parcelable, Serializable { |
| 267 | public JSONObject toJSONObject() { | 351 | public JSONObject toJSONObject() { |
| 268 | JSONObject jObj = new JSONObject(); | 352 | JSONObject jObj = new JSONObject(); |
| 269 | try { | 353 | try { |
| 270 | - jObj.putOpt(INDEX_URL, this.indexUrl); | 354 | + jObj.put(INDEX_URL, this.indexUrl != null ? this.indexUrl : JSONObject.NULL); |
| 271 | - jObj.putOpt(LOGO_URL, this.logoUrl); | 355 | + jObj.put(LOGO_URL, this.logoUrl != null ? this.logoUrl : JSONObject.NULL); |
| 272 | jObj.putOpt(ACTION, this.action); | 356 | jObj.putOpt(ACTION, this.action); |
| 273 | jObj.putOpt(DELIVERED, this.delivered); | 357 | jObj.putOpt(DELIVERED, this.delivered); |
| 274 | jObj.putOpt(EXPIRES, this.expires); | 358 | jObj.putOpt(EXPIRES, this.expires); |
| 275 | - jObj.putOpt(MESSAGE, this.message); | 359 | + jObj.put(MESSAGE, this.message != null ? this.message : JSONObject.NULL); |
| 276 | - jObj.putOpt(OFFER_CATEGORY, this.offerCategory); | 360 | + jObj.put(OFFER_CATEGORY, this.offerCategory != null ? this.offerCategory : JSONObject.NULL); |
| 277 | - jObj.putOpt(OFFER_MESSAGE, this.offerMessage); | 361 | + jObj.put(OFFER_MESSAGE, this.offerMessage != null ? this.offerMessage : JSONObject.NULL); |
| 278 | - jObj.putOpt(SESSION_UUID, this.sessionUUID); | 362 | + jObj.put(SESSION_UUID, this.sessionUUID != null ? this.sessionUUID : JSONObject.NULL); |
| 279 | jObj.putOpt(STARTS, this.starts); | 363 | jObj.putOpt(STARTS, this.starts); |
| 280 | - jObj.putOpt(SUBTITLE, this.subtitle); | 364 | + jObj.put(SUBTITLE, this.subtitle != null ? this.subtitle : JSONObject.NULL); |
| 281 | - jObj.putOpt(TITLE, this.title); | 365 | + jObj.put(TITLE, this.title != null ? this.title : JSONObject.NULL); |
| 282 | jObj.putOpt(SORTING, this.sorting); | 366 | jObj.putOpt(SORTING, this.sorting); |
| 283 | jObj.putOpt(OPENED, this.opened); | 367 | jObj.putOpt(OPENED, this.opened); |
| 284 | jObj.putOpt(IS_NEW, this.isNew); | 368 | jObj.putOpt(IS_NEW, this.isNew); |
| 285 | - jObj.putOpt(SORTING, this.sorting); | 369 | + jObj.put(EXTRA_FIELDS, this.extraFields != null ? this.extraFields : JSONObject.NULL); |
| 286 | - jObj.putOpt(EXTRA_FIELDS, this.extraFields); | 370 | + jObj.put(TYPE, this.type != null ? this.type : JSONObject.NULL); |
| 287 | - jObj.putOpt(TYPE, this.type); | ||
| 288 | jObj.putOpt(EXPIRED, this.expired); | 371 | jObj.putOpt(EXPIRED, this.expired); |
| 289 | jObj.putOpt(SHOW, this.show); | 372 | jObj.putOpt(SHOW, this.show); |
| 290 | - jObj.putOpt(DELIVERY_METHOD, this.deliveryMethod); | 373 | + jObj.put(DELIVERY_METHOD, this.deliveryMethod != null ? this.deliveryMethod : JSONObject.NULL); |
| 291 | - jObj.putOpt(DISPLAY_TYPE, this.displayType); | 374 | + jObj.put(DISPLAY_TYPE, this.displayType != null ? this.displayType : JSONObject.NULL); |
| 292 | - jObj.put(BUS_ID, this.busId); | 375 | + jObj.put(BUS_ID, this.busId != null ? this.busId : JSONObject.NULL); |
| 293 | - jObj.put(CAMPAIGN_TYPE_SETTINGS, this.campaignTypeSettings); | 376 | + jObj.put(CAMPAIGN_TYPE_SETTINGS, this.campaignTypeSettings != null ? this.campaignTypeSettings : JSONObject.NULL); |
| 294 | jObj.putOpt(COUPON_AVAILABILITY, this.couponAvailability); | 377 | jObj.putOpt(COUPON_AVAILABILITY, this.couponAvailability); |
| 295 | - jObj.putOpt(CATEGORY_ID, this.categoryId); | 378 | + jObj.put(CATEGORY_ID, this.categoryId != null ? this.categoryId : JSONObject.NULL); |
| 379 | + jObj.put(COMMUNICATION_UUID, this.communicationUuid != null ? this.communicationUuid : JSONObject.NULL); | ||
| 380 | + jObj.put(COMMUNICATION_NAME, this.communicationName != null ? this.communicationName : JSONObject.NULL); | ||
| 381 | + jObj.put(COMMUNICATION_CATEGORY, this.communicationCategory != null ? this.communicationCategory : JSONObject.NULL); | ||
| 382 | + jObj.put(CATEGORY, this.category != null ? this.category : JSONObject.NULL); | ||
| 383 | + jObj.put(DESCRIPTION, this.description != null ? this.description : JSONObject.NULL); | ||
| 384 | + jObj.put(WORKFLOW_SETTINGS, this.workflowSettings != null ? this.workflowSettings : JSONObject.NULL); | ||
| 385 | + jObj.put(SETTINGS, this.settings != null ? this.settings : JSONObject.NULL); | ||
| 386 | + jObj.put(AUDIENCE, this.audience != null ? this.audience : JSONObject.NULL); | ||
| 387 | + jObj.put(START_DATE, this.startDate != null ? this.startDate : JSONObject.NULL); | ||
| 388 | + jObj.put(END_DATE, this.endDate != null ? this.endDate : JSONObject.NULL); | ||
| 296 | } catch (JSONException e) { | 389 | } catch (JSONException e) { |
| 297 | if (WarpConstants.DEBUG) { | 390 | if (WarpConstants.DEBUG) { |
| 298 | e.printStackTrace(); | 391 | e.printStackTrace(); |
| ... | @@ -366,7 +459,6 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -366,7 +459,6 @@ public class Campaign implements Parcelable, Serializable { |
| 366 | // Getters | 459 | // Getters |
| 367 | // ================================================================================ | 460 | // ================================================================================ |
| 368 | 461 | ||
| 369 | - | ||
| 370 | public String getCategoryId() { | 462 | public String getCategoryId() { |
| 371 | return categoryId; | 463 | return categoryId; |
| 372 | } | 464 | } |
| ... | @@ -499,7 +591,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -499,7 +591,7 @@ public class Campaign implements Parcelable, Serializable { |
| 499 | return indexUrl; | 591 | return indexUrl; |
| 500 | } | 592 | } |
| 501 | 593 | ||
| 502 | - public String getExtraFields() { | 594 | + public JSONObject getExtraFields() { |
| 503 | return extraFields; | 595 | return extraFields; |
| 504 | } | 596 | } |
| 505 | 597 | ||
| ... | @@ -615,7 +707,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -615,7 +707,7 @@ public class Campaign implements Parcelable, Serializable { |
| 615 | this.logoUrl = logoUrl; | 707 | this.logoUrl = logoUrl; |
| 616 | } | 708 | } |
| 617 | 709 | ||
| 618 | - public void setExtraFields(String extraFields) { | 710 | + public void setExtraFields(JSONObject extraFields) { |
| 619 | this.extraFields = extraFields; | 711 | this.extraFields = extraFields; |
| 620 | } | 712 | } |
| 621 | 713 | ||
| ... | @@ -671,6 +763,70 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -671,6 +763,70 @@ public class Campaign implements Parcelable, Serializable { |
| 671 | this.filter = filter; | 763 | this.filter = filter; |
| 672 | } | 764 | } |
| 673 | 765 | ||
| 766 | + public String getCommunicationUuid() { | ||
| 767 | + return communicationUuid; | ||
| 768 | + } | ||
| 769 | + | ||
| 770 | + public void setCommunicationUuid(String communicationUuid) { | ||
| 771 | + this.communicationUuid = communicationUuid; | ||
| 772 | + } | ||
| 773 | + | ||
| 774 | + public String getCommunicationName() { | ||
| 775 | + return communicationName; | ||
| 776 | + } | ||
| 777 | + | ||
| 778 | + public void setCommunicationName(String communicationName) { | ||
| 779 | + this.communicationName = communicationName; | ||
| 780 | + } | ||
| 781 | + | ||
| 782 | + public String getCommunicationCategory() { | ||
| 783 | + return communicationCategory; | ||
| 784 | + } | ||
| 785 | + | ||
| 786 | + public void setCommunicationCategory(String communicationCategory) { | ||
| 787 | + this.communicationCategory = communicationCategory; | ||
| 788 | + } | ||
| 789 | + | ||
| 790 | + public String getCategory() { | ||
| 791 | + return category; | ||
| 792 | + } | ||
| 793 | + | ||
| 794 | + public void setCategory(String category) { | ||
| 795 | + this.category = category; | ||
| 796 | + } | ||
| 797 | + | ||
| 798 | + public String getDescription() { | ||
| 799 | + return description; | ||
| 800 | + } | ||
| 801 | + | ||
| 802 | + public void setDescription(String description) { | ||
| 803 | + this.description = description; | ||
| 804 | + } | ||
| 805 | + | ||
| 806 | + public JSONObject getWorkflowSettings() { | ||
| 807 | + return workflowSettings; | ||
| 808 | + } | ||
| 809 | + | ||
| 810 | + public void setWorkflowSettings(JSONObject workflowSettings) { | ||
| 811 | + this.workflowSettings = workflowSettings; | ||
| 812 | + } | ||
| 813 | + | ||
| 814 | + public JSONObject getSettings() { | ||
| 815 | + return settings; | ||
| 816 | + } | ||
| 817 | + | ||
| 818 | + public void setSettings(JSONObject settings) { | ||
| 819 | + this.settings = settings; | ||
| 820 | + } | ||
| 821 | + | ||
| 822 | + public String getAudience() { | ||
| 823 | + return audience; | ||
| 824 | + } | ||
| 825 | + | ||
| 826 | + public void setAudience(String audience) { | ||
| 827 | + this.audience = audience; | ||
| 828 | + } | ||
| 829 | + | ||
| 674 | @Override | 830 | @Override |
| 675 | public int describeContents() { | 831 | public int describeContents() { |
| 676 | return 0; | 832 | return 0; | ... | ... |
| ... | @@ -77,61 +77,68 @@ public class Content implements Parcelable, Serializable { | ... | @@ -77,61 +77,68 @@ public class Content implements Parcelable, Serializable { |
| 77 | 77 | ||
| 78 | /* Member variables of the Content object */ | 78 | /* Member variables of the Content object */ |
| 79 | 79 | ||
| 80 | - private String id = ""; | 80 | + private String id; |
| 81 | - private int idid = 0; | 81 | + private int idid; |
| 82 | - private String customId = ""; | 82 | + private String customId; |
| 83 | - private String name = ""; | 83 | + private String name; |
| 84 | - private String description = ""; | 84 | + private String description; |
| 85 | - private String shortDescription = ""; | 85 | + private String shortDescription; |
| 86 | - private String couponDescription = ""; | 86 | + private String couponDescription; |
| 87 | - private boolean active = false; | 87 | + private boolean active; |
| 88 | - private String created = ""; | 88 | + private String created; |
| 89 | - private int categoryId = 0; | 89 | + private int categoryId; |
| 90 | - private String categoryName = ""; | 90 | + private String categoryName; |
| 91 | - private String categoryUuid = ""; | 91 | + private String categoryUuid; |
| 92 | - private String merchantUuid = ""; | 92 | + private String merchantUuid; |
| 93 | - private ArrayList<Tags> tags = new ArrayList<Tags>(); | 93 | + private ArrayList<Tags> tags; |
| 94 | - private String startDate = ""; | 94 | + private String startDate; |
| 95 | - private String endDate = ""; | 95 | + private String endDate; |
| 96 | - private String imgPreview = ""; | 96 | + private String imgPreview; |
| 97 | - private ArrayList<String> img = new ArrayList<String>(); | 97 | + private ArrayList<String> img; |
| 98 | - private boolean favourite = false; | 98 | + private boolean favourite; |
| 99 | - private JSONObject extraFields = new JSONObject(); | 99 | + private JSONObject extraFields; |
| 100 | - private String participated = ""; | 100 | + private String participated; |
| 101 | - private JSONObject participatedFields = new JSONObject(); | 101 | + private JSONObject participatedFields; |
| 102 | - private String parent = ""; | 102 | + private String parent; |
| 103 | - private int sorting = 0; | 103 | + private int sorting; |
| 104 | - private String consumerFullName = ""; | 104 | + private String consumerFullName; |
| 105 | - private String consumerPhoto = ""; | 105 | + private String consumerPhoto; |
| 106 | 106 | ||
| 107 | + /** | ||
| 108 | + * Helper method to get a nullable String from a JSONObject. | ||
| 109 | + * Returns null if the JSON value is null, otherwise returns the String value. | ||
| 110 | + */ | ||
| 111 | + private static String optNullableString(JSONObject json, String key) { | ||
| 112 | + return json.isNull(key) ? null : json.optString(key); | ||
| 113 | + } | ||
| 107 | 114 | ||
| 108 | public Content() { | 115 | public Content() { |
| 109 | - this.id = ""; | 116 | + this.id = null; |
| 110 | this.idid = 0; | 117 | this.idid = 0; |
| 111 | - this.customId = ""; | 118 | + this.customId = null; |
| 112 | - this.name = ""; | 119 | + this.name = null; |
| 113 | - this.description = ""; | 120 | + this.description = null; |
| 114 | - this.shortDescription = ""; | 121 | + this.shortDescription = null; |
| 115 | - this.couponDescription = ""; | 122 | + this.couponDescription = null; |
| 116 | this.active = false; | 123 | this.active = false; |
| 117 | - this.created = ""; | 124 | + this.created = null; |
| 118 | this.categoryId = 0; | 125 | this.categoryId = 0; |
| 119 | - this.categoryName = ""; | 126 | + this.categoryName = null; |
| 120 | - this.categoryUuid = ""; | 127 | + this.categoryUuid = null; |
| 121 | - this.merchantUuid = ""; | 128 | + this.merchantUuid = null; |
| 122 | this.tags = new ArrayList<Tags>(); | 129 | this.tags = new ArrayList<Tags>(); |
| 123 | - this.startDate = ""; | 130 | + this.startDate = null; |
| 124 | - this.endDate = ""; | 131 | + this.endDate = null; |
| 125 | - this.imgPreview = ""; | 132 | + this.imgPreview = null; |
| 126 | this.img = new ArrayList<String>(); | 133 | this.img = new ArrayList<String>(); |
| 127 | this.favourite = false; | 134 | this.favourite = false; |
| 128 | - this.extraFields = new JSONObject(); | 135 | + this.extraFields = null; |
| 129 | - this.participated = ""; | 136 | + this.participated = null; |
| 130 | - this.participatedFields = new JSONObject(); | 137 | + this.participatedFields = null; |
| 131 | - this.parent = ""; | 138 | + this.parent = null; |
| 132 | this.sorting = 0; | 139 | this.sorting = 0; |
| 133 | - this.consumerFullName = ""; | 140 | + this.consumerFullName = null; |
| 134 | - this.consumerPhoto = ""; | 141 | + this.consumerPhoto = null; |
| 135 | } | 142 | } |
| 136 | 143 | ||
| 137 | /** | 144 | /** |
| ... | @@ -149,19 +156,18 @@ public class Content implements Parcelable, Serializable { | ... | @@ -149,19 +156,18 @@ public class Content implements Parcelable, Serializable { |
| 149 | private static final String NAME = "name"; | 156 | private static final String NAME = "name"; |
| 150 | private static final String ID = "id"; | 157 | private static final String ID = "id"; |
| 151 | 158 | ||
| 152 | - | 159 | + private String name; |
| 153 | - private String name = ""; | 160 | + private String id; |
| 154 | - private String id = ""; | ||
| 155 | 161 | ||
| 156 | public Tags() { | 162 | public Tags() { |
| 157 | - this.name = ""; | 163 | + this.name = null; |
| 158 | - this.id = ""; | 164 | + this.id = null; |
| 159 | } | 165 | } |
| 160 | 166 | ||
| 161 | public Tags(JSONObject json) { | 167 | public Tags(JSONObject json) { |
| 162 | if (json != null) { | 168 | if (json != null) { |
| 163 | - this.name = json.isNull(NAME) ? "" : json.optString(NAME); | 169 | + this.name = json.isNull(NAME) ? null : json.optString(NAME); |
| 164 | - this.id = json.isNull(ID) ? "" : json.optString(ID); | 170 | + this.id = json.isNull(ID) ? null : json.optString(ID); |
| 165 | } | 171 | } |
| 166 | } | 172 | } |
| 167 | 173 | ||
| ... | @@ -189,48 +195,50 @@ public class Content implements Parcelable, Serializable { | ... | @@ -189,48 +195,50 @@ public class Content implements Parcelable, Serializable { |
| 189 | */ | 195 | */ |
| 190 | public Content(JSONObject json) { | 196 | public Content(JSONObject json) { |
| 191 | if (json != null) { | 197 | if (json != null) { |
| 192 | - this.id = json.optString(ID); | 198 | + this.id = optNullableString(json, ID); |
| 193 | this.idid = json.optInt(ID_ID); | 199 | this.idid = json.optInt(ID_ID); |
| 194 | - this.customId = json.isNull(CUSTOM_ID) ? "" : json.optString(CUSTOM_ID); | 200 | + this.customId = optNullableString(json, CUSTOM_ID); |
| 195 | - this.name = json.optString(NAME); | 201 | + this.name = optNullableString(json, NAME); |
| 196 | - this.description = json.optString(DESCRIPTION); | 202 | + this.description = optNullableString(json, DESCRIPTION); |
| 197 | - this.shortDescription = json.optString(SHORT_DESCRIPTION); | 203 | + this.shortDescription = optNullableString(json, SHORT_DESCRIPTION); |
| 198 | - this.couponDescription = json.optString(COUPON_DESCRIPTION); | 204 | + this.couponDescription = optNullableString(json, COUPON_DESCRIPTION); |
| 199 | this.active = json.optBoolean(ACTIVE); | 205 | this.active = json.optBoolean(ACTIVE); |
| 200 | - this.created = json.optString(CREATED); | 206 | + this.created = optNullableString(json, CREATED); |
| 201 | this.categoryId = json.optInt(CATEGORY_ID); | 207 | this.categoryId = json.optInt(CATEGORY_ID); |
| 202 | - this.categoryName = json.optString(CATEGORY_NAME); | 208 | + this.categoryName = optNullableString(json, CATEGORY_NAME); |
| 203 | - this.categoryUuid = json.optString(CATEGORY_UUID); | 209 | + this.categoryUuid = optNullableString(json, CATEGORY_UUID); |
| 204 | - this.merchantUuid = json.isNull(MERCHANT_UUID) ? "" : json.optString(MERCHANT_UUID); | 210 | + this.merchantUuid = optNullableString(json, MERCHANT_UUID); |
| 205 | JSONArray tempTags = json.optJSONArray(TAGS); | 211 | JSONArray tempTags = json.optJSONArray(TAGS); |
| 206 | if (tempTags != null) { | 212 | if (tempTags != null) { |
| 213 | + this.tags = new ArrayList<Tags>(); | ||
| 207 | for (int i = 0; i < tempTags.length(); i++) { | 214 | for (int i = 0; i < tempTags.length(); i++) { |
| 208 | this.tags.add(new Tags(tempTags.optJSONObject(i))); | 215 | this.tags.add(new Tags(tempTags.optJSONObject(i))); |
| 209 | } | 216 | } |
| 210 | } else { | 217 | } else { |
| 211 | - this.tags = new ArrayList<Tags>(); | 218 | + this.tags = null; |
| 212 | } | 219 | } |
| 213 | - this.startDate = json.isNull(START_DATE) ? "" : json.optString(START_DATE); | 220 | + this.startDate = optNullableString(json, START_DATE); |
| 214 | - this.endDate = json.isNull(END_DATE) ? "" : json.optString(END_DATE); | 221 | + this.endDate = optNullableString(json, END_DATE); |
| 215 | - this.imgPreview = json.optString(IMG_PREVIEW); | 222 | + this.imgPreview = optNullableString(json, IMG_PREVIEW); |
| 216 | try { | 223 | try { |
| 217 | JSONArray tempImg = new JSONArray(json.optString(IMG)); | 224 | JSONArray tempImg = new JSONArray(json.optString(IMG)); |
| 218 | if (tempImg != null) { | 225 | if (tempImg != null) { |
| 226 | + this.img = new ArrayList<String>(); | ||
| 219 | for (int i = 0; i < tempImg.length(); i++) { | 227 | for (int i = 0; i < tempImg.length(); i++) { |
| 220 | this.img.add(tempImg.optString(i)); | 228 | this.img.add(tempImg.optString(i)); |
| 221 | } | 229 | } |
| 222 | } | 230 | } |
| 223 | } catch (JSONException e) { | 231 | } catch (JSONException e) { |
| 224 | - this.img = new ArrayList<String>(); | 232 | + this.img = null; |
| 225 | } | 233 | } |
| 226 | this.favourite = json.optBoolean(FAVOURITE); | 234 | this.favourite = json.optBoolean(FAVOURITE); |
| 227 | this.extraFields = json.optJSONObject(EXTRA_FIELDS); | 235 | this.extraFields = json.optJSONObject(EXTRA_FIELDS); |
| 228 | - this.participated = json.isNull(PARTICIPATED) ? "" : json.optString(PARTICIPATED); | 236 | + this.participated = optNullableString(json, PARTICIPATED); |
| 229 | this.participatedFields = json.optJSONObject(PARTICIPATED_FIELDS); | 237 | this.participatedFields = json.optJSONObject(PARTICIPATED_FIELDS); |
| 230 | - this.parent = json.isNull(PARENT) ? "" : json.optString(PARENT); | 238 | + this.parent = optNullableString(json, PARENT); |
| 231 | this.sorting = json.optInt(SORTING); | 239 | this.sorting = json.optInt(SORTING); |
| 232 | - this.consumerFullName = json.isNull(CONSUMER_FULL_NAME) ? "" : json.optString(CONSUMER_FULL_NAME); | 240 | + this.consumerFullName = optNullableString(json, CONSUMER_FULL_NAME); |
| 233 | - this.consumerPhoto = json.isNull(CONSUMER_PHOTO) ? "" : json.optString(CONSUMER_PHOTO); | 241 | + this.consumerPhoto = optNullableString(json, CONSUMER_PHOTO); |
| 234 | } | 242 | } |
| 235 | } | 243 | } |
| 236 | 244 | ||
| ... | @@ -248,15 +256,25 @@ public class Content implements Parcelable, Serializable { | ... | @@ -248,15 +256,25 @@ public class Content implements Parcelable, Serializable { |
| 248 | this.categoryName = source.readString(); | 256 | this.categoryName = source.readString(); |
| 249 | this.categoryUuid = source.readString(); | 257 | this.categoryUuid = source.readString(); |
| 250 | this.merchantUuid = source.readString(); | 258 | this.merchantUuid = source.readString(); |
| 251 | - this.tags = source.readArrayList(null); | 259 | + this.tags = source.readArrayList(Tags.class.getClassLoader()); |
| 252 | this.startDate = source.readString(); | 260 | this.startDate = source.readString(); |
| 253 | this.endDate = source.readString(); | 261 | this.endDate = source.readString(); |
| 254 | this.imgPreview = source.readString(); | 262 | this.imgPreview = source.readString(); |
| 255 | this.img = source.createStringArrayList(); | 263 | this.img = source.createStringArrayList(); |
| 256 | this.favourite = source.readByte() != 0; | 264 | this.favourite = source.readByte() != 0; |
| 257 | - this.extraFields = (JSONObject) source.readSerializable(); | 265 | + try { |
| 266 | + String extraFieldsStr = source.readString(); | ||
| 267 | + this.extraFields = extraFieldsStr != null ? new JSONObject(extraFieldsStr) : null; | ||
| 268 | + } catch (JSONException e) { | ||
| 269 | + this.extraFields = null; | ||
| 270 | + } | ||
| 258 | this.participated = source.readString(); | 271 | this.participated = source.readString(); |
| 259 | - this.participatedFields = (JSONObject) source.readSerializable(); | 272 | + try { |
| 273 | + String participatedFieldsStr = source.readString(); | ||
| 274 | + this.participatedFields = participatedFieldsStr != null ? new JSONObject(participatedFieldsStr) : null; | ||
| 275 | + } catch (JSONException e) { | ||
| 276 | + this.participatedFields = null; | ||
| 277 | + } | ||
| 260 | this.parent = source.readString(); | 278 | this.parent = source.readString(); |
| 261 | this.sorting = source.readInt(); | 279 | this.sorting = source.readInt(); |
| 262 | this.consumerFullName = source.readString(); | 280 | this.consumerFullName = source.readString(); |
| ... | @@ -284,9 +302,9 @@ public class Content implements Parcelable, Serializable { | ... | @@ -284,9 +302,9 @@ public class Content implements Parcelable, Serializable { |
| 284 | dest.writeString(this.imgPreview); | 302 | dest.writeString(this.imgPreview); |
| 285 | dest.writeStringList(this.img); | 303 | dest.writeStringList(this.img); |
| 286 | dest.writeByte(this.favourite ? (byte) 1 : (byte) 0); | 304 | dest.writeByte(this.favourite ? (byte) 1 : (byte) 0); |
| 287 | - dest.writeSerializable((Serializable) this.extraFields); | 305 | + dest.writeString(this.extraFields != null ? this.extraFields.toString() : null); |
| 288 | dest.writeString(this.participated); | 306 | dest.writeString(this.participated); |
| 289 | - dest.writeSerializable((Serializable) this.participatedFields); | 307 | + dest.writeString(this.participatedFields != null ? this.participatedFields.toString() : null); |
| 290 | dest.writeString(this.parent); | 308 | dest.writeString(this.parent); |
| 291 | dest.writeInt(this.sorting); | 309 | dest.writeInt(this.sorting); |
| 292 | dest.writeString(this.consumerFullName); | 310 | dest.writeString(this.consumerFullName); |
| ... | @@ -301,8 +319,48 @@ public class Content implements Parcelable, Serializable { | ... | @@ -301,8 +319,48 @@ public class Content implements Parcelable, Serializable { |
| 301 | public JSONObject toJSONObject() { | 319 | public JSONObject toJSONObject() { |
| 302 | JSONObject jObj = new JSONObject(); | 320 | JSONObject jObj = new JSONObject(); |
| 303 | try { | 321 | try { |
| 304 | - jObj.putOpt(ID, this.id); | 322 | + jObj.put(ID, this.id != null ? this.id : JSONObject.NULL); |
| 305 | jObj.putOpt(ID_ID, this.idid); | 323 | jObj.putOpt(ID_ID, this.idid); |
| 324 | + jObj.put(CUSTOM_ID, this.customId != null ? this.customId : JSONObject.NULL); | ||
| 325 | + jObj.put(NAME, this.name != null ? this.name : JSONObject.NULL); | ||
| 326 | + jObj.put(DESCRIPTION, this.description != null ? this.description : JSONObject.NULL); | ||
| 327 | + jObj.put(SHORT_DESCRIPTION, this.shortDescription != null ? this.shortDescription : JSONObject.NULL); | ||
| 328 | + jObj.put(COUPON_DESCRIPTION, this.couponDescription != null ? this.couponDescription : JSONObject.NULL); | ||
| 329 | + jObj.putOpt(ACTIVE, this.active); | ||
| 330 | + jObj.put(CREATED, this.created != null ? this.created : JSONObject.NULL); | ||
| 331 | + jObj.putOpt(CATEGORY_ID, this.categoryId); | ||
| 332 | + jObj.put(CATEGORY_NAME, this.categoryName != null ? this.categoryName : JSONObject.NULL); | ||
| 333 | + jObj.put(CATEGORY_UUID, this.categoryUuid != null ? this.categoryUuid : JSONObject.NULL); | ||
| 334 | + jObj.put(MERCHANT_UUID, this.merchantUuid != null ? this.merchantUuid : JSONObject.NULL); | ||
| 335 | + if (this.tags != null) { | ||
| 336 | + JSONArray tagsArray = new JSONArray(); | ||
| 337 | + for (Tags tag : this.tags) { | ||
| 338 | + JSONObject tagObj = new JSONObject(); | ||
| 339 | + tagObj.put(Tags.ID, tag.getId() != null ? tag.getId() : JSONObject.NULL); | ||
| 340 | + tagObj.put(Tags.NAME, tag.getName() != null ? tag.getName() : JSONObject.NULL); | ||
| 341 | + tagsArray.put(tagObj); | ||
| 342 | + } | ||
| 343 | + jObj.put(TAGS, tagsArray); | ||
| 344 | + } else { | ||
| 345 | + jObj.put(TAGS, JSONObject.NULL); | ||
| 346 | + } | ||
| 347 | + jObj.put(START_DATE, this.startDate != null ? this.startDate : JSONObject.NULL); | ||
| 348 | + jObj.put(END_DATE, this.endDate != null ? this.endDate : JSONObject.NULL); | ||
| 349 | + jObj.put(IMG_PREVIEW, this.imgPreview != null ? this.imgPreview : JSONObject.NULL); | ||
| 350 | + if (this.img != null) { | ||
| 351 | + JSONArray imgArray = new JSONArray(this.img); | ||
| 352 | + jObj.put(IMG, imgArray.toString()); | ||
| 353 | + } else { | ||
| 354 | + jObj.put(IMG, JSONObject.NULL); | ||
| 355 | + } | ||
| 356 | + jObj.putOpt(FAVOURITE, this.favourite); | ||
| 357 | + jObj.put(EXTRA_FIELDS, this.extraFields != null ? this.extraFields : JSONObject.NULL); | ||
| 358 | + jObj.put(PARTICIPATED, this.participated != null ? this.participated : JSONObject.NULL); | ||
| 359 | + jObj.put(PARTICIPATED_FIELDS, this.participatedFields != null ? this.participatedFields : JSONObject.NULL); | ||
| 360 | + jObj.put(PARENT, this.parent != null ? this.parent : JSONObject.NULL); | ||
| 361 | + jObj.putOpt(SORTING, this.sorting); | ||
| 362 | + jObj.put(CONSUMER_FULL_NAME, this.consumerFullName != null ? this.consumerFullName : JSONObject.NULL); | ||
| 363 | + jObj.put(CONSUMER_PHOTO, this.consumerPhoto != null ? this.consumerPhoto : JSONObject.NULL); | ||
| 306 | } catch (JSONException e) { | 364 | } catch (JSONException e) { |
| 307 | if (WarpConstants.DEBUG) { | 365 | if (WarpConstants.DEBUG) { |
| 308 | e.printStackTrace(); | 366 | e.printStackTrace(); |
| ... | @@ -341,7 +399,6 @@ public class Content implements Parcelable, Serializable { | ... | @@ -341,7 +399,6 @@ public class Content implements Parcelable, Serializable { |
| 341 | // Getters | 399 | // Getters |
| 342 | // ================================================================================ | 400 | // ================================================================================ |
| 343 | 401 | ||
| 344 | - | ||
| 345 | public String getId() { | 402 | public String getId() { |
| 346 | return id; | 403 | return id; |
| 347 | } | 404 | } | ... | ... |
| ... | @@ -33,9 +33,7 @@ import org.json.JSONException; | ... | @@ -33,9 +33,7 @@ import org.json.JSONException; |
| 33 | import org.json.JSONObject; | 33 | import org.json.JSONObject; |
| 34 | 34 | ||
| 35 | import java.io.Serializable; | 35 | import java.io.Serializable; |
| 36 | -import java.text.ParseException; | 36 | +import java.util.ArrayList; |
| 37 | -import java.text.SimpleDateFormat; | ||
| 38 | -import java.util.Date; | ||
| 39 | 37 | ||
| 40 | import ly.warp.sdk.utils.WarpUtils; | 38 | import ly.warp.sdk.utils.WarpUtils; |
| 41 | import ly.warp.sdk.utils.constants.WarpConstants; | 39 | import ly.warp.sdk.utils.constants.WarpConstants; |
| ... | @@ -48,7 +46,7 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -48,7 +46,7 @@ public class Couponset implements Parcelable, Serializable { |
| 48 | 46 | ||
| 49 | private static final long serialVersionUID = -4754964462459705285L; | 47 | private static final long serialVersionUID = -4754964462459705285L; |
| 50 | 48 | ||
| 51 | - /* Constants used to export the campaign in JSON formal and vice versa */ | 49 | + /* Constants used to export the Couponset in JSON formal and vice versa */ |
| 52 | 50 | ||
| 53 | private static final String UUID = "uuid"; | 51 | private static final String UUID = "uuid"; |
| 54 | private static final String ADMIN_NAME = "admin_name"; | 52 | private static final String ADMIN_NAME = "admin_name"; |
| ... | @@ -66,7 +64,6 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -66,7 +64,6 @@ public class Couponset implements Parcelable, Serializable { |
| 66 | private static final String POINTS = "points"; | 64 | private static final String POINTS = "points"; |
| 67 | private static final String POINTS_CAUSE = "points_cause"; | 65 | private static final String POINTS_CAUSE = "points_cause"; |
| 68 | private static final String EXPIRATION = "expiration"; | 66 | private static final String EXPIRATION = "expiration"; |
| 69 | - private static final String VALUE = "value"; | ||
| 70 | private static final String THIRD_PARTY_SERVICE = "third_party_service"; | 67 | private static final String THIRD_PARTY_SERVICE = "third_party_service"; |
| 71 | private static final String NAME = "name"; | 68 | private static final String NAME = "name"; |
| 72 | private static final String DESCRIPTION = "description"; | 69 | private static final String DESCRIPTION = "description"; |
| ... | @@ -86,112 +83,156 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -86,112 +83,156 @@ public class Couponset implements Parcelable, Serializable { |
| 86 | private static final String LOCKED = "locked"; | 83 | private static final String LOCKED = "locked"; |
| 87 | private static final String UNLOCK_ACTION = "unlock_action"; | 84 | private static final String UNLOCK_ACTION = "unlock_action"; |
| 88 | private static final String UNLOCK_MESSAGE = "unlock_message"; | 85 | private static final String UNLOCK_MESSAGE = "unlock_message"; |
| 86 | + private static final String ELIGIBILITIES = "eligibilities"; | ||
| 87 | + private static final String START_DATE = "start_date"; | ||
| 88 | + private static final String END_DATE = "end_date"; | ||
| 89 | + private static final String HIDE_CONDITION = "hide_condition"; | ||
| 90 | + private static final String SHOW_AS_BANNER = "show_as_banner"; | ||
| 91 | + private static final String SEGMENT = "segment"; | ||
| 92 | + private static final String OFFER_CATEGORY = "offer_category"; | ||
| 93 | + private static final String TAGGING = "tagging"; | ||
| 94 | + private static final String REGIONS = "regions"; | ||
| 95 | + | ||
| 96 | + /* Member variables of the Couponset object */ | ||
| 97 | + | ||
| 98 | + private String uuid; | ||
| 99 | + private String admin_name; | ||
| 100 | + private String created; | ||
| 101 | + private String updated; | ||
| 102 | + private String app_uuid; | ||
| 103 | + private JSONArray img; | ||
| 104 | + private String img_preview; | ||
| 105 | + private Integer sorting; | ||
| 106 | + private boolean active; | ||
| 107 | + private boolean visible; | ||
| 108 | + private boolean buyable; | ||
| 109 | + private boolean user_generated; | ||
| 110 | + private JSONObject limits; | ||
| 111 | + private int points; | ||
| 112 | + private String points_cause; | ||
| 113 | + private JSONObject expiration; | ||
| 114 | + private boolean third_party_service; | ||
| 115 | + private String name; | ||
| 116 | + private String description; | ||
| 117 | + private String short_description; | ||
| 118 | + private String discount; | ||
| 119 | + private String category; | ||
| 120 | + private String terms; | ||
| 121 | + private int availability; | ||
| 122 | + private String merchantUuid; | ||
| 123 | + private String innerText; | ||
| 124 | + private String discount_type; | ||
| 125 | + private double final_price; | ||
| 126 | + private String couponsetType; | ||
| 127 | + private JSONObject extraFields; | ||
| 128 | + private boolean isNew; | ||
| 129 | + private boolean promoted; | ||
| 130 | + private boolean personalized; | ||
| 131 | + private boolean locked; | ||
| 132 | + private String unlockAction; | ||
| 133 | + private String unlockMessage; | ||
| 134 | + private JSONObject eligibilities; | ||
| 135 | + private String startDate; | ||
| 136 | + private String endDate; | ||
| 137 | + private JSONObject hideCondition; | ||
| 138 | + private JSONObject showAsBanner; | ||
| 139 | + private String segment; | ||
| 140 | + private String offerCategory; | ||
| 141 | + private JSONObject tagging; | ||
| 142 | + private JSONArray regions; | ||
| 143 | + private Merchant merchant; | ||
| 89 | 144 | ||
| 90 | - | 145 | + /** |
| 91 | - /* Member variables of the Campaign object */ | 146 | + * Helper method to get a nullable String from a JSONObject. |
| 92 | - | 147 | + * Returns null if the JSON value is null, otherwise returns the String value. |
| 93 | - private String uuid = ""; | 148 | + */ |
| 94 | - private String admin_name = ""; | 149 | + private static String optNullableString(JSONObject json, String key) { |
| 95 | - private String created = ""; | 150 | + return json.isNull(key) ? null : json.optString(key); |
| 96 | - private String updated = ""; | 151 | + } |
| 97 | - private String app_uuid = ""; | ||
| 98 | - private JSONArray img = new JSONArray(); | ||
| 99 | - private String img_preview = ""; | ||
| 100 | - private int sorting = 0; | ||
| 101 | - private boolean active = false; | ||
| 102 | - private boolean visible = false; | ||
| 103 | - private boolean buyable = false; | ||
| 104 | - private boolean user_generated = false; | ||
| 105 | - private JSONObject limits = new JSONObject(); | ||
| 106 | - private int points = 0; | ||
| 107 | - private String points_cause = ""; | ||
| 108 | - private String expiration = ""; | ||
| 109 | - private boolean third_party_service = false; | ||
| 110 | - private String name = ""; | ||
| 111 | - private String description = ""; | ||
| 112 | - private String short_description = ""; | ||
| 113 | - private String discount = ""; | ||
| 114 | - private String category = ""; | ||
| 115 | - private String terms = ""; | ||
| 116 | - private int availability = 0; | ||
| 117 | - private String merchantUuid = ""; | ||
| 118 | - private String innerText = ""; | ||
| 119 | - private String discount_type = ""; | ||
| 120 | - private double final_price = 0.0d; | ||
| 121 | - private Date endDate = new Date(); | ||
| 122 | - private String couponsetType = ""; | ||
| 123 | - private JSONObject extraFields = new JSONObject(); | ||
| 124 | - private boolean isNew = false; | ||
| 125 | - private boolean promoted = false; | ||
| 126 | - private boolean personalized = false; | ||
| 127 | - private boolean locked = false; | ||
| 128 | - private String unlockAction = ""; | ||
| 129 | - private String unlockMessage = ""; | ||
| 130 | 152 | ||
| 131 | public Couponset() { | 153 | public Couponset() { |
| 132 | - this.uuid = ""; | 154 | + this.uuid = null; |
| 133 | - this.admin_name = ""; | 155 | + this.admin_name = null; |
| 134 | - this.created = ""; | 156 | + this.created = null; |
| 135 | - this.updated = ""; | 157 | + this.updated = null; |
| 136 | - this.app_uuid = ""; | 158 | + this.app_uuid = null; |
| 137 | - this.img = new JSONArray(); | 159 | + this.img = null; |
| 138 | - this.img_preview = ""; | 160 | + this.img_preview = null; |
| 139 | - this.sorting = 0; | 161 | + this.sorting = null; |
| 140 | this.active = false; | 162 | this.active = false; |
| 141 | this.visible = false; | 163 | this.visible = false; |
| 142 | this.buyable = false; | 164 | this.buyable = false; |
| 143 | this.user_generated = false; | 165 | this.user_generated = false; |
| 144 | - this.limits = new JSONObject(); | 166 | + this.limits = null; |
| 145 | this.points = 0; | 167 | this.points = 0; |
| 146 | - this.points_cause = ""; | 168 | + this.points_cause = null; |
| 147 | - this.expiration = ""; | 169 | + this.expiration = null; |
| 148 | this.third_party_service = false; | 170 | this.third_party_service = false; |
| 149 | - this.name = ""; | 171 | + this.name = null; |
| 150 | - this.description = ""; | 172 | + this.description = null; |
| 151 | - this.short_description = ""; | 173 | + this.short_description = null; |
| 152 | - this.discount = ""; | 174 | + this.discount = null; |
| 153 | - this.category = ""; | 175 | + this.category = null; |
| 154 | - this.terms = ""; | 176 | + this.terms = null; |
| 155 | this.availability = 0; | 177 | this.availability = 0; |
| 156 | - this.merchantUuid = ""; | 178 | + this.merchantUuid = null; |
| 157 | - this.innerText = ""; | 179 | + this.innerText = null; |
| 158 | - this.discount_type = ""; | 180 | + this.discount_type = null; |
| 159 | this.final_price = 0.0d; | 181 | this.final_price = 0.0d; |
| 160 | - this.extraFields = new JSONObject(); | 182 | + this.couponsetType = null; |
| 183 | + this.extraFields = null; | ||
| 161 | this.isNew = false; | 184 | this.isNew = false; |
| 162 | this.promoted = false; | 185 | this.promoted = false; |
| 163 | this.personalized = false; | 186 | this.personalized = false; |
| 164 | this.locked = false; | 187 | this.locked = false; |
| 165 | - this.unlockAction = ""; | 188 | + this.unlockAction = null; |
| 166 | - this.unlockMessage = ""; | 189 | + this.unlockMessage = null; |
| 190 | + this.eligibilities = null; | ||
| 191 | + this.startDate = null; | ||
| 192 | + this.endDate = null; | ||
| 193 | + this.hideCondition = null; | ||
| 194 | + this.showAsBanner = null; | ||
| 195 | + this.segment = null; | ||
| 196 | + this.offerCategory = null; | ||
| 197 | + this.tagging = null; | ||
| 198 | + this.regions = null; | ||
| 199 | + this.merchant = null; | ||
| 167 | } | 200 | } |
| 168 | 201 | ||
| 169 | public Couponset(boolean isUniversal) { | 202 | public Couponset(boolean isUniversal) { |
| 170 | - this.admin_name = ""; | 203 | + this.uuid = null; |
| 204 | + this.admin_name = null; | ||
| 171 | this.active = false; | 205 | this.active = false; |
| 172 | this.buyable = false; | 206 | this.buyable = false; |
| 173 | - this.category = ""; | 207 | + this.category = null; |
| 174 | - this.created = ""; | 208 | + this.created = null; |
| 175 | - this.discount = ""; | 209 | + this.discount = null; |
| 176 | - this.discount_type = ""; | 210 | + this.discount_type = null; |
| 177 | - this.name = ""; | 211 | + this.name = null; |
| 178 | - this.img = new JSONArray(); | 212 | + this.img = null; |
| 179 | - this.short_description = ""; | 213 | + this.img_preview = null; |
| 180 | - this.terms = ""; | 214 | + this.short_description = null; |
| 181 | - this.updated = ""; | 215 | + this.terms = null; |
| 182 | - this.uuid = ""; | 216 | + this.updated = null; |
| 183 | -// this.endDate = new Date(); | 217 | + this.couponsetType = null; |
| 184 | - this.couponsetType = ""; | 218 | + this.innerText = null; |
| 185 | - this.img_preview = ""; | ||
| 186 | - this.innerText = ""; | ||
| 187 | this.final_price = 0.0d; | 219 | this.final_price = 0.0d; |
| 188 | - this.extraFields = new JSONObject(); | 220 | + this.extraFields = null; |
| 189 | this.isNew = false; | 221 | this.isNew = false; |
| 190 | this.promoted = false; | 222 | this.promoted = false; |
| 191 | this.personalized = false; | 223 | this.personalized = false; |
| 192 | this.locked = false; | 224 | this.locked = false; |
| 193 | - this.unlockAction = ""; | 225 | + this.unlockAction = null; |
| 194 | - this.unlockMessage = ""; | 226 | + this.unlockMessage = null; |
| 227 | + this.eligibilities = null; | ||
| 228 | + this.startDate = null; | ||
| 229 | + this.endDate = null; | ||
| 230 | + this.hideCondition = null; | ||
| 231 | + this.showAsBanner = null; | ||
| 232 | + this.segment = null; | ||
| 233 | + this.offerCategory = null; | ||
| 234 | + this.tagging = null; | ||
| 235 | + this.regions = null; | ||
| 195 | } | 236 | } |
| 196 | 237 | ||
| 197 | /** | 238 | /** |
| ... | @@ -208,23 +249,22 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -208,23 +249,22 @@ public class Couponset implements Parcelable, Serializable { |
| 208 | /** | 249 | /** |
| 209 | * Constructor used to create an Object from a given JSON Object | 250 | * Constructor used to create an Object from a given JSON Object |
| 210 | * | 251 | * |
| 211 | - * @param json JSON Object used to create the Address | 252 | + * @param json JSON Object used to create the Couponset |
| 212 | */ | 253 | */ |
| 213 | public Couponset(JSONObject json) { | 254 | public Couponset(JSONObject json) { |
| 214 | if (json != null) { | 255 | if (json != null) { |
| 215 | - this.uuid = json.optString(UUID); | 256 | + this.uuid = optNullableString(json, UUID); |
| 216 | - this.admin_name = json.optString(ADMIN_NAME); | 257 | + this.admin_name = optNullableString(json, ADMIN_NAME); |
| 217 | - this.created = json.optString(CREATED); | 258 | + this.created = optNullableString(json, CREATED); |
| 218 | - this.updated = json.optString(UPDATED); | 259 | + this.updated = optNullableString(json, UPDATED); |
| 219 | - this.app_uuid = json.optString(APP_UUID); | 260 | + this.app_uuid = optNullableString(json, APP_UUID); |
| 220 | -// this.img = json.optJSONArray(IMG); | ||
| 221 | try { | 261 | try { |
| 222 | this.img = new JSONArray(json.optString(IMG)); | 262 | this.img = new JSONArray(json.optString(IMG)); |
| 223 | } catch (JSONException e) { | 263 | } catch (JSONException e) { |
| 224 | - e.printStackTrace(); | 264 | + this.img = null; |
| 225 | } | 265 | } |
| 226 | - this.img_preview = json.optString(IMG_PREVIEW); | 266 | + this.img_preview = optNullableString(json, IMG_PREVIEW); |
| 227 | - this.sorting = json.optInt(SORTING); | 267 | + this.sorting = json.isNull(SORTING) ? null : json.optInt(SORTING); |
| 228 | this.active = json.optBoolean(ACTIVE); | 268 | this.active = json.optBoolean(ACTIVE); |
| 229 | this.visible = json.optBoolean(VISIBLE); | 269 | this.visible = json.optBoolean(VISIBLE); |
| 230 | this.buyable = json.optBoolean(BUYABLE); | 270 | this.buyable = json.optBoolean(BUYABLE); |
| ... | @@ -232,102 +272,77 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -232,102 +272,77 @@ public class Couponset implements Parcelable, Serializable { |
| 232 | this.promoted = json.optBoolean(PROMOTED); | 272 | this.promoted = json.optBoolean(PROMOTED); |
| 233 | this.personalized = json.optBoolean(PERSONALIZED); | 273 | this.personalized = json.optBoolean(PERSONALIZED); |
| 234 | this.locked = json.optBoolean(LOCKED); | 274 | this.locked = json.optBoolean(LOCKED); |
| 235 | - this.unlockAction = json.optString(UNLOCK_ACTION); | 275 | + this.unlockAction = optNullableString(json, UNLOCK_ACTION); |
| 236 | - this.unlockMessage = json.optString(UNLOCK_MESSAGE); | 276 | + this.unlockMessage = optNullableString(json, UNLOCK_MESSAGE); |
| 237 | this.user_generated = json.optBoolean(USER_GENERATED); | 277 | this.user_generated = json.optBoolean(USER_GENERATED); |
| 238 | this.limits = json.optJSONObject(LIMITS); | 278 | this.limits = json.optJSONObject(LIMITS); |
| 239 | this.points = json.optInt(POINTS); | 279 | this.points = json.optInt(POINTS); |
| 240 | - this.points_cause = json.optString(POINTS_CAUSE); | 280 | + this.points_cause = optNullableString(json, POINTS_CAUSE); |
| 241 | - JSONObject exp = null; | 281 | + this.expiration = json.optJSONObject(EXPIRATION); |
| 242 | - try { | ||
| 243 | - exp = new JSONObject(json.optString(EXPIRATION)); | ||
| 244 | - this.expiration = exp.optString(VALUE); | ||
| 245 | - } catch (JSONException e) { | ||
| 246 | - e.printStackTrace(); | ||
| 247 | - this.expiration = ""; | ||
| 248 | - } | ||
| 249 | this.third_party_service = json.optBoolean(THIRD_PARTY_SERVICE); | 282 | this.third_party_service = json.optBoolean(THIRD_PARTY_SERVICE); |
| 250 | - this.name = json.optString(NAME); | 283 | + this.name = optNullableString(json, NAME); |
| 251 | - this.description = json.optString(DESCRIPTION); | 284 | + this.description = optNullableString(json, DESCRIPTION); |
| 252 | - this.short_description = json.optString(SHORT_DESCRIPTION); | 285 | + this.short_description = optNullableString(json, SHORT_DESCRIPTION); |
| 253 | - this.discount = json.optString(DISCOUNT); | 286 | + this.discount = optNullableString(json, DISCOUNT); |
| 254 | - this.category = json.optString(CATEGORY); | 287 | + this.category = optNullableString(json, CATEGORY); |
| 255 | - this.terms = json.optString(TERMS); | 288 | + this.terms = optNullableString(json, TERMS); |
| 256 | this.availability = json.optInt(AVAILABILITY); | 289 | this.availability = json.optInt(AVAILABILITY); |
| 257 | - this.merchantUuid = json.optString(MERCHANT_UUID); | 290 | + this.merchantUuid = optNullableString(json, MERCHANT_UUID); |
| 258 | - this.innerText = json.optString(INNER_TEXT); | 291 | + this.innerText = optNullableString(json, INNER_TEXT); |
| 259 | - this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE); | 292 | + this.discount_type = optNullableString(json, DISCOUNT_TYPE); |
| 260 | this.final_price = json.isNull(FINAL_PRICE) ? 0.0d : json.optDouble(FINAL_PRICE); | 293 | this.final_price = json.isNull(FINAL_PRICE) ? 0.0d : json.optDouble(FINAL_PRICE); |
| 261 | -// this.extraFields = json.optJSONObject(EXTRA_FIELDS); | 294 | + this.extraFields = json.optJSONObject(EXTRA_FIELDS); |
| 262 | - JSONObject ef = null; | 295 | + this.eligibilities = json.optJSONObject(ELIGIBILITIES); |
| 263 | - ef = json.optJSONObject(EXTRA_FIELDS); | 296 | + this.startDate = optNullableString(json, START_DATE); |
| 264 | - this.extraFields = ef; | 297 | + this.endDate = optNullableString(json, END_DATE); |
| 298 | + this.hideCondition = json.optJSONObject(HIDE_CONDITION); | ||
| 299 | + this.showAsBanner = json.optJSONObject(SHOW_AS_BANNER); | ||
| 300 | + this.segment = optNullableString(json, SEGMENT); | ||
| 301 | + this.offerCategory = optNullableString(json, OFFER_CATEGORY); | ||
| 302 | + this.tagging = json.optJSONObject(TAGGING); | ||
| 303 | + this.regions = json.optJSONArray(REGIONS); | ||
| 265 | } | 304 | } |
| 266 | } | 305 | } |
| 267 | 306 | ||
| 268 | public Couponset(JSONObject json, boolean isUniversal) { | 307 | public Couponset(JSONObject json, boolean isUniversal) { |
| 269 | if (json != null) { | 308 | if (json != null) { |
| 270 | - this.uuid = json.optString(UUID); | 309 | + this.uuid = optNullableString(json, UUID); |
| 271 | - this.admin_name = json.optString(ADMIN_NAME); | 310 | + this.admin_name = optNullableString(json, ADMIN_NAME); |
| 272 | - this.created = json.optString(CREATED); | 311 | + this.created = optNullableString(json, CREATED); |
| 273 | - this.updated = json.optString(UPDATED); | 312 | + this.updated = optNullableString(json, UPDATED); |
| 274 | -// this.img = json.optJSONArray(IMG); | ||
| 275 | try { | 313 | try { |
| 276 | this.img = new JSONArray(json.optString(IMG)); | 314 | this.img = new JSONArray(json.optString(IMG)); |
| 277 | } catch (JSONException e) { | 315 | } catch (JSONException e) { |
| 278 | - e.printStackTrace(); | 316 | + this.img = null; |
| 279 | } | 317 | } |
| 280 | this.isNew = json.optBoolean(IS_NEW); | 318 | this.isNew = json.optBoolean(IS_NEW); |
| 281 | this.promoted = json.optBoolean(PROMOTED); | 319 | this.promoted = json.optBoolean(PROMOTED); |
| 282 | this.personalized = json.optBoolean(PERSONALIZED); | 320 | this.personalized = json.optBoolean(PERSONALIZED); |
| 283 | this.locked = json.optBoolean(LOCKED); | 321 | this.locked = json.optBoolean(LOCKED); |
| 284 | - this.unlockAction = json.optString(UNLOCK_ACTION); | 322 | + this.unlockAction = optNullableString(json, UNLOCK_ACTION); |
| 285 | - this.unlockMessage = json.optString(UNLOCK_MESSAGE); | 323 | + this.unlockMessage = optNullableString(json, UNLOCK_MESSAGE); |
| 286 | this.active = json.optBoolean(ACTIVE); | 324 | this.active = json.optBoolean(ACTIVE); |
| 287 | this.buyable = json.optBoolean(BUYABLE); | 325 | this.buyable = json.optBoolean(BUYABLE); |
| 288 | - this.name = json.optString(NAME); | 326 | + this.name = optNullableString(json, NAME); |
| 289 | - this.short_description = json.optString(SHORT_DESCRIPTION); | 327 | + this.short_description = optNullableString(json, SHORT_DESCRIPTION); |
| 290 | - this.discount = json.optString(DISCOUNT); | 328 | + this.discount = optNullableString(json, DISCOUNT); |
| 291 | - this.category = json.optString(CATEGORY); | 329 | + this.category = optNullableString(json, CATEGORY); |
| 292 | - this.terms = json.optString(TERMS); | 330 | + this.terms = optNullableString(json, TERMS); |
| 293 | - this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE); | 331 | + this.discount_type = optNullableString(json, DISCOUNT_TYPE); |
| 294 | - this.couponsetType = json.optString("couponset_type"); | 332 | + this.couponsetType = optNullableString(json, "couponset_type"); |
| 295 | - this.img_preview = json.optString(IMG_PREVIEW); | 333 | + this.img_preview = optNullableString(json, IMG_PREVIEW); |
| 296 | - this.innerText = json.optString(INNER_TEXT); | 334 | + this.innerText = optNullableString(json, INNER_TEXT); |
| 297 | this.final_price = json.isNull(FINAL_PRICE) ? 0.0d : json.optDouble(FINAL_PRICE); | 335 | this.final_price = json.isNull(FINAL_PRICE) ? 0.0d : json.optDouble(FINAL_PRICE); |
| 298 | this.extraFields = json.optJSONObject(EXTRA_FIELDS); | 336 | this.extraFields = json.optJSONObject(EXTRA_FIELDS); |
| 299 | -// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 337 | + this.eligibilities = json.optJSONObject(ELIGIBILITIES); |
| 300 | -// Date newDate = new Date(); | 338 | + this.startDate = optNullableString(json, START_DATE); |
| 301 | -// String tempRedeemDate = json.optString("end_date"); | 339 | + this.endDate = optNullableString(json, END_DATE); |
| 302 | -// try { | 340 | + this.hideCondition = json.optJSONObject(HIDE_CONDITION); |
| 303 | -// newDate = simpleDateFormat.parse(tempRedeemDate); | 341 | + this.showAsBanner = json.optJSONObject(SHOW_AS_BANNER); |
| 304 | -// this.endDate = newDate; | 342 | + this.segment = optNullableString(json, SEGMENT); |
| 305 | -// } catch (ParseException e) { | 343 | + this.offerCategory = optNullableString(json, OFFER_CATEGORY); |
| 306 | -// e.printStackTrace(); | 344 | + this.tagging = json.optJSONObject(TAGGING); |
| 307 | -// } | 345 | + this.regions = json.optJSONArray(REGIONS); |
| 308 | - | ||
| 309 | -// this.app_uuid = json.optString(APP_UUID); | ||
| 310 | -// this.img_preview = json.optString(IMG_PREVIEW); | ||
| 311 | -// this.sorting = json.optInt(SORTING); | ||
| 312 | -// this.visible = json.optBoolean(VISIBLE); | ||
| 313 | -// this.user_generated = json.optBoolean(USER_GENERATED); | ||
| 314 | -// this.limits = json.optJSONObject(LIMITS); | ||
| 315 | -// this.points = json.optInt(POINTS); | ||
| 316 | -// this.points_cause = json.optString(POINTS_CAUSE); | ||
| 317 | -// JSONObject exp = null; | ||
| 318 | -// try { | ||
| 319 | -// exp = new JSONObject(json.optString(EXPIRATION)); | ||
| 320 | -// this.expiration = exp.optString(VALUE); | ||
| 321 | -// } catch (JSONException e) { | ||
| 322 | -// e.printStackTrace(); | ||
| 323 | -// this.expiration = ""; | ||
| 324 | -// } | ||
| 325 | -// this.third_party_service = json.optBoolean(THIRD_PARTY_SERVICE); | ||
| 326 | -// this.description = json.optString(DESCRIPTION); | ||
| 327 | -// this.availability = json.optInt(AVAILABILITY); | ||
| 328 | -// this.merchantUuid = json.optString(MERCHANT_UUID); | ||
| 329 | -// this.innerText = json.optString(INNER_TEXT); | ||
| 330 | -// this.final_price = json.isNull(FINAL_PRICE) ? 0.0d : json.optDouble(FINAL_PRICE); | ||
| 331 | } | 346 | } |
| 332 | } | 347 | } |
| 333 | 348 | ||
| ... | @@ -337,15 +352,33 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -337,15 +352,33 @@ public class Couponset implements Parcelable, Serializable { |
| 337 | this.created = source.readString(); | 352 | this.created = source.readString(); |
| 338 | this.updated = source.readString(); | 353 | this.updated = source.readString(); |
| 339 | this.app_uuid = source.readString(); | 354 | this.app_uuid = source.readString(); |
| 355 | + try { | ||
| 356 | + String imgStr = source.readString(); | ||
| 357 | + this.img = imgStr != null ? new JSONArray(imgStr) : null; | ||
| 358 | + } catch (JSONException e) { | ||
| 359 | + this.img = null; | ||
| 360 | + } | ||
| 340 | this.img_preview = source.readString(); | 361 | this.img_preview = source.readString(); |
| 341 | - this.sorting = source.readInt(); | 362 | + int sortingVal = source.readInt(); |
| 363 | + this.sorting = sortingVal == Integer.MIN_VALUE ? null : sortingVal; | ||
| 342 | this.active = source.readByte() != 0; | 364 | this.active = source.readByte() != 0; |
| 343 | this.visible = source.readByte() != 0; | 365 | this.visible = source.readByte() != 0; |
| 344 | this.buyable = source.readByte() != 0; | 366 | this.buyable = source.readByte() != 0; |
| 345 | this.user_generated = source.readByte() != 0; | 367 | this.user_generated = source.readByte() != 0; |
| 368 | + try { | ||
| 369 | + String limitsStr = source.readString(); | ||
| 370 | + this.limits = limitsStr != null ? new JSONObject(limitsStr) : null; | ||
| 371 | + } catch (JSONException e) { | ||
| 372 | + this.limits = null; | ||
| 373 | + } | ||
| 346 | this.points = source.readInt(); | 374 | this.points = source.readInt(); |
| 347 | this.points_cause = source.readString(); | 375 | this.points_cause = source.readString(); |
| 348 | - this.expiration = source.readString(); | 376 | + try { |
| 377 | + String expirationStr = source.readString(); | ||
| 378 | + this.expiration = expirationStr != null ? new JSONObject(expirationStr) : null; | ||
| 379 | + } catch (JSONException e) { | ||
| 380 | + this.expiration = null; | ||
| 381 | + } | ||
| 349 | this.third_party_service = source.readByte() != 0; | 382 | this.third_party_service = source.readByte() != 0; |
| 350 | this.name = source.readString(); | 383 | this.name = source.readString(); |
| 351 | this.description = source.readString(); | 384 | this.description = source.readString(); |
| ... | @@ -358,12 +391,53 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -358,12 +391,53 @@ public class Couponset implements Parcelable, Serializable { |
| 358 | this.innerText = source.readString(); | 391 | this.innerText = source.readString(); |
| 359 | this.discount_type = source.readString(); | 392 | this.discount_type = source.readString(); |
| 360 | this.final_price = source.readDouble(); | 393 | this.final_price = source.readDouble(); |
| 394 | + this.couponsetType = source.readString(); | ||
| 395 | + try { | ||
| 396 | + String extraFieldsStr = source.readString(); | ||
| 397 | + this.extraFields = extraFieldsStr != null ? new JSONObject(extraFieldsStr) : null; | ||
| 398 | + } catch (JSONException e) { | ||
| 399 | + this.extraFields = null; | ||
| 400 | + } | ||
| 361 | this.isNew = source.readByte() != 0; | 401 | this.isNew = source.readByte() != 0; |
| 362 | this.promoted = source.readByte() != 0; | 402 | this.promoted = source.readByte() != 0; |
| 363 | this.personalized = source.readByte() != 0; | 403 | this.personalized = source.readByte() != 0; |
| 364 | this.locked = source.readByte() != 0; | 404 | this.locked = source.readByte() != 0; |
| 365 | this.unlockAction = source.readString(); | 405 | this.unlockAction = source.readString(); |
| 366 | this.unlockMessage = source.readString(); | 406 | this.unlockMessage = source.readString(); |
| 407 | + try { | ||
| 408 | + String eligibilitiesStr = source.readString(); | ||
| 409 | + this.eligibilities = eligibilitiesStr != null ? new JSONObject(eligibilitiesStr) : null; | ||
| 410 | + } catch (JSONException e) { | ||
| 411 | + this.eligibilities = null; | ||
| 412 | + } | ||
| 413 | + this.startDate = source.readString(); | ||
| 414 | + this.endDate = source.readString(); | ||
| 415 | + try { | ||
| 416 | + String hideConditionStr = source.readString(); | ||
| 417 | + this.hideCondition = hideConditionStr != null ? new JSONObject(hideConditionStr) : null; | ||
| 418 | + } catch (JSONException e) { | ||
| 419 | + this.hideCondition = null; | ||
| 420 | + } | ||
| 421 | + try { | ||
| 422 | + String showAsBannerStr = source.readString(); | ||
| 423 | + this.showAsBanner = showAsBannerStr != null ? new JSONObject(showAsBannerStr) : null; | ||
| 424 | + } catch (JSONException e) { | ||
| 425 | + this.showAsBanner = null; | ||
| 426 | + } | ||
| 427 | + this.segment = source.readString(); | ||
| 428 | + this.offerCategory = source.readString(); | ||
| 429 | + try { | ||
| 430 | + String taggingStr = source.readString(); | ||
| 431 | + this.tagging = taggingStr != null ? new JSONObject(taggingStr) : null; | ||
| 432 | + } catch (JSONException e) { | ||
| 433 | + this.tagging = null; | ||
| 434 | + } | ||
| 435 | + try { | ||
| 436 | + String regionsStr = source.readString(); | ||
| 437 | + this.regions = regionsStr != null ? new JSONArray(regionsStr) : null; | ||
| 438 | + } catch (JSONException e) { | ||
| 439 | + this.regions = null; | ||
| 440 | + } | ||
| 367 | } | 441 | } |
| 368 | 442 | ||
| 369 | @Override | 443 | @Override |
| ... | @@ -373,15 +447,17 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -373,15 +447,17 @@ public class Couponset implements Parcelable, Serializable { |
| 373 | dest.writeString(this.created); | 447 | dest.writeString(this.created); |
| 374 | dest.writeString(this.updated); | 448 | dest.writeString(this.updated); |
| 375 | dest.writeString(this.app_uuid); | 449 | dest.writeString(this.app_uuid); |
| 450 | + dest.writeString(this.img != null ? this.img.toString() : null); | ||
| 376 | dest.writeString(this.img_preview); | 451 | dest.writeString(this.img_preview); |
| 377 | - dest.writeInt(this.sorting); | 452 | + dest.writeInt(this.sorting != null ? this.sorting : Integer.MIN_VALUE); |
| 378 | dest.writeByte((byte) (this.active ? 1 : 0)); | 453 | dest.writeByte((byte) (this.active ? 1 : 0)); |
| 379 | dest.writeByte((byte) (this.visible ? 1 : 0)); | 454 | dest.writeByte((byte) (this.visible ? 1 : 0)); |
| 380 | dest.writeByte((byte) (this.buyable ? 1 : 0)); | 455 | dest.writeByte((byte) (this.buyable ? 1 : 0)); |
| 381 | dest.writeByte((byte) (this.user_generated ? 1 : 0)); | 456 | dest.writeByte((byte) (this.user_generated ? 1 : 0)); |
| 457 | + dest.writeString(this.limits != null ? this.limits.toString() : null); | ||
| 382 | dest.writeInt(this.points); | 458 | dest.writeInt(this.points); |
| 383 | dest.writeString(this.points_cause); | 459 | dest.writeString(this.points_cause); |
| 384 | - dest.writeString(this.expiration); | 460 | + dest.writeString(this.expiration != null ? this.expiration.toString() : null); |
| 385 | dest.writeByte((byte) (this.third_party_service ? 1 : 0)); | 461 | dest.writeByte((byte) (this.third_party_service ? 1 : 0)); |
| 386 | dest.writeString(this.name); | 462 | dest.writeString(this.name); |
| 387 | dest.writeString(this.description); | 463 | dest.writeString(this.description); |
| ... | @@ -394,12 +470,23 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -394,12 +470,23 @@ public class Couponset implements Parcelable, Serializable { |
| 394 | dest.writeString(this.innerText); | 470 | dest.writeString(this.innerText); |
| 395 | dest.writeString(this.discount_type); | 471 | dest.writeString(this.discount_type); |
| 396 | dest.writeDouble(this.final_price); | 472 | dest.writeDouble(this.final_price); |
| 473 | + dest.writeString(this.couponsetType); | ||
| 474 | + dest.writeString(this.extraFields != null ? this.extraFields.toString() : null); | ||
| 397 | dest.writeByte((byte) (this.isNew ? 1 : 0)); | 475 | dest.writeByte((byte) (this.isNew ? 1 : 0)); |
| 398 | dest.writeByte((byte) (this.promoted ? 1 : 0)); | 476 | dest.writeByte((byte) (this.promoted ? 1 : 0)); |
| 399 | dest.writeByte((byte) (this.personalized ? 1 : 0)); | 477 | dest.writeByte((byte) (this.personalized ? 1 : 0)); |
| 400 | dest.writeByte((byte) (this.locked ? 1 : 0)); | 478 | dest.writeByte((byte) (this.locked ? 1 : 0)); |
| 401 | dest.writeString(this.unlockAction); | 479 | dest.writeString(this.unlockAction); |
| 402 | dest.writeString(this.unlockMessage); | 480 | dest.writeString(this.unlockMessage); |
| 481 | + dest.writeString(this.eligibilities != null ? this.eligibilities.toString() : null); | ||
| 482 | + dest.writeString(this.startDate); | ||
| 483 | + dest.writeString(this.endDate); | ||
| 484 | + dest.writeString(this.hideCondition != null ? this.hideCondition.toString() : null); | ||
| 485 | + dest.writeString(this.showAsBanner != null ? this.showAsBanner.toString() : null); | ||
| 486 | + dest.writeString(this.segment); | ||
| 487 | + dest.writeString(this.offerCategory); | ||
| 488 | + dest.writeString(this.tagging != null ? this.tagging.toString() : null); | ||
| 489 | + dest.writeString(this.regions != null ? this.regions.toString() : null); | ||
| 403 | } | 490 | } |
| 404 | 491 | ||
| 405 | /** | 492 | /** |
| ... | @@ -410,41 +497,50 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -410,41 +497,50 @@ public class Couponset implements Parcelable, Serializable { |
| 410 | public JSONObject toJSONObject() { | 497 | public JSONObject toJSONObject() { |
| 411 | JSONObject jObj = new JSONObject(); | 498 | JSONObject jObj = new JSONObject(); |
| 412 | try { | 499 | try { |
| 413 | - jObj.putOpt(UUID, this.uuid); | 500 | + jObj.put(UUID, this.uuid != null ? this.uuid : JSONObject.NULL); |
| 414 | - jObj.putOpt(ADMIN_NAME, this.admin_name); | 501 | + jObj.put(ADMIN_NAME, this.admin_name != null ? this.admin_name : JSONObject.NULL); |
| 415 | - jObj.putOpt(CREATED, this.created); | 502 | + jObj.put(CREATED, this.created != null ? this.created : JSONObject.NULL); |
| 416 | - jObj.putOpt(UPDATED, this.updated); | 503 | + jObj.put(UPDATED, this.updated != null ? this.updated : JSONObject.NULL); |
| 417 | - jObj.putOpt(APP_UUID, this.app_uuid); | 504 | + jObj.put(APP_UUID, this.app_uuid != null ? this.app_uuid : JSONObject.NULL); |
| 418 | - jObj.putOpt(IMG, this.img); | 505 | + jObj.put(IMG, this.img != null ? this.img : JSONObject.NULL); |
| 419 | - jObj.putOpt(IMG_PREVIEW, this.img_preview); | 506 | + jObj.put(IMG_PREVIEW, this.img_preview != null ? this.img_preview : JSONObject.NULL); |
| 420 | - jObj.putOpt(SORTING, this.sorting); | 507 | + jObj.put(SORTING, this.sorting != null ? this.sorting : JSONObject.NULL); |
| 421 | jObj.putOpt(ACTIVE, this.active); | 508 | jObj.putOpt(ACTIVE, this.active); |
| 422 | jObj.putOpt(VISIBLE, this.visible); | 509 | jObj.putOpt(VISIBLE, this.visible); |
| 423 | jObj.putOpt(BUYABLE, this.buyable); | 510 | jObj.putOpt(BUYABLE, this.buyable); |
| 424 | jObj.putOpt(USER_GENERATED, this.user_generated); | 511 | jObj.putOpt(USER_GENERATED, this.user_generated); |
| 425 | - jObj.putOpt(LIMITS, this.limits); | 512 | + jObj.put(LIMITS, this.limits != null ? this.limits : JSONObject.NULL); |
| 426 | jObj.putOpt(POINTS, this.points); | 513 | jObj.putOpt(POINTS, this.points); |
| 427 | - jObj.putOpt(POINTS_CAUSE, this.points_cause); | 514 | + jObj.put(POINTS_CAUSE, this.points_cause != null ? this.points_cause : JSONObject.NULL); |
| 428 | - jObj.putOpt(EXPIRATION, this.expiration); | 515 | + jObj.put(EXPIRATION, this.expiration != null ? this.expiration : JSONObject.NULL); |
| 429 | jObj.putOpt(THIRD_PARTY_SERVICE, this.third_party_service); | 516 | jObj.putOpt(THIRD_PARTY_SERVICE, this.third_party_service); |
| 430 | - jObj.putOpt(NAME, this.name); | 517 | + jObj.put(NAME, this.name != null ? this.name : JSONObject.NULL); |
| 431 | - jObj.putOpt(DESCRIPTION, this.description); | 518 | + jObj.put(DESCRIPTION, this.description != null ? this.description : JSONObject.NULL); |
| 432 | - jObj.putOpt(SHORT_DESCRIPTION, this.short_description); | 519 | + jObj.put(SHORT_DESCRIPTION, this.short_description != null ? this.short_description : JSONObject.NULL); |
| 433 | - jObj.putOpt(DISCOUNT, this.discount); | 520 | + jObj.put(DISCOUNT, this.discount != null ? this.discount : JSONObject.NULL); |
| 434 | - jObj.putOpt(CATEGORY, this.category); | 521 | + jObj.put(CATEGORY, this.category != null ? this.category : JSONObject.NULL); |
| 435 | - jObj.putOpt(TERMS, this.terms); | 522 | + jObj.put(TERMS, this.terms != null ? this.terms : JSONObject.NULL); |
| 436 | jObj.putOpt(AVAILABILITY, this.availability); | 523 | jObj.putOpt(AVAILABILITY, this.availability); |
| 437 | - jObj.putOpt(MERCHANT_UUID, this.merchantUuid); | 524 | + jObj.put(MERCHANT_UUID, this.merchantUuid != null ? this.merchantUuid : JSONObject.NULL); |
| 438 | - jObj.putOpt(INNER_TEXT, this.innerText); | 525 | + jObj.put(INNER_TEXT, this.innerText != null ? this.innerText : JSONObject.NULL); |
| 439 | - jObj.putOpt(DISCOUNT_TYPE, this.discount_type); | 526 | + jObj.put(DISCOUNT_TYPE, this.discount_type != null ? this.discount_type : JSONObject.NULL); |
| 440 | jObj.putOpt(FINAL_PRICE, this.final_price); | 527 | jObj.putOpt(FINAL_PRICE, this.final_price); |
| 441 | - jObj.putOpt(EXTRA_FIELDS, this.extraFields); | 528 | + jObj.put(EXTRA_FIELDS, this.extraFields != null ? this.extraFields : JSONObject.NULL); |
| 442 | jObj.putOpt(IS_NEW, this.isNew); | 529 | jObj.putOpt(IS_NEW, this.isNew); |
| 443 | jObj.putOpt(PROMOTED, this.promoted); | 530 | jObj.putOpt(PROMOTED, this.promoted); |
| 444 | jObj.putOpt(PERSONALIZED, this.personalized); | 531 | jObj.putOpt(PERSONALIZED, this.personalized); |
| 445 | jObj.putOpt(LOCKED, this.locked); | 532 | jObj.putOpt(LOCKED, this.locked); |
| 446 | - jObj.putOpt(UNLOCK_ACTION, this.unlockAction); | 533 | + jObj.put(UNLOCK_ACTION, this.unlockAction != null ? this.unlockAction : JSONObject.NULL); |
| 447 | - jObj.putOpt(UNLOCK_MESSAGE, this.unlockMessage); | 534 | + jObj.put(UNLOCK_MESSAGE, this.unlockMessage != null ? this.unlockMessage : JSONObject.NULL); |
| 535 | + jObj.put(ELIGIBILITIES, this.eligibilities != null ? this.eligibilities : JSONObject.NULL); | ||
| 536 | + jObj.put(START_DATE, this.startDate != null ? this.startDate : JSONObject.NULL); | ||
| 537 | + jObj.put(END_DATE, this.endDate != null ? this.endDate : JSONObject.NULL); | ||
| 538 | + jObj.put(HIDE_CONDITION, this.hideCondition != null ? this.hideCondition : JSONObject.NULL); | ||
| 539 | + jObj.put(SHOW_AS_BANNER, this.showAsBanner != null ? this.showAsBanner : JSONObject.NULL); | ||
| 540 | + jObj.put(SEGMENT, this.segment != null ? this.segment : JSONObject.NULL); | ||
| 541 | + jObj.put(OFFER_CATEGORY, this.offerCategory != null ? this.offerCategory : JSONObject.NULL); | ||
| 542 | + jObj.put(TAGGING, this.tagging != null ? this.tagging : JSONObject.NULL); | ||
| 543 | + jObj.put(REGIONS, this.regions != null ? this.regions : JSONObject.NULL); | ||
| 448 | } catch (JSONException e) { | 544 | } catch (JSONException e) { |
| 449 | if (WarpConstants.DEBUG) { | 545 | if (WarpConstants.DEBUG) { |
| 450 | e.printStackTrace(); | 546 | e.printStackTrace(); |
| ... | @@ -454,6 +550,30 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -454,6 +550,30 @@ public class Couponset implements Parcelable, Serializable { |
| 454 | } | 550 | } |
| 455 | 551 | ||
| 456 | /** | 552 | /** |
| 553 | + * Helper to get the expiration value string from the expiration JSONObject | ||
| 554 | + * | ||
| 555 | + * @return The expiration value string, or null | ||
| 556 | + */ | ||
| 557 | + public String getExpirationValue() { | ||
| 558 | + if (expiration != null) { | ||
| 559 | + return expiration.optString("value", null); | ||
| 560 | + } | ||
| 561 | + return null; | ||
| 562 | + } | ||
| 563 | + | ||
| 564 | + /** | ||
| 565 | + * Helper to get the expiration type from the expiration JSONObject | ||
| 566 | + * | ||
| 567 | + * @return The expiration type string, or null | ||
| 568 | + */ | ||
| 569 | + public String getExpirationType() { | ||
| 570 | + if (expiration != null) { | ||
| 571 | + return expiration.optString("type", null); | ||
| 572 | + } | ||
| 573 | + return null; | ||
| 574 | + } | ||
| 575 | + | ||
| 576 | + /** | ||
| 457 | * String representation of the Couponset, as a JSON object | 577 | * String representation of the Couponset, as a JSON object |
| 458 | * | 578 | * |
| 459 | * @return A String representation of JSON object | 579 | * @return A String representation of JSON object |
| ... | @@ -465,7 +585,7 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -465,7 +585,7 @@ public class Couponset implements Parcelable, Serializable { |
| 465 | } | 585 | } |
| 466 | 586 | ||
| 467 | /** | 587 | /** |
| 468 | - * String representation of the Address, as a human readable JSON object | 588 | + * String representation of the Couponset, as a human readable JSON object |
| 469 | * | 589 | * |
| 470 | * @return A human readable String representation of JSON object | 590 | * @return A human readable String representation of JSON object |
| 471 | */ | 591 | */ |
| ... | @@ -483,7 +603,6 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -483,7 +603,6 @@ public class Couponset implements Parcelable, Serializable { |
| 483 | // Getters | 603 | // Getters |
| 484 | // ================================================================================ | 604 | // ================================================================================ |
| 485 | 605 | ||
| 486 | - | ||
| 487 | public String getUuid() { | 606 | public String getUuid() { |
| 488 | return uuid; | 607 | return uuid; |
| 489 | } | 608 | } |
| ... | @@ -492,6 +611,10 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -492,6 +611,10 @@ public class Couponset implements Parcelable, Serializable { |
| 492 | return admin_name; | 611 | return admin_name; |
| 493 | } | 612 | } |
| 494 | 613 | ||
| 614 | + public String getAdmin_name() { | ||
| 615 | + return admin_name; | ||
| 616 | + } | ||
| 617 | + | ||
| 495 | public String getCreated() { | 618 | public String getCreated() { |
| 496 | return created; | 619 | return created; |
| 497 | } | 620 | } |
| ... | @@ -512,7 +635,11 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -512,7 +635,11 @@ public class Couponset implements Parcelable, Serializable { |
| 512 | return img_preview; | 635 | return img_preview; |
| 513 | } | 636 | } |
| 514 | 637 | ||
| 515 | - public int getSorting() { | 638 | + public String getImg_preview() { |
| 639 | + return img_preview; | ||
| 640 | + } | ||
| 641 | + | ||
| 642 | + public Integer getSorting() { | ||
| 516 | return sorting; | 643 | return sorting; |
| 517 | } | 644 | } |
| 518 | 645 | ||
| ... | @@ -544,7 +671,7 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -544,7 +671,7 @@ public class Couponset implements Parcelable, Serializable { |
| 544 | return points_cause; | 671 | return points_cause; |
| 545 | } | 672 | } |
| 546 | 673 | ||
| 547 | - public String getExpiration() { | 674 | + public JSONObject getExpiration() { |
| 548 | return expiration; | 675 | return expiration; |
| 549 | } | 676 | } |
| 550 | 677 | ||
| ... | @@ -564,6 +691,10 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -564,6 +691,10 @@ public class Couponset implements Parcelable, Serializable { |
| 564 | return short_description; | 691 | return short_description; |
| 565 | } | 692 | } |
| 566 | 693 | ||
| 694 | + public String getShort_description() { | ||
| 695 | + return short_description; | ||
| 696 | + } | ||
| 697 | + | ||
| 567 | public String getDiscount() { | 698 | public String getDiscount() { |
| 568 | return discount; | 699 | return discount; |
| 569 | } | 700 | } |
| ... | @@ -596,6 +727,82 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -596,6 +727,82 @@ public class Couponset implements Parcelable, Serializable { |
| 596 | return final_price; | 727 | return final_price; |
| 597 | } | 728 | } |
| 598 | 729 | ||
| 730 | + public String getCouponsetType() { | ||
| 731 | + return couponsetType; | ||
| 732 | + } | ||
| 733 | + | ||
| 734 | + public JSONObject getExtraFields() { | ||
| 735 | + return extraFields; | ||
| 736 | + } | ||
| 737 | + | ||
| 738 | + public boolean isNew() { | ||
| 739 | + return isNew; | ||
| 740 | + } | ||
| 741 | + | ||
| 742 | + public boolean isPromoted() { | ||
| 743 | + return promoted; | ||
| 744 | + } | ||
| 745 | + | ||
| 746 | + public boolean isPersonalized() { | ||
| 747 | + return personalized; | ||
| 748 | + } | ||
| 749 | + | ||
| 750 | + public boolean isLocked() { | ||
| 751 | + return locked; | ||
| 752 | + } | ||
| 753 | + | ||
| 754 | + public String getUnlockAction() { | ||
| 755 | + return unlockAction; | ||
| 756 | + } | ||
| 757 | + | ||
| 758 | + public String getUnlockMessage() { | ||
| 759 | + return unlockMessage; | ||
| 760 | + } | ||
| 761 | + | ||
| 762 | + public JSONObject getEligibilities() { | ||
| 763 | + return eligibilities; | ||
| 764 | + } | ||
| 765 | + | ||
| 766 | + public String getStartDate() { | ||
| 767 | + return startDate; | ||
| 768 | + } | ||
| 769 | + | ||
| 770 | + public String getEndDate() { | ||
| 771 | + return endDate; | ||
| 772 | + } | ||
| 773 | + | ||
| 774 | + public JSONObject getHideCondition() { | ||
| 775 | + return hideCondition; | ||
| 776 | + } | ||
| 777 | + | ||
| 778 | + public JSONObject getShowAsBanner() { | ||
| 779 | + return showAsBanner; | ||
| 780 | + } | ||
| 781 | + | ||
| 782 | + public String getSegment() { | ||
| 783 | + return segment; | ||
| 784 | + } | ||
| 785 | + | ||
| 786 | + public String getOfferCategory() { | ||
| 787 | + return offerCategory; | ||
| 788 | + } | ||
| 789 | + | ||
| 790 | + public JSONObject getTagging() { | ||
| 791 | + return tagging; | ||
| 792 | + } | ||
| 793 | + | ||
| 794 | + public JSONArray getRegions() { | ||
| 795 | + return regions; | ||
| 796 | + } | ||
| 797 | + | ||
| 798 | + public Merchant getMerchant() { | ||
| 799 | + return merchant; | ||
| 800 | + } | ||
| 801 | + | ||
| 802 | + // ================================================================================ | ||
| 803 | + // Setters | ||
| 804 | + // ================================================================================ | ||
| 805 | + | ||
| 599 | public void setUuid(String uuid) { | 806 | public void setUuid(String uuid) { |
| 600 | this.uuid = uuid; | 807 | this.uuid = uuid; |
| 601 | } | 808 | } |
| ... | @@ -624,7 +831,7 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -624,7 +831,7 @@ public class Couponset implements Parcelable, Serializable { |
| 624 | this.img_preview = img_preview; | 831 | this.img_preview = img_preview; |
| 625 | } | 832 | } |
| 626 | 833 | ||
| 627 | - public void setSorting(int sorting) { | 834 | + public void setSorting(Integer sorting) { |
| 628 | this.sorting = sorting; | 835 | this.sorting = sorting; |
| 629 | } | 836 | } |
| 630 | 837 | ||
| ... | @@ -656,7 +863,7 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -656,7 +863,7 @@ public class Couponset implements Parcelable, Serializable { |
| 656 | this.points_cause = points_cause; | 863 | this.points_cause = points_cause; |
| 657 | } | 864 | } |
| 658 | 865 | ||
| 659 | - public void setExpiration(String expiration) { | 866 | + public void setExpiration(JSONObject expiration) { |
| 660 | this.expiration = expiration; | 867 | this.expiration = expiration; |
| 661 | } | 868 | } |
| 662 | 869 | ||
| ... | @@ -708,81 +915,76 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -708,81 +915,76 @@ public class Couponset implements Parcelable, Serializable { |
| 708 | this.final_price = final_price; | 915 | this.final_price = final_price; |
| 709 | } | 916 | } |
| 710 | 917 | ||
| 711 | - public String getCouponsetType() { | ||
| 712 | - return couponsetType; | ||
| 713 | - } | ||
| 714 | - | ||
| 715 | public void setCouponsetType(String couponsetType) { | 918 | public void setCouponsetType(String couponsetType) { |
| 716 | this.couponsetType = couponsetType; | 919 | this.couponsetType = couponsetType; |
| 717 | } | 920 | } |
| 718 | 921 | ||
| 719 | - public String getAdmin_name() { | 922 | + public void setExtraFields(JSONObject extraFields) { |
| 720 | - return admin_name; | 923 | + this.extraFields = extraFields; |
| 721 | } | 924 | } |
| 722 | 925 | ||
| 723 | - public JSONObject getExtraFields() { | 926 | + public void setNew(boolean aNew) { |
| 724 | - return extraFields; | 927 | + isNew = aNew; |
| 725 | } | 928 | } |
| 726 | 929 | ||
| 727 | - public void setExtraFields(JSONObject extraFields) { | 930 | + public void setPromoted(boolean promoted) { |
| 728 | - this.extraFields = extraFields; | 931 | + this.promoted = promoted; |
| 729 | } | 932 | } |
| 730 | 933 | ||
| 731 | - public String getShort_description() { | 934 | + public void setPersonalized(boolean personalized) { |
| 732 | - return short_description; | 935 | + this.personalized = personalized; |
| 733 | } | 936 | } |
| 734 | 937 | ||
| 735 | - public String getImg_preview() { | 938 | + public void setLocked(boolean locked) { |
| 736 | - return img_preview; | 939 | + this.locked = locked; |
| 737 | } | 940 | } |
| 738 | 941 | ||
| 739 | - | 942 | + public void setUnlockAction(String unlockAction) { |
| 740 | - public boolean isNew() { | 943 | + this.unlockAction = unlockAction; |
| 741 | - return isNew; | ||
| 742 | } | 944 | } |
| 743 | 945 | ||
| 744 | - public void setNew(boolean aNew) { | 946 | + public void setUnlockMessage(String unlockMessage) { |
| 745 | - isNew = aNew; | 947 | + this.unlockMessage = unlockMessage; |
| 746 | } | 948 | } |
| 747 | 949 | ||
| 748 | - public boolean isPromoted() { | 950 | + public void setEligibilities(JSONObject eligibilities) { |
| 749 | - return promoted; | 951 | + this.eligibilities = eligibilities; |
| 750 | } | 952 | } |
| 751 | 953 | ||
| 752 | - public void setPromoted(boolean promoted) { | 954 | + public void setStartDate(String startDate) { |
| 753 | - this.promoted = promoted; | 955 | + this.startDate = startDate; |
| 754 | } | 956 | } |
| 755 | 957 | ||
| 756 | - public boolean isPersonalized() { | 958 | + public void setEndDate(String endDate) { |
| 757 | - return personalized; | 959 | + this.endDate = endDate; |
| 758 | } | 960 | } |
| 759 | 961 | ||
| 760 | - public void setPersonalized(boolean personalized) { | 962 | + public void setHideCondition(JSONObject hideCondition) { |
| 761 | - this.personalized = personalized; | 963 | + this.hideCondition = hideCondition; |
| 762 | } | 964 | } |
| 763 | 965 | ||
| 764 | - public boolean isLocked() { | 966 | + public void setShowAsBanner(JSONObject showAsBanner) { |
| 765 | - return locked; | 967 | + this.showAsBanner = showAsBanner; |
| 766 | } | 968 | } |
| 767 | 969 | ||
| 768 | - public void setLocked(boolean locked) { | 970 | + public void setSegment(String segment) { |
| 769 | - this.locked = locked; | 971 | + this.segment = segment; |
| 770 | } | 972 | } |
| 771 | 973 | ||
| 772 | - public String getUnlockAction() { | 974 | + public void setOfferCategory(String offerCategory) { |
| 773 | - return unlockAction; | 975 | + this.offerCategory = offerCategory; |
| 774 | } | 976 | } |
| 775 | 977 | ||
| 776 | - public void setUnlockAction(String unlockAction) { | 978 | + public void setTagging(JSONObject tagging) { |
| 777 | - this.unlockAction = unlockAction; | 979 | + this.tagging = tagging; |
| 778 | } | 980 | } |
| 779 | 981 | ||
| 780 | - public String getUnlockMessage() { | 982 | + public void setRegions(JSONArray regions) { |
| 781 | - return unlockMessage; | 983 | + this.regions = regions; |
| 782 | } | 984 | } |
| 783 | 985 | ||
| 784 | - public void setUnlockMessage(String unlockMessage) { | 986 | + public void setMerchant(Merchant merchant) { |
| 785 | - this.unlockMessage = unlockMessage; | 987 | + this.merchant = merchant; |
| 786 | } | 988 | } |
| 787 | 989 | ||
| 788 | @Override | 990 | @Override | ... | ... |
| ... | @@ -46,7 +46,7 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -46,7 +46,7 @@ public class Merchant implements Parcelable, Serializable { |
| 46 | 46 | ||
| 47 | private static final long serialVersionUID = -4754964462459705285L; | 47 | private static final long serialVersionUID = -4754964462459705285L; |
| 48 | 48 | ||
| 49 | - /* Constants used to export the campaign in JSON formal and vice versa */ | 49 | + /* Constants used to export the Merchant in JSON formal and vice versa */ |
| 50 | 50 | ||
| 51 | private static final String ADDRESS = "address"; | 51 | private static final String ADDRESS = "address"; |
| 52 | private static final String ID = "id"; | 52 | private static final String ID = "id"; |
| ... | @@ -73,122 +73,157 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -73,122 +73,157 @@ public class Merchant implements Parcelable, Serializable { |
| 73 | private static final String CATEGORY_UUID = "category_uuid"; | 73 | private static final String CATEGORY_UUID = "category_uuid"; |
| 74 | private static final String CREATED = "created"; | 74 | private static final String CREATED = "created"; |
| 75 | private static final String PARENT = "parent"; | 75 | private static final String PARENT = "parent"; |
| 76 | - private static final String IMG = "img"; // JSONArray | 76 | + private static final String IMG = "img"; |
| 77 | private static final String IMG_PREVIEW = "img_preview"; | 77 | private static final String IMG_PREVIEW = "img_preview"; |
| 78 | private static final String ADMIN_NAME = "admin_name"; | 78 | private static final String ADMIN_NAME = "admin_name"; |
| 79 | - private static final String SORTING = "sorting"; // int | 79 | + private static final String SORTING = "sorting"; |
| 80 | private static final String BODY = "body"; | 80 | private static final String BODY = "body"; |
| 81 | private static final String OWNER_NAME = "owner_name"; | 81 | private static final String OWNER_NAME = "owner_name"; |
| 82 | private static final String PREVIEW = "preview"; | 82 | private static final String PREVIEW = "preview"; |
| 83 | - private static final String MERCHANT_METADATA = "merchant_metadata"; // JSONObject | 83 | + private static final String MERCHANT_METADATA = "merchant_metadata"; |
| 84 | - private static final String PROMOTED = "promoted"; // boolean | 84 | + private static final String PROMOTED = "promoted"; |
| 85 | - private static final String DISTANCE = "distance"; // int | 85 | + private static final String DISTANCE = "distance"; |
| 86 | - private static final String DEFAULT_SHOWN = "default_shown"; // boolean | 86 | + private static final String DEFAULT_SHOWN = "default_shown"; |
| 87 | - private static final String HIDDEN = "hidden"; // boolean | 87 | + private static final String HIDDEN = "hidden"; |
| 88 | - private static final String WORKING_HOURS = "working_hours"; // JSONObject | 88 | + private static final String WORKING_HOURS = "working_hours"; |
| 89 | - private static final String TAGS = "tags"; // JSONArray | 89 | + private static final String TAGS = "tags"; |
| 90 | - private static final String PRODUCT = "product"; // JSONObject | 90 | + private static final String PRODUCT = "product"; |
| 91 | - | 91 | + private static final String TELEPHONES_RAW = "telephones_raw"; |
| 92 | - /* Member variables of the Campaign object */ | 92 | + private static final String YEAR_ESTABLISHED = "year_established"; |
| 93 | - | 93 | + private static final String CURRENCY = "currency"; |
| 94 | - private String address = ""; | 94 | + private static final String BANK = "bank"; |
| 95 | - private String id = ""; | 95 | + private static final String MIN_ORDER_PRICE = "min_order_price"; |
| 96 | - private String store_id = ""; | 96 | + private static final String MIN_ORDER_PRICE_TAKEAWAY = "min_order_price_takeaway"; |
| 97 | - private String name = ""; | 97 | + private static final String MIN_PRICE = "min_price"; |
| 98 | - private String logo = ""; | 98 | + private static final String MAX_PRICE = "max_price"; |
| 99 | - private String website = ""; | 99 | + private static final String URL_NAME = "url_name"; |
| 100 | - private String email = ""; | 100 | + |
| 101 | - private String telephone = ""; | 101 | + /* Member variables of the Merchant object */ |
| 102 | - private String category = ""; | 102 | + |
| 103 | - private String description = ""; | 103 | + private String address; |
| 104 | - private String short_description = ""; | 104 | + private String id; |
| 105 | - private String region = ""; | 105 | + private String store_id; |
| 106 | - private double latitude = 0.0; | 106 | + private String name; |
| 107 | - private double longitude = 0.0; | 107 | + private String logo; |
| 108 | - private String image = ""; | 108 | + private String website; |
| 109 | - private JSONObject extra_fields = new JSONObject(); | 109 | + private String email; |
| 110 | + private String telephone; | ||
| 111 | + private String category; | ||
| 112 | + private String description; | ||
| 113 | + private String short_description; | ||
| 114 | + private String region; | ||
| 115 | + private Double latitude; | ||
| 116 | + private Double longitude; | ||
| 117 | + private String image; | ||
| 118 | + private JSONObject extra_fields; | ||
| 110 | private boolean active; | 119 | private boolean active; |
| 111 | - private String city = ""; | 120 | + private String city; |
| 112 | - private String country = ""; | 121 | + private String country; |
| 113 | - private String postal_code = ""; | 122 | + private String postal_code; |
| 114 | - private String vat = ""; | 123 | + private String vat; |
| 115 | - private String uuid = ""; | 124 | + private String uuid; |
| 116 | - private String category_uuid = ""; | 125 | + private String category_uuid; |
| 117 | - private String created = ""; | 126 | + private String created; |
| 118 | - private String parent = ""; | 127 | + private String parent; |
| 119 | - private JSONArray img = new JSONArray(); | 128 | + private JSONArray img; |
| 120 | - private String img_preview = ""; | 129 | + private String img_preview; |
| 121 | - private String admin_name = ""; | 130 | + private String admin_name; |
| 122 | - private int sorting = 0; | 131 | + private Integer sorting; |
| 123 | - private String body = ""; | 132 | + private String body; |
| 124 | - private String owner_name = ""; | 133 | + private String owner_name; |
| 125 | - private String preview = ""; | 134 | + private String preview; |
| 126 | - private JSONObject merchant_metadata = new JSONObject(); | 135 | + private JSONObject merchant_metadata; |
| 127 | - private boolean promoted = false; | 136 | + private boolean promoted; |
| 128 | - private int distance = 0; | 137 | + private Integer distance; |
| 129 | - private boolean default_shown = false; | 138 | + private boolean default_shown; |
| 130 | - private boolean hidden = false; | 139 | + private boolean hidden; |
| 131 | - private JSONObject working_hours = new JSONObject(); | 140 | + private String working_hours; |
| 132 | - private JSONArray tags = new JSONArray(); | 141 | + private JSONArray tags; |
| 133 | - private JSONObject product = new JSONObject(); | 142 | + private JSONObject product; |
| 143 | + private String telephonesRaw; | ||
| 144 | + private String yearEstablished; | ||
| 145 | + private String currency; | ||
| 146 | + private String bank; | ||
| 147 | + private String minOrderPrice; | ||
| 148 | + private String minOrderPriceTakeaway; | ||
| 149 | + private String minPrice; | ||
| 150 | + private String maxPrice; | ||
| 151 | + private String urlName; | ||
| 152 | + | ||
| 153 | + /** | ||
| 154 | + * Helper method to get a nullable String from a JSONObject. | ||
| 155 | + * Returns null if the JSON value is null, otherwise returns the String value. | ||
| 156 | + */ | ||
| 157 | + private static String optNullableString(JSONObject json, String key) { | ||
| 158 | + return json.isNull(key) ? null : json.optString(key); | ||
| 159 | + } | ||
| 134 | 160 | ||
| 135 | public Merchant() { | 161 | public Merchant() { |
| 136 | - this.address = ""; | 162 | + this.address = null; |
| 137 | - this.id = ""; | 163 | + this.id = null; |
| 138 | - this.store_id = ""; | 164 | + this.store_id = null; |
| 139 | - this.name = ""; | 165 | + this.name = null; |
| 140 | - this.logo = ""; | 166 | + this.logo = null; |
| 141 | - this.website = ""; | 167 | + this.website = null; |
| 142 | - this.email = ""; | 168 | + this.email = null; |
| 143 | - this.telephone = ""; | 169 | + this.telephone = null; |
| 144 | - this.category = ""; | 170 | + this.category = null; |
| 145 | - this.description = ""; | 171 | + this.description = null; |
| 146 | - this.short_description = ""; | 172 | + this.short_description = null; |
| 147 | - this.region = ""; | 173 | + this.region = null; |
| 148 | - this.latitude = 0.0; | 174 | + this.latitude = null; |
| 149 | - this.longitude = 0.0; | 175 | + this.longitude = null; |
| 150 | - this.image = ""; | 176 | + this.image = null; |
| 151 | - this.extra_fields = new JSONObject(); | 177 | + this.extra_fields = null; |
| 152 | this.active = true; | 178 | this.active = true; |
| 153 | - this.city = ""; | 179 | + this.city = null; |
| 154 | - this.country = ""; | 180 | + this.country = null; |
| 155 | - this.postal_code = ""; | 181 | + this.postal_code = null; |
| 156 | - this.vat = ""; | 182 | + this.vat = null; |
| 157 | - this.uuid = ""; | 183 | + this.uuid = null; |
| 158 | - this.category_uuid = ""; | 184 | + this.category_uuid = null; |
| 159 | - this.created = ""; | 185 | + this.created = null; |
| 160 | - this.parent = ""; | 186 | + this.parent = null; |
| 161 | - this.img = new JSONArray(); | 187 | + this.img = null; |
| 162 | - this.img_preview = ""; | 188 | + this.img_preview = null; |
| 163 | - this.admin_name = ""; | 189 | + this.admin_name = null; |
| 164 | - this.sorting = 0; | 190 | + this.sorting = null; |
| 165 | - this.body = ""; | 191 | + this.body = null; |
| 166 | - this.owner_name = ""; | 192 | + this.owner_name = null; |
| 167 | - this.preview = ""; | 193 | + this.preview = null; |
| 168 | - this.merchant_metadata = new JSONObject(); | 194 | + this.merchant_metadata = null; |
| 169 | this.promoted = false; | 195 | this.promoted = false; |
| 170 | - this.distance = 0; | 196 | + this.distance = null; |
| 171 | this.default_shown = true; | 197 | this.default_shown = true; |
| 172 | this.hidden = false; | 198 | this.hidden = false; |
| 173 | - this.working_hours = new JSONObject(); | 199 | + this.working_hours = null; |
| 174 | - this.tags = new JSONArray(); | 200 | + this.tags = null; |
| 175 | - this.product = new JSONObject(); | 201 | + this.product = null; |
| 202 | + this.telephonesRaw = null; | ||
| 203 | + this.yearEstablished = null; | ||
| 204 | + this.currency = null; | ||
| 205 | + this.bank = null; | ||
| 206 | + this.minOrderPrice = null; | ||
| 207 | + this.minOrderPriceTakeaway = null; | ||
| 208 | + this.minPrice = null; | ||
| 209 | + this.maxPrice = null; | ||
| 210 | + this.urlName = null; | ||
| 176 | } | 211 | } |
| 177 | 212 | ||
| 178 | public Merchant(boolean isUniversal) { | 213 | public Merchant(boolean isUniversal) { |
| 179 | - this.address = ""; | 214 | + this.address = null; |
| 180 | - this.city = ""; | 215 | + this.city = null; |
| 181 | - this.body = ""; | 216 | + this.body = null; |
| 182 | - this.logo = ""; | 217 | + this.logo = null; |
| 183 | - this.country = ""; | 218 | + this.country = null; |
| 184 | - this.name = ""; | 219 | + this.name = null; |
| 185 | - this.postal_code = ""; | 220 | + this.postal_code = null; |
| 186 | - this.region = ""; | 221 | + this.region = null; |
| 187 | - this.telephone = ""; | 222 | + this.telephone = null; |
| 188 | - this.merchant_metadata = new JSONObject(); | 223 | + this.merchant_metadata = null; |
| 189 | - this.admin_name = ""; | 224 | + this.admin_name = null; |
| 190 | - this.img_preview = ""; | 225 | + this.img_preview = null; |
| 191 | - this.website = ""; | 226 | + this.website = null; |
| 192 | } | 227 | } |
| 193 | 228 | ||
| 194 | /** | 229 | /** |
| ... | @@ -209,96 +244,73 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -209,96 +244,73 @@ public class Merchant implements Parcelable, Serializable { |
| 209 | */ | 244 | */ |
| 210 | public Merchant(JSONObject json) { | 245 | public Merchant(JSONObject json) { |
| 211 | if (json != null) { | 246 | if (json != null) { |
| 212 | - this.address = json.isNull(ADDRESS) ? "" : json.optString(ADDRESS); | 247 | + this.address = optNullableString(json, ADDRESS); |
| 213 | - this.id = json.optString(ID); | 248 | + this.id = optNullableString(json, ID); |
| 214 | - this.store_id = json.optString(STORE_ID); | 249 | + this.store_id = optNullableString(json, STORE_ID); |
| 215 | - this.name = json.isNull(NAME) ? "" : json.optString(NAME); | 250 | + this.name = optNullableString(json, NAME); |
| 216 | - this.logo = json.optString(LOGO); | 251 | + this.logo = optNullableString(json, LOGO); |
| 217 | - this.website = json.optString(WEBSITE); | 252 | + this.website = optNullableString(json, WEBSITE); |
| 218 | - this.email = json.optString(EMAIL); | 253 | + this.email = optNullableString(json, EMAIL); |
| 219 | - this.telephone = json.isNull(TELEPHONE) ? "" : json.optString(TELEPHONE); | 254 | + this.telephone = optNullableString(json, TELEPHONE); |
| 220 | - this.category = json.optString(CATEGORY); | 255 | + this.category = optNullableString(json, CATEGORY); |
| 221 | - this.description = json.optString(DESCRIPTION); | 256 | + this.description = optNullableString(json, DESCRIPTION); |
| 222 | - this.short_description = json.optString(SHORT_DESCRIPTION); | 257 | + this.short_description = optNullableString(json, SHORT_DESCRIPTION); |
| 223 | - this.region = json.optString(REGION); | 258 | + this.region = optNullableString(json, REGION); |
| 224 | - this.latitude = json.isNull(LAT) ? 0.0 : json.optDouble(LAT); | 259 | + this.latitude = json.isNull(LAT) ? null : json.optDouble(LAT); |
| 225 | - this.longitude = json.isNull(LON) ? 0.0 : json.optDouble(LON); | 260 | + this.longitude = json.isNull(LON) ? null : json.optDouble(LON); |
| 226 | - this.image = json.optString(IMAGE); | 261 | + this.image = optNullableString(json, IMAGE); |
| 227 | this.extra_fields = json.optJSONObject(EXTRA_FIELDS); | 262 | this.extra_fields = json.optJSONObject(EXTRA_FIELDS); |
| 228 | this.active = json.optBoolean(ACTIVE); | 263 | this.active = json.optBoolean(ACTIVE); |
| 229 | - this.city = json.optString(CITY); | 264 | + this.city = optNullableString(json, CITY); |
| 230 | - this.country = json.optString(COUNTRY); | 265 | + this.country = optNullableString(json, COUNTRY); |
| 231 | - this.postal_code = json.optString(POSTAL_CODE); | 266 | + this.postal_code = optNullableString(json, POSTAL_CODE); |
| 232 | - this.vat = json.optString(VAT); | 267 | + this.vat = optNullableString(json, VAT); |
| 233 | - this.uuid = json.optString(UUID); | 268 | + this.uuid = optNullableString(json, UUID); |
| 234 | - this.category_uuid = json.optString(CATEGORY_UUID); | 269 | + this.category_uuid = optNullableString(json, CATEGORY_UUID); |
| 235 | - this.created = json.optString(CREATED); | 270 | + this.created = optNullableString(json, CREATED); |
| 236 | - this.parent = json.optString(PARENT); | 271 | + this.parent = optNullableString(json, PARENT); |
| 237 | this.img = json.optJSONArray(IMG); | 272 | this.img = json.optJSONArray(IMG); |
| 238 | - this.img_preview = json.optString(IMG_PREVIEW); | 273 | + this.img_preview = optNullableString(json, IMG_PREVIEW); |
| 239 | - this.admin_name = json.optString(ADMIN_NAME); | 274 | + this.admin_name = optNullableString(json, ADMIN_NAME); |
| 240 | - this.sorting = json.optInt(SORTING); | 275 | + this.sorting = json.isNull(SORTING) ? null : json.optInt(SORTING); |
| 241 | - this.body = json.optString(BODY); | 276 | + this.body = optNullableString(json, BODY); |
| 242 | - this.owner_name = json.optString(OWNER_NAME); | 277 | + this.owner_name = optNullableString(json, OWNER_NAME); |
| 243 | - this.preview = json.optString(PREVIEW); | 278 | + this.preview = optNullableString(json, PREVIEW); |
| 244 | this.merchant_metadata = json.optJSONObject(MERCHANT_METADATA); | 279 | this.merchant_metadata = json.optJSONObject(MERCHANT_METADATA); |
| 245 | this.promoted = json.optBoolean(PROMOTED); | 280 | this.promoted = json.optBoolean(PROMOTED); |
| 246 | - this.distance = json.optInt(DISTANCE); | 281 | + this.distance = json.isNull(DISTANCE) ? null : json.optInt(DISTANCE); |
| 247 | this.default_shown = json.optBoolean(DEFAULT_SHOWN); | 282 | this.default_shown = json.optBoolean(DEFAULT_SHOWN); |
| 248 | this.hidden = json.optBoolean(HIDDEN); | 283 | this.hidden = json.optBoolean(HIDDEN); |
| 249 | - this.working_hours = json.optJSONObject(WORKING_HOURS); | 284 | + this.working_hours = optNullableString(json, WORKING_HOURS); |
| 250 | this.tags = json.optJSONArray(TAGS); | 285 | this.tags = json.optJSONArray(TAGS); |
| 251 | this.product = json.optJSONObject(PRODUCT); | 286 | this.product = json.optJSONObject(PRODUCT); |
| 287 | + this.telephonesRaw = optNullableString(json, TELEPHONES_RAW); | ||
| 288 | + this.yearEstablished = optNullableString(json, YEAR_ESTABLISHED); | ||
| 289 | + this.currency = optNullableString(json, CURRENCY); | ||
| 290 | + this.bank = optNullableString(json, BANK); | ||
| 291 | + this.minOrderPrice = optNullableString(json, MIN_ORDER_PRICE); | ||
| 292 | + this.minOrderPriceTakeaway = optNullableString(json, MIN_ORDER_PRICE_TAKEAWAY); | ||
| 293 | + this.minPrice = optNullableString(json, MIN_PRICE); | ||
| 294 | + this.maxPrice = optNullableString(json, MAX_PRICE); | ||
| 295 | + this.urlName = optNullableString(json, URL_NAME); | ||
| 252 | } | 296 | } |
| 253 | } | 297 | } |
| 254 | 298 | ||
| 255 | public Merchant(JSONObject json, boolean isUniversal) { | 299 | public Merchant(JSONObject json, boolean isUniversal) { |
| 256 | if (json != null) { | 300 | if (json != null) { |
| 257 | - this.address = json.isNull(ADDRESS) ? "" : json.optString(ADDRESS); | 301 | + this.address = optNullableString(json, ADDRESS); |
| 258 | - this.body = json.optString(BODY); | 302 | + this.body = optNullableString(json, BODY); |
| 259 | - this.city = json.optString(CITY); | 303 | + this.city = optNullableString(json, CITY); |
| 260 | - this.logo = json.optString(LOGO); | 304 | + this.logo = optNullableString(json, LOGO); |
| 261 | - this.country = json.optString(COUNTRY); | 305 | + this.country = optNullableString(json, COUNTRY); |
| 262 | - this.name = json.isNull(NAME) ? "" : json.optString(NAME); | 306 | + this.name = optNullableString(json, NAME); |
| 263 | - this.postal_code = json.optString(POSTAL_CODE); | 307 | + this.postal_code = optNullableString(json, POSTAL_CODE); |
| 264 | - this.region = json.optString(REGION); | 308 | + this.region = optNullableString(json, REGION); |
| 265 | - this.telephone = json.isNull(TELEPHONE) ? "" : json.optString(TELEPHONE); | 309 | + this.telephone = optNullableString(json, TELEPHONE); |
| 266 | this.merchant_metadata = json.optJSONObject(MERCHANT_METADATA); | 310 | this.merchant_metadata = json.optJSONObject(MERCHANT_METADATA); |
| 267 | - this.admin_name = json.optString(ADMIN_NAME); | 311 | + this.admin_name = optNullableString(json, ADMIN_NAME); |
| 268 | - this.img_preview = json.optString(IMG_PREVIEW); | 312 | + this.img_preview = optNullableString(json, IMG_PREVIEW); |
| 269 | - this.website = json.optString(WEBSITE); | 313 | + this.website = optNullableString(json, WEBSITE); |
| 270 | - | ||
| 271 | -// this.id = json.optString(ID); | ||
| 272 | -// this.store_id = json.optString(STORE_ID); | ||
| 273 | -// this.website = json.optString(WEBSITE); | ||
| 274 | -// this.email = json.optString(EMAIL); | ||
| 275 | -// this.category = json.optString(CATEGORY); | ||
| 276 | -// this.description = json.optString(DESCRIPTION); | ||
| 277 | -// this.short_description = json.optString(SHORT_DESCRIPTION); | ||
| 278 | -// this.latitude = json.isNull(LAT) ? 0.0 : json.optDouble(LAT); | ||
| 279 | -// this.longitude = json.isNull(LON) ? 0.0 : json.optDouble(LON); | ||
| 280 | -// this.image = json.optString(IMAGE); | ||
| 281 | -// this.extra_fields = json.optJSONObject(EXTRA_FIELDS); | ||
| 282 | -// this.active = json.optBoolean(ACTIVE); | ||
| 283 | -// this.vat = json.optString(VAT); | ||
| 284 | -// this.uuid = json.optString(UUID); | ||
| 285 | -// this.category_uuid = json.optString(CATEGORY_UUID); | ||
| 286 | -// this.created = json.optString(CREATED); | ||
| 287 | -// this.parent = json.optString(PARENT); | ||
| 288 | -// this.img = json.optJSONArray(IMG); | ||
| 289 | -// this.img_preview = json.optString(IMG_PREVIEW); | ||
| 290 | -// this.admin_name = json.optString(ADMIN_NAME); | ||
| 291 | -// this.sorting = json.optInt(SORTING); | ||
| 292 | -// this.owner_name = json.optString(OWNER_NAME); | ||
| 293 | -// this.preview = json.optString(PREVIEW); | ||
| 294 | -// this.promoted = json.optBoolean(PROMOTED); | ||
| 295 | -// this.distance = json.optInt(DISTANCE); | ||
| 296 | -// this.default_shown = json.optBoolean(DEFAULT_SHOWN); | ||
| 297 | -// this.hidden = json.optBoolean(HIDDEN); | ||
| 298 | -// this.working_hours = json.optJSONObject(WORKING_HOURS); | ||
| 299 | -// this.tags = json.optJSONArray(TAGS); | ||
| 300 | -// this.product = json.optJSONObject(PRODUCT); | ||
| 301 | -// coordinates = new LatLng(this.latitude, this.longitude); | ||
| 302 | } | 314 | } |
| 303 | } | 315 | } |
| 304 | 316 | ||
| ... | @@ -315,9 +327,17 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -315,9 +327,17 @@ public class Merchant implements Parcelable, Serializable { |
| 315 | this.description = source.readString(); | 327 | this.description = source.readString(); |
| 316 | this.short_description = source.readString(); | 328 | this.short_description = source.readString(); |
| 317 | this.region = source.readString(); | 329 | this.region = source.readString(); |
| 318 | - this.latitude = source.readDouble(); | 330 | + double latVal = source.readDouble(); |
| 319 | - this.longitude = source.readDouble(); | 331 | + this.latitude = latVal == Double.MIN_VALUE ? null : latVal; |
| 332 | + double lonVal = source.readDouble(); | ||
| 333 | + this.longitude = lonVal == Double.MIN_VALUE ? null : lonVal; | ||
| 320 | this.image = source.readString(); | 334 | this.image = source.readString(); |
| 335 | + try { | ||
| 336 | + String extraFieldsStr = source.readString(); | ||
| 337 | + this.extra_fields = extraFieldsStr != null ? new JSONObject(extraFieldsStr) : null; | ||
| 338 | + } catch (JSONException e) { | ||
| 339 | + this.extra_fields = null; | ||
| 340 | + } | ||
| 321 | this.active = source.readByte() != 0; | 341 | this.active = source.readByte() != 0; |
| 322 | this.city = source.readString(); | 342 | this.city = source.readString(); |
| 323 | this.country = source.readString(); | 343 | this.country = source.readString(); |
| ... | @@ -327,16 +347,52 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -327,16 +347,52 @@ public class Merchant implements Parcelable, Serializable { |
| 327 | this.category_uuid = source.readString(); | 347 | this.category_uuid = source.readString(); |
| 328 | this.created = source.readString(); | 348 | this.created = source.readString(); |
| 329 | this.parent = source.readString(); | 349 | this.parent = source.readString(); |
| 350 | + try { | ||
| 351 | + String imgStr = source.readString(); | ||
| 352 | + this.img = imgStr != null ? new JSONArray(imgStr) : null; | ||
| 353 | + } catch (JSONException e) { | ||
| 354 | + this.img = null; | ||
| 355 | + } | ||
| 330 | this.img_preview = source.readString(); | 356 | this.img_preview = source.readString(); |
| 331 | this.admin_name = source.readString(); | 357 | this.admin_name = source.readString(); |
| 332 | - this.sorting = source.readInt(); | 358 | + int sortingVal = source.readInt(); |
| 359 | + this.sorting = sortingVal == Integer.MIN_VALUE ? null : sortingVal; | ||
| 333 | this.body = source.readString(); | 360 | this.body = source.readString(); |
| 334 | this.owner_name = source.readString(); | 361 | this.owner_name = source.readString(); |
| 335 | this.preview = source.readString(); | 362 | this.preview = source.readString(); |
| 363 | + try { | ||
| 364 | + String metadataStr = source.readString(); | ||
| 365 | + this.merchant_metadata = metadataStr != null ? new JSONObject(metadataStr) : null; | ||
| 366 | + } catch (JSONException e) { | ||
| 367 | + this.merchant_metadata = null; | ||
| 368 | + } | ||
| 336 | this.promoted = source.readByte() != 0; | 369 | this.promoted = source.readByte() != 0; |
| 337 | - this.distance = source.readInt(); | 370 | + int distanceVal = source.readInt(); |
| 371 | + this.distance = distanceVal == Integer.MIN_VALUE ? null : distanceVal; | ||
| 338 | this.default_shown = source.readByte() != 0; | 372 | this.default_shown = source.readByte() != 0; |
| 339 | this.hidden = source.readByte() != 0; | 373 | this.hidden = source.readByte() != 0; |
| 374 | + this.working_hours = source.readString(); | ||
| 375 | + try { | ||
| 376 | + String tagsStr = source.readString(); | ||
| 377 | + this.tags = tagsStr != null ? new JSONArray(tagsStr) : null; | ||
| 378 | + } catch (JSONException e) { | ||
| 379 | + this.tags = null; | ||
| 380 | + } | ||
| 381 | + try { | ||
| 382 | + String productStr = source.readString(); | ||
| 383 | + this.product = productStr != null ? new JSONObject(productStr) : null; | ||
| 384 | + } catch (JSONException e) { | ||
| 385 | + this.product = null; | ||
| 386 | + } | ||
| 387 | + this.telephonesRaw = source.readString(); | ||
| 388 | + this.yearEstablished = source.readString(); | ||
| 389 | + this.currency = source.readString(); | ||
| 390 | + this.bank = source.readString(); | ||
| 391 | + this.minOrderPrice = source.readString(); | ||
| 392 | + this.minOrderPriceTakeaway = source.readString(); | ||
| 393 | + this.minPrice = source.readString(); | ||
| 394 | + this.maxPrice = source.readString(); | ||
| 395 | + this.urlName = source.readString(); | ||
| 340 | } | 396 | } |
| 341 | 397 | ||
| 342 | @Override | 398 | @Override |
| ... | @@ -353,9 +409,10 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -353,9 +409,10 @@ public class Merchant implements Parcelable, Serializable { |
| 353 | dest.writeString(this.description); | 409 | dest.writeString(this.description); |
| 354 | dest.writeString(this.short_description); | 410 | dest.writeString(this.short_description); |
| 355 | dest.writeString(this.region); | 411 | dest.writeString(this.region); |
| 356 | - dest.writeDouble(this.latitude); | 412 | + dest.writeDouble(this.latitude != null ? this.latitude : Double.MIN_VALUE); |
| 357 | - dest.writeDouble(this.longitude); | 413 | + dest.writeDouble(this.longitude != null ? this.longitude : Double.MIN_VALUE); |
| 358 | dest.writeString(this.image); | 414 | dest.writeString(this.image); |
| 415 | + dest.writeString(this.extra_fields != null ? this.extra_fields.toString() : null); | ||
| 359 | dest.writeByte((byte) (this.active ? 1 : 0)); | 416 | dest.writeByte((byte) (this.active ? 1 : 0)); |
| 360 | dest.writeString(this.city); | 417 | dest.writeString(this.city); |
| 361 | dest.writeString(this.country); | 418 | dest.writeString(this.country); |
| ... | @@ -365,16 +422,30 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -365,16 +422,30 @@ public class Merchant implements Parcelable, Serializable { |
| 365 | dest.writeString(this.category_uuid); | 422 | dest.writeString(this.category_uuid); |
| 366 | dest.writeString(this.created); | 423 | dest.writeString(this.created); |
| 367 | dest.writeString(this.parent); | 424 | dest.writeString(this.parent); |
| 425 | + dest.writeString(this.img != null ? this.img.toString() : null); | ||
| 368 | dest.writeString(this.img_preview); | 426 | dest.writeString(this.img_preview); |
| 369 | dest.writeString(this.admin_name); | 427 | dest.writeString(this.admin_name); |
| 370 | - dest.writeInt(this.sorting); | 428 | + dest.writeInt(this.sorting != null ? this.sorting : Integer.MIN_VALUE); |
| 371 | dest.writeString(this.body); | 429 | dest.writeString(this.body); |
| 372 | dest.writeString(this.owner_name); | 430 | dest.writeString(this.owner_name); |
| 373 | dest.writeString(this.preview); | 431 | dest.writeString(this.preview); |
| 432 | + dest.writeString(this.merchant_metadata != null ? this.merchant_metadata.toString() : null); | ||
| 374 | dest.writeByte((byte) (this.promoted ? 1 : 0)); | 433 | dest.writeByte((byte) (this.promoted ? 1 : 0)); |
| 375 | - dest.writeInt(this.distance); | 434 | + dest.writeInt(this.distance != null ? this.distance : Integer.MIN_VALUE); |
| 376 | dest.writeByte((byte) (this.default_shown ? 1 : 0)); | 435 | dest.writeByte((byte) (this.default_shown ? 1 : 0)); |
| 377 | dest.writeByte((byte) (this.hidden ? 1 : 0)); | 436 | dest.writeByte((byte) (this.hidden ? 1 : 0)); |
| 437 | + dest.writeString(this.working_hours); | ||
| 438 | + dest.writeString(this.tags != null ? this.tags.toString() : null); | ||
| 439 | + dest.writeString(this.product != null ? this.product.toString() : null); | ||
| 440 | + dest.writeString(this.telephonesRaw); | ||
| 441 | + dest.writeString(this.yearEstablished); | ||
| 442 | + dest.writeString(this.currency); | ||
| 443 | + dest.writeString(this.bank); | ||
| 444 | + dest.writeString(this.minOrderPrice); | ||
| 445 | + dest.writeString(this.minOrderPriceTakeaway); | ||
| 446 | + dest.writeString(this.minPrice); | ||
| 447 | + dest.writeString(this.maxPrice); | ||
| 448 | + dest.writeString(this.urlName); | ||
| 378 | } | 449 | } |
| 379 | 450 | ||
| 380 | /** | 451 | /** |
| ... | @@ -385,46 +456,55 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -385,46 +456,55 @@ public class Merchant implements Parcelable, Serializable { |
| 385 | public JSONObject toJSONObject() { | 456 | public JSONObject toJSONObject() { |
| 386 | JSONObject jObj = new JSONObject(); | 457 | JSONObject jObj = new JSONObject(); |
| 387 | try { | 458 | try { |
| 388 | - jObj.putOpt(ADDRESS, this.address); | 459 | + jObj.put(ADDRESS, this.address != null ? this.address : JSONObject.NULL); |
| 389 | - jObj.putOpt(ID, this.id); | 460 | + jObj.put(ID, this.id != null ? this.id : JSONObject.NULL); |
| 390 | - jObj.putOpt(STORE_ID, this.store_id); | 461 | + jObj.put(STORE_ID, this.store_id != null ? this.store_id : JSONObject.NULL); |
| 391 | - jObj.putOpt(NAME, this.name); | 462 | + jObj.put(NAME, this.name != null ? this.name : JSONObject.NULL); |
| 392 | - jObj.putOpt(LOGO, this.logo); | 463 | + jObj.put(LOGO, this.logo != null ? this.logo : JSONObject.NULL); |
| 393 | - jObj.putOpt(WEBSITE, this.website); | 464 | + jObj.put(WEBSITE, this.website != null ? this.website : JSONObject.NULL); |
| 394 | - jObj.putOpt(EMAIL, this.email); | 465 | + jObj.put(EMAIL, this.email != null ? this.email : JSONObject.NULL); |
| 395 | - jObj.putOpt(TELEPHONE, this.telephone); | 466 | + jObj.put(TELEPHONE, this.telephone != null ? this.telephone : JSONObject.NULL); |
| 396 | - jObj.putOpt(CATEGORY, this.category); | 467 | + jObj.put(CATEGORY, this.category != null ? this.category : JSONObject.NULL); |
| 397 | - jObj.putOpt(DESCRIPTION, this.description); | 468 | + jObj.put(DESCRIPTION, this.description != null ? this.description : JSONObject.NULL); |
| 398 | - jObj.putOpt(SHORT_DESCRIPTION, this.short_description); | 469 | + jObj.put(SHORT_DESCRIPTION, this.short_description != null ? this.short_description : JSONObject.NULL); |
| 399 | - jObj.putOpt(REGION, this.region); | 470 | + jObj.put(REGION, this.region != null ? this.region : JSONObject.NULL); |
| 400 | - jObj.putOpt(LAT, this.latitude); | 471 | + jObj.put(LAT, this.latitude != null ? this.latitude : JSONObject.NULL); |
| 401 | - jObj.putOpt(LON, this.longitude); | 472 | + jObj.put(LON, this.longitude != null ? this.longitude : JSONObject.NULL); |
| 402 | - jObj.putOpt(IMAGE, this.image); | 473 | + jObj.put(IMAGE, this.image != null ? this.image : JSONObject.NULL); |
| 403 | - jObj.putOpt(EXTRA_FIELDS, this.extra_fields); | 474 | + jObj.put(EXTRA_FIELDS, this.extra_fields != null ? this.extra_fields : JSONObject.NULL); |
| 404 | jObj.putOpt(ACTIVE, this.active); | 475 | jObj.putOpt(ACTIVE, this.active); |
| 405 | - jObj.putOpt(CITY, this.city); | 476 | + jObj.put(CITY, this.city != null ? this.city : JSONObject.NULL); |
| 406 | - jObj.putOpt(COUNTRY, this.country); | 477 | + jObj.put(COUNTRY, this.country != null ? this.country : JSONObject.NULL); |
| 407 | - jObj.putOpt(POSTAL_CODE, this.postal_code); | 478 | + jObj.put(POSTAL_CODE, this.postal_code != null ? this.postal_code : JSONObject.NULL); |
| 408 | - jObj.putOpt(VAT, this.vat); | 479 | + jObj.put(VAT, this.vat != null ? this.vat : JSONObject.NULL); |
| 409 | - jObj.putOpt(UUID, this.uuid); | 480 | + jObj.put(UUID, this.uuid != null ? this.uuid : JSONObject.NULL); |
| 410 | - jObj.putOpt(CATEGORY_UUID, this.category_uuid); | 481 | + jObj.put(CATEGORY_UUID, this.category_uuid != null ? this.category_uuid : JSONObject.NULL); |
| 411 | - jObj.putOpt(CREATED, this.created); | 482 | + jObj.put(CREATED, this.created != null ? this.created : JSONObject.NULL); |
| 412 | - jObj.putOpt(PARENT, this.parent); | 483 | + jObj.put(PARENT, this.parent != null ? this.parent : JSONObject.NULL); |
| 413 | - jObj.putOpt(IMG, this.img); | 484 | + jObj.put(IMG, this.img != null ? this.img : JSONObject.NULL); |
| 414 | - jObj.putOpt(IMG_PREVIEW, this.img_preview); | 485 | + jObj.put(IMG_PREVIEW, this.img_preview != null ? this.img_preview : JSONObject.NULL); |
| 415 | - jObj.putOpt(ADMIN_NAME, this.admin_name); | 486 | + jObj.put(ADMIN_NAME, this.admin_name != null ? this.admin_name : JSONObject.NULL); |
| 416 | - jObj.putOpt(SORTING, this.sorting); | 487 | + jObj.put(SORTING, this.sorting != null ? this.sorting : JSONObject.NULL); |
| 417 | - jObj.putOpt(BODY, this.body); | 488 | + jObj.put(BODY, this.body != null ? this.body : JSONObject.NULL); |
| 418 | - jObj.putOpt(OWNER_NAME, this.owner_name); | 489 | + jObj.put(OWNER_NAME, this.owner_name != null ? this.owner_name : JSONObject.NULL); |
| 419 | - jObj.putOpt(PREVIEW, this.preview); | 490 | + jObj.put(PREVIEW, this.preview != null ? this.preview : JSONObject.NULL); |
| 420 | - jObj.putOpt(MERCHANT_METADATA, this.merchant_metadata); | 491 | + jObj.put(MERCHANT_METADATA, this.merchant_metadata != null ? this.merchant_metadata : JSONObject.NULL); |
| 421 | jObj.putOpt(PROMOTED, this.promoted); | 492 | jObj.putOpt(PROMOTED, this.promoted); |
| 422 | - jObj.putOpt(DISTANCE, this.distance); | 493 | + jObj.put(DISTANCE, this.distance != null ? this.distance : JSONObject.NULL); |
| 423 | jObj.putOpt(DEFAULT_SHOWN, this.default_shown); | 494 | jObj.putOpt(DEFAULT_SHOWN, this.default_shown); |
| 424 | jObj.putOpt(HIDDEN, this.hidden); | 495 | jObj.putOpt(HIDDEN, this.hidden); |
| 425 | - jObj.putOpt(WORKING_HOURS, this.working_hours); | 496 | + jObj.put(WORKING_HOURS, this.working_hours != null ? this.working_hours : JSONObject.NULL); |
| 426 | - jObj.putOpt(TAGS, this.tags); | 497 | + jObj.put(TAGS, this.tags != null ? this.tags : JSONObject.NULL); |
| 427 | - jObj.putOpt(PRODUCT, this.product); | 498 | + jObj.put(PRODUCT, this.product != null ? this.product : JSONObject.NULL); |
| 499 | + jObj.put(TELEPHONES_RAW, this.telephonesRaw != null ? this.telephonesRaw : JSONObject.NULL); | ||
| 500 | + jObj.put(YEAR_ESTABLISHED, this.yearEstablished != null ? this.yearEstablished : JSONObject.NULL); | ||
| 501 | + jObj.put(CURRENCY, this.currency != null ? this.currency : JSONObject.NULL); | ||
| 502 | + jObj.put(BANK, this.bank != null ? this.bank : JSONObject.NULL); | ||
| 503 | + jObj.put(MIN_ORDER_PRICE, this.minOrderPrice != null ? this.minOrderPrice : JSONObject.NULL); | ||
| 504 | + jObj.put(MIN_ORDER_PRICE_TAKEAWAY, this.minOrderPriceTakeaway != null ? this.minOrderPriceTakeaway : JSONObject.NULL); | ||
| 505 | + jObj.put(MIN_PRICE, this.minPrice != null ? this.minPrice : JSONObject.NULL); | ||
| 506 | + jObj.put(MAX_PRICE, this.maxPrice != null ? this.maxPrice : JSONObject.NULL); | ||
| 507 | + jObj.put(URL_NAME, this.urlName != null ? this.urlName : JSONObject.NULL); | ||
| 428 | } catch (JSONException e) { | 508 | } catch (JSONException e) { |
| 429 | if (WarpConstants.DEBUG) { | 509 | if (WarpConstants.DEBUG) { |
| 430 | e.printStackTrace(); | 510 | e.printStackTrace(); |
| ... | @@ -434,6 +514,24 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -434,6 +514,24 @@ public class Merchant implements Parcelable, Serializable { |
| 434 | } | 514 | } |
| 435 | 515 | ||
| 436 | /** | 516 | /** |
| 517 | + * Helper method to parse the working_hours string into a JSONObject | ||
| 518 | + * | ||
| 519 | + * @return The working hours as a JSONObject, or null if parsing fails or value is null | ||
| 520 | + */ | ||
| 521 | + public JSONObject getWorkingHoursJSON() { | ||
| 522 | + try { | ||
| 523 | + if (working_hours != null && !working_hours.isEmpty()) { | ||
| 524 | + return new JSONObject(working_hours); | ||
| 525 | + } | ||
| 526 | + } catch (JSONException e) { | ||
| 527 | + if (WarpConstants.DEBUG) { | ||
| 528 | + e.printStackTrace(); | ||
| 529 | + } | ||
| 530 | + } | ||
| 531 | + return null; | ||
| 532 | + } | ||
| 533 | + | ||
| 534 | + /** | ||
| 437 | * String representation of the Merchant, as a JSON object | 535 | * String representation of the Merchant, as a JSON object |
| 438 | * | 536 | * |
| 439 | * @return A String representation of JSON object | 537 | * @return A String representation of JSON object |
| ... | @@ -511,11 +609,11 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -511,11 +609,11 @@ public class Merchant implements Parcelable, Serializable { |
| 511 | return region; | 609 | return region; |
| 512 | } | 610 | } |
| 513 | 611 | ||
| 514 | - public double getLatitude() { | 612 | + public Double getLatitude() { |
| 515 | return latitude; | 613 | return latitude; |
| 516 | } | 614 | } |
| 517 | 615 | ||
| 518 | - public double getLongitude() { | 616 | + public Double getLongitude() { |
| 519 | return longitude; | 617 | return longitude; |
| 520 | } | 618 | } |
| 521 | 619 | ||
| ... | @@ -567,6 +665,10 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -567,6 +665,10 @@ public class Merchant implements Parcelable, Serializable { |
| 567 | return jsonArrayToList(img); | 665 | return jsonArrayToList(img); |
| 568 | } | 666 | } |
| 569 | 667 | ||
| 668 | + public JSONArray getImgRaw() { | ||
| 669 | + return img; | ||
| 670 | + } | ||
| 671 | + | ||
| 570 | public String getImgPreview() { | 672 | public String getImgPreview() { |
| 571 | return img_preview; | 673 | return img_preview; |
| 572 | } | 674 | } |
| ... | @@ -575,7 +677,7 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -575,7 +677,7 @@ public class Merchant implements Parcelable, Serializable { |
| 575 | return admin_name; | 677 | return admin_name; |
| 576 | } | 678 | } |
| 577 | 679 | ||
| 578 | - public int getSorting() { | 680 | + public Integer getSorting() { |
| 579 | return sorting; | 681 | return sorting; |
| 580 | } | 682 | } |
| 581 | 683 | ||
| ... | @@ -599,7 +701,7 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -599,7 +701,7 @@ public class Merchant implements Parcelable, Serializable { |
| 599 | return promoted; | 701 | return promoted; |
| 600 | } | 702 | } |
| 601 | 703 | ||
| 602 | - public int getDistance() { | 704 | + public Integer getDistance() { |
| 603 | return distance; | 705 | return distance; |
| 604 | } | 706 | } |
| 605 | 707 | ||
| ... | @@ -611,7 +713,7 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -611,7 +713,7 @@ public class Merchant implements Parcelable, Serializable { |
| 611 | return hidden; | 713 | return hidden; |
| 612 | } | 714 | } |
| 613 | 715 | ||
| 614 | - public JSONObject getWorkingHours() { | 716 | + public String getWorkingHours() { |
| 615 | return working_hours; | 717 | return working_hours; |
| 616 | } | 718 | } |
| 617 | 719 | ||
| ... | @@ -619,10 +721,54 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -619,10 +721,54 @@ public class Merchant implements Parcelable, Serializable { |
| 619 | return jsonArrayToList(tags); | 721 | return jsonArrayToList(tags); |
| 620 | } | 722 | } |
| 621 | 723 | ||
| 724 | + public JSONArray getTagsRaw() { | ||
| 725 | + return tags; | ||
| 726 | + } | ||
| 727 | + | ||
| 622 | public JSONObject getProduct() { | 728 | public JSONObject getProduct() { |
| 623 | return product; | 729 | return product; |
| 624 | } | 730 | } |
| 625 | 731 | ||
| 732 | + public String getTelephonesRaw() { | ||
| 733 | + return telephonesRaw; | ||
| 734 | + } | ||
| 735 | + | ||
| 736 | + public String getYearEstablished() { | ||
| 737 | + return yearEstablished; | ||
| 738 | + } | ||
| 739 | + | ||
| 740 | + public String getCurrency() { | ||
| 741 | + return currency; | ||
| 742 | + } | ||
| 743 | + | ||
| 744 | + public String getBank() { | ||
| 745 | + return bank; | ||
| 746 | + } | ||
| 747 | + | ||
| 748 | + public String getMinOrderPrice() { | ||
| 749 | + return minOrderPrice; | ||
| 750 | + } | ||
| 751 | + | ||
| 752 | + public String getMinOrderPriceTakeaway() { | ||
| 753 | + return minOrderPriceTakeaway; | ||
| 754 | + } | ||
| 755 | + | ||
| 756 | + public String getMinPrice() { | ||
| 757 | + return minPrice; | ||
| 758 | + } | ||
| 759 | + | ||
| 760 | + public String getMaxPrice() { | ||
| 761 | + return maxPrice; | ||
| 762 | + } | ||
| 763 | + | ||
| 764 | + public String getUrlName() { | ||
| 765 | + return urlName; | ||
| 766 | + } | ||
| 767 | + | ||
| 768 | + // ================================================================================ | ||
| 769 | + // Setters | ||
| 770 | + // ================================================================================ | ||
| 771 | + | ||
| 626 | public void setAddress(String address) { | 772 | public void setAddress(String address) { |
| 627 | this.address = address; | 773 | this.address = address; |
| 628 | } | 774 | } |
| ... | @@ -671,11 +817,11 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -671,11 +817,11 @@ public class Merchant implements Parcelable, Serializable { |
| 671 | this.region = region; | 817 | this.region = region; |
| 672 | } | 818 | } |
| 673 | 819 | ||
| 674 | - public void setLatitude(double latitude) { | 820 | + public void setLatitude(Double latitude) { |
| 675 | this.latitude = latitude; | 821 | this.latitude = latitude; |
| 676 | } | 822 | } |
| 677 | 823 | ||
| 678 | - public void setLongitude(double longitude) { | 824 | + public void setLongitude(Double longitude) { |
| 679 | this.longitude = longitude; | 825 | this.longitude = longitude; |
| 680 | } | 826 | } |
| 681 | 827 | ||
| ... | @@ -735,7 +881,7 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -735,7 +881,7 @@ public class Merchant implements Parcelable, Serializable { |
| 735 | this.admin_name = admin_name; | 881 | this.admin_name = admin_name; |
| 736 | } | 882 | } |
| 737 | 883 | ||
| 738 | - public void setSorting(int sorting) { | 884 | + public void setSorting(Integer sorting) { |
| 739 | this.sorting = sorting; | 885 | this.sorting = sorting; |
| 740 | } | 886 | } |
| 741 | 887 | ||
| ... | @@ -759,7 +905,7 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -759,7 +905,7 @@ public class Merchant implements Parcelable, Serializable { |
| 759 | this.promoted = promoted; | 905 | this.promoted = promoted; |
| 760 | } | 906 | } |
| 761 | 907 | ||
| 762 | - public void setDistance(int distance) { | 908 | + public void setDistance(Integer distance) { |
| 763 | this.distance = distance; | 909 | this.distance = distance; |
| 764 | } | 910 | } |
| 765 | 911 | ||
| ... | @@ -771,7 +917,7 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -771,7 +917,7 @@ public class Merchant implements Parcelable, Serializable { |
| 771 | this.hidden = hidden; | 917 | this.hidden = hidden; |
| 772 | } | 918 | } |
| 773 | 919 | ||
| 774 | - public void setWorking_hours(JSONObject working_hours) { | 920 | + public void setWorking_hours(String working_hours) { |
| 775 | this.working_hours = working_hours; | 921 | this.working_hours = working_hours; |
| 776 | } | 922 | } |
| 777 | 923 | ||
| ... | @@ -783,6 +929,42 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -783,6 +929,42 @@ public class Merchant implements Parcelable, Serializable { |
| 783 | this.product = product; | 929 | this.product = product; |
| 784 | } | 930 | } |
| 785 | 931 | ||
| 932 | + public void setTelephonesRaw(String telephonesRaw) { | ||
| 933 | + this.telephonesRaw = telephonesRaw; | ||
| 934 | + } | ||
| 935 | + | ||
| 936 | + public void setYearEstablished(String yearEstablished) { | ||
| 937 | + this.yearEstablished = yearEstablished; | ||
| 938 | + } | ||
| 939 | + | ||
| 940 | + public void setCurrency(String currency) { | ||
| 941 | + this.currency = currency; | ||
| 942 | + } | ||
| 943 | + | ||
| 944 | + public void setBank(String bank) { | ||
| 945 | + this.bank = bank; | ||
| 946 | + } | ||
| 947 | + | ||
| 948 | + public void setMinOrderPrice(String minOrderPrice) { | ||
| 949 | + this.minOrderPrice = minOrderPrice; | ||
| 950 | + } | ||
| 951 | + | ||
| 952 | + public void setMinOrderPriceTakeaway(String minOrderPriceTakeaway) { | ||
| 953 | + this.minOrderPriceTakeaway = minOrderPriceTakeaway; | ||
| 954 | + } | ||
| 955 | + | ||
| 956 | + public void setMinPrice(String minPrice) { | ||
| 957 | + this.minPrice = minPrice; | ||
| 958 | + } | ||
| 959 | + | ||
| 960 | + public void setMaxPrice(String maxPrice) { | ||
| 961 | + this.maxPrice = maxPrice; | ||
| 962 | + } | ||
| 963 | + | ||
| 964 | + public void setUrlName(String urlName) { | ||
| 965 | + this.urlName = urlName; | ||
| 966 | + } | ||
| 967 | + | ||
| 786 | @Override | 968 | @Override |
| 787 | public int describeContents() { | 969 | public int describeContents() { |
| 788 | return 0; | 970 | return 0; |
| ... | @@ -805,7 +987,6 @@ public class Merchant implements Parcelable, Serializable { | ... | @@ -805,7 +987,6 @@ public class Merchant implements Parcelable, Serializable { |
| 805 | listData.add(jArray.optString(i)); | 987 | listData.add(jArray.optString(i)); |
| 806 | } | 988 | } |
| 807 | } | 989 | } |
| 808 | - | ||
| 809 | return listData; | 990 | return listData; |
| 810 | } | 991 | } |
| 811 | } | 992 | } | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2010-2013 Warply Ltd. All rights reserved. | ||
| 3 | + * | ||
| 4 | + * Redistribution and use in source and binary forms, without modification, are | ||
| 5 | + * permitted provided that the following conditions are met: | ||
| 6 | + * | ||
| 7 | + * 1. Redistributions of source code must retain the above copyright notice, | ||
| 8 | + * this list of conditions and the following disclaimer. | ||
| 9 | + * | ||
| 10 | + * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| 11 | + * this list of conditions and the following disclaimer in the documentation | ||
| 12 | + * and/or other materials provided with the distribution. | ||
| 13 | + * | ||
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR | ||
| 15 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 16 | + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
| 17 | + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 18 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 19 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
| 20 | + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 21 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 22 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
| 23 | + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 24 | + */ | ||
| 25 | + | ||
| 26 | +package ly.warp.sdk.io.models; | ||
| 27 | + | ||
| 28 | +import android.os.Parcel; | ||
| 29 | +import android.os.Parcelable; | ||
| 30 | + | ||
| 31 | +import org.json.JSONArray; | ||
| 32 | +import org.json.JSONException; | ||
| 33 | +import org.json.JSONObject; | ||
| 34 | + | ||
| 35 | +import java.io.Serializable; | ||
| 36 | +import java.util.ArrayList; | ||
| 37 | + | ||
| 38 | +import ly.warp.sdk.utils.WarpUtils; | ||
| 39 | +import ly.warp.sdk.utils.constants.WarpConstants; | ||
| 40 | + | ||
| 41 | +/** | ||
| 42 | + * Created by Panagiotis Triantafyllou on 27-Feb-26. | ||
| 43 | + */ | ||
| 44 | + | ||
| 45 | +public class User implements Parcelable, Serializable { | ||
| 46 | + | ||
| 47 | + private static final long serialVersionUID = -4754964462459705285L; | ||
| 48 | + | ||
| 49 | + /* Constants used to export the User in JSON format and vice versa */ | ||
| 50 | + | ||
| 51 | + private static final String CONSUMER_METADATA = "consumer_metadata"; | ||
| 52 | + private static final String ELIGIBILITY_TYPE = "eligibility_type"; | ||
| 53 | + private static final String EMAIL = "email"; | ||
| 54 | + private static final String FAVORITE_COUPONSETS = "favorite_couponsets"; | ||
| 55 | + private static final String IS_ELIGIBLE = "is_eligible"; | ||
| 56 | + private static final String MSISDN = "msisdn"; | ||
| 57 | + private static final String PROFILE_METADATA = "profile_metadata"; | ||
| 58 | + private static final String QUESTIONNAIRE = "questionnaire"; | ||
| 59 | + private static final String QUESTIONNAIRE_ANSWERS = "questionnaire_answers"; | ||
| 60 | + private static final String USER_ANSWERS = "user_answers"; | ||
| 61 | + private static final String USER_ID = "user_id"; | ||
| 62 | + private static final String USER_SEGMENTS = "user_segments"; | ||
| 63 | + private static final String UUID = "uuid"; | ||
| 64 | + | ||
| 65 | + /* Member variables of the User object */ | ||
| 66 | + | ||
| 67 | + private JSONObject consumerMetadata; | ||
| 68 | + private String eligibilityType; | ||
| 69 | + private String email; | ||
| 70 | + private JSONArray favoriteCouponsets; | ||
| 71 | + private boolean isEligible = false; | ||
| 72 | + private String msisdn; | ||
| 73 | + private String profileMetadata; | ||
| 74 | + private JSONObject questionnaire; | ||
| 75 | + private JSONObject questionnaireAnswers; | ||
| 76 | + private JSONObject userAnswers; | ||
| 77 | + private String userId; | ||
| 78 | + private JSONArray userSegments; | ||
| 79 | + private String uuid; | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * Helper method to get a nullable String from a JSONObject. | ||
| 83 | + * Returns null if the JSON value is null, otherwise returns the String value. | ||
| 84 | + */ | ||
| 85 | + private static String optNullableString(JSONObject json, String key) { | ||
| 86 | + return json.isNull(key) ? null : json.optString(key); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public User() { | ||
| 90 | + this.consumerMetadata = null; | ||
| 91 | + this.eligibilityType = null; | ||
| 92 | + this.email = null; | ||
| 93 | + this.favoriteCouponsets = null; | ||
| 94 | + this.isEligible = false; | ||
| 95 | + this.msisdn = null; | ||
| 96 | + this.profileMetadata = null; | ||
| 97 | + this.questionnaire = null; | ||
| 98 | + this.questionnaireAnswers = null; | ||
| 99 | + this.userAnswers = null; | ||
| 100 | + this.userId = null; | ||
| 101 | + this.userSegments = null; | ||
| 102 | + this.uuid = null; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * Basic constructor used to create an object from a String, representing a | ||
| 107 | + * JSON Object | ||
| 108 | + * | ||
| 109 | + * @param json The String, representing the JSON Object | ||
| 110 | + * @throws JSONException Thrown if the String cannot be converted to JSON | ||
| 111 | + */ | ||
| 112 | + public User(String json) throws JSONException { | ||
| 113 | + this(new JSONObject(json)); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * Constructor used to create an Object from a given JSON Object | ||
| 118 | + * | ||
| 119 | + * @param json JSON Object used to create the User | ||
| 120 | + */ | ||
| 121 | + public User(JSONObject json) { | ||
| 122 | + if (json != null) { | ||
| 123 | + this.consumerMetadata = json.optJSONObject(CONSUMER_METADATA); | ||
| 124 | + this.eligibilityType = optNullableString(json, ELIGIBILITY_TYPE); | ||
| 125 | + this.email = optNullableString(json, EMAIL); | ||
| 126 | + this.favoriteCouponsets = json.optJSONArray(FAVORITE_COUPONSETS); | ||
| 127 | + this.isEligible = json.optBoolean(IS_ELIGIBLE); | ||
| 128 | + this.msisdn = optNullableString(json, MSISDN); | ||
| 129 | + this.profileMetadata = optNullableString(json, PROFILE_METADATA); | ||
| 130 | + this.questionnaire = json.optJSONObject(QUESTIONNAIRE); | ||
| 131 | + this.questionnaireAnswers = json.optJSONObject(QUESTIONNAIRE_ANSWERS); | ||
| 132 | + this.userAnswers = json.optJSONObject(USER_ANSWERS); | ||
| 133 | + this.userId = optNullableString(json, USER_ID); | ||
| 134 | + this.userSegments = json.optJSONArray(USER_SEGMENTS); | ||
| 135 | + this.uuid = optNullableString(json, UUID); | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + public User(Parcel source) { | ||
| 140 | + this.eligibilityType = source.readString(); | ||
| 141 | + this.email = source.readString(); | ||
| 142 | + this.isEligible = source.readByte() != 0; | ||
| 143 | + this.msisdn = source.readString(); | ||
| 144 | + this.profileMetadata = source.readString(); | ||
| 145 | + this.userId = source.readString(); | ||
| 146 | + this.uuid = source.readString(); | ||
| 147 | + try { | ||
| 148 | + String consumerMetadataStr = source.readString(); | ||
| 149 | + this.consumerMetadata = consumerMetadataStr != null ? new JSONObject(consumerMetadataStr) : null; | ||
| 150 | + } catch (JSONException e) { | ||
| 151 | + this.consumerMetadata = null; | ||
| 152 | + } | ||
| 153 | + try { | ||
| 154 | + String favoriteCouponsetsStr = source.readString(); | ||
| 155 | + this.favoriteCouponsets = favoriteCouponsetsStr != null ? new JSONArray(favoriteCouponsetsStr) : null; | ||
| 156 | + } catch (JSONException e) { | ||
| 157 | + this.favoriteCouponsets = null; | ||
| 158 | + } | ||
| 159 | + try { | ||
| 160 | + String questionnaireStr = source.readString(); | ||
| 161 | + this.questionnaire = questionnaireStr != null ? new JSONObject(questionnaireStr) : null; | ||
| 162 | + } catch (JSONException e) { | ||
| 163 | + this.questionnaire = null; | ||
| 164 | + } | ||
| 165 | + try { | ||
| 166 | + String questionnaireAnswersStr = source.readString(); | ||
| 167 | + this.questionnaireAnswers = questionnaireAnswersStr != null ? new JSONObject(questionnaireAnswersStr) : null; | ||
| 168 | + } catch (JSONException e) { | ||
| 169 | + this.questionnaireAnswers = null; | ||
| 170 | + } | ||
| 171 | + try { | ||
| 172 | + String userAnswersStr = source.readString(); | ||
| 173 | + this.userAnswers = userAnswersStr != null ? new JSONObject(userAnswersStr) : null; | ||
| 174 | + } catch (JSONException e) { | ||
| 175 | + this.userAnswers = null; | ||
| 176 | + } | ||
| 177 | + try { | ||
| 178 | + String userSegmentsStr = source.readString(); | ||
| 179 | + this.userSegments = userSegmentsStr != null ? new JSONArray(userSegmentsStr) : null; | ||
| 180 | + } catch (JSONException e) { | ||
| 181 | + this.userSegments = null; | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + @Override | ||
| 186 | + public void writeToParcel(Parcel dest, int flags) { | ||
| 187 | + dest.writeString(this.eligibilityType); | ||
| 188 | + dest.writeString(this.email); | ||
| 189 | + dest.writeByte((byte) (this.isEligible ? 1 : 0)); | ||
| 190 | + dest.writeString(this.msisdn); | ||
| 191 | + dest.writeString(this.profileMetadata); | ||
| 192 | + dest.writeString(this.userId); | ||
| 193 | + dest.writeString(this.uuid); | ||
| 194 | + dest.writeString(this.consumerMetadata != null ? this.consumerMetadata.toString() : null); | ||
| 195 | + dest.writeString(this.favoriteCouponsets != null ? this.favoriteCouponsets.toString() : null); | ||
| 196 | + dest.writeString(this.questionnaire != null ? this.questionnaire.toString() : null); | ||
| 197 | + dest.writeString(this.questionnaireAnswers != null ? this.questionnaireAnswers.toString() : null); | ||
| 198 | + dest.writeString(this.userAnswers != null ? this.userAnswers.toString() : null); | ||
| 199 | + dest.writeString(this.userSegments != null ? this.userSegments.toString() : null); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + /** | ||
| 203 | + * Converts the User into a JSON Object | ||
| 204 | + * | ||
| 205 | + * @return The JSON Object created from this User | ||
| 206 | + */ | ||
| 207 | + public JSONObject toJSONObject() { | ||
| 208 | + JSONObject jObj = new JSONObject(); | ||
| 209 | + try { | ||
| 210 | + jObj.put(CONSUMER_METADATA, this.consumerMetadata != null ? this.consumerMetadata : JSONObject.NULL); | ||
| 211 | + jObj.put(ELIGIBILITY_TYPE, this.eligibilityType != null ? this.eligibilityType : JSONObject.NULL); | ||
| 212 | + jObj.put(EMAIL, this.email != null ? this.email : JSONObject.NULL); | ||
| 213 | + jObj.put(FAVORITE_COUPONSETS, this.favoriteCouponsets != null ? this.favoriteCouponsets : JSONObject.NULL); | ||
| 214 | + jObj.putOpt(IS_ELIGIBLE, this.isEligible); | ||
| 215 | + jObj.put(MSISDN, this.msisdn != null ? this.msisdn : JSONObject.NULL); | ||
| 216 | + jObj.put(PROFILE_METADATA, this.profileMetadata != null ? this.profileMetadata : JSONObject.NULL); | ||
| 217 | + jObj.put(QUESTIONNAIRE, this.questionnaire != null ? this.questionnaire : JSONObject.NULL); | ||
| 218 | + jObj.put(QUESTIONNAIRE_ANSWERS, this.questionnaireAnswers != null ? this.questionnaireAnswers : JSONObject.NULL); | ||
| 219 | + jObj.put(USER_ANSWERS, this.userAnswers != null ? this.userAnswers : JSONObject.NULL); | ||
| 220 | + jObj.put(USER_ID, this.userId != null ? this.userId : JSONObject.NULL); | ||
| 221 | + jObj.put(USER_SEGMENTS, this.userSegments != null ? this.userSegments : JSONObject.NULL); | ||
| 222 | + jObj.put(UUID, this.uuid != null ? this.uuid : JSONObject.NULL); | ||
| 223 | + } catch (JSONException e) { | ||
| 224 | + if (WarpConstants.DEBUG) { | ||
| 225 | + e.printStackTrace(); | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + return jObj; | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + /** | ||
| 232 | + * String representation of the User, as a JSON object | ||
| 233 | + * | ||
| 234 | + * @return A String representation of JSON object | ||
| 235 | + */ | ||
| 236 | + public String toString() { | ||
| 237 | + if (toJSONObject() != null) | ||
| 238 | + return toJSONObject().toString(); | ||
| 239 | + return null; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + /** | ||
| 243 | + * String representation of the User, as a human readable JSON object | ||
| 244 | + * | ||
| 245 | + * @return A human readable String representation of JSON object | ||
| 246 | + */ | ||
| 247 | + public String toHumanReadableString() { | ||
| 248 | + String humanReadableString = null; | ||
| 249 | + try { | ||
| 250 | + humanReadableString = toJSONObject().toString(2); | ||
| 251 | + } catch (JSONException e) { | ||
| 252 | + WarpUtils.warn("Failed converting User JSON object to String", e); | ||
| 253 | + } | ||
| 254 | + return humanReadableString; | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + /** | ||
| 258 | + * Helper method to parse the profile_metadata string into a JSONObject | ||
| 259 | + * | ||
| 260 | + * @return The profile metadata as a JSONObject, or null if parsing fails or value is null | ||
| 261 | + */ | ||
| 262 | + public JSONObject getProfileMetadataJSON() { | ||
| 263 | + try { | ||
| 264 | + if (profileMetadata != null && !profileMetadata.isEmpty()) { | ||
| 265 | + return new JSONObject(profileMetadata); | ||
| 266 | + } | ||
| 267 | + } catch (JSONException e) { | ||
| 268 | + if (WarpConstants.DEBUG) { | ||
| 269 | + e.printStackTrace(); | ||
| 270 | + } | ||
| 271 | + } | ||
| 272 | + return null; | ||
| 273 | + } | ||
| 274 | + | ||
| 275 | + // ================================================================================ | ||
| 276 | + // Getters | ||
| 277 | + // ================================================================================ | ||
| 278 | + | ||
| 279 | + public JSONObject getConsumerMetadata() { | ||
| 280 | + return consumerMetadata; | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + public String getEligibilityType() { | ||
| 284 | + return eligibilityType; | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + public String getEmail() { | ||
| 288 | + return email; | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + public JSONArray getFavoriteCouponsets() { | ||
| 292 | + return favoriteCouponsets; | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + public ArrayList<String> getFavoriteCouponsetsList() { | ||
| 296 | + return jsonArrayToList(favoriteCouponsets); | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + public boolean isEligible() { | ||
| 300 | + return isEligible; | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + public String getMsisdn() { | ||
| 304 | + return msisdn; | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + public String getProfileMetadata() { | ||
| 308 | + return profileMetadata; | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + public JSONObject getQuestionnaire() { | ||
| 312 | + return questionnaire; | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + public JSONObject getQuestionnaireAnswers() { | ||
| 316 | + return questionnaireAnswers; | ||
| 317 | + } | ||
| 318 | + | ||
| 319 | + public JSONObject getUserAnswers() { | ||
| 320 | + return userAnswers; | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + public String getUserId() { | ||
| 324 | + return userId; | ||
| 325 | + } | ||
| 326 | + | ||
| 327 | + public JSONArray getUserSegments() { | ||
| 328 | + return userSegments; | ||
| 329 | + } | ||
| 330 | + | ||
| 331 | + public ArrayList<String> getUserSegmentsList() { | ||
| 332 | + return jsonArrayToList(userSegments); | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + public String getUuid() { | ||
| 336 | + return uuid; | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + // ================================================================================ | ||
| 340 | + // Setters | ||
| 341 | + // ================================================================================ | ||
| 342 | + | ||
| 343 | + public void setConsumerMetadata(JSONObject consumerMetadata) { | ||
| 344 | + this.consumerMetadata = consumerMetadata; | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + public void setEligibilityType(String eligibilityType) { | ||
| 348 | + this.eligibilityType = eligibilityType; | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + public void setEmail(String email) { | ||
| 352 | + this.email = email; | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + public void setFavoriteCouponsets(JSONArray favoriteCouponsets) { | ||
| 356 | + this.favoriteCouponsets = favoriteCouponsets; | ||
| 357 | + } | ||
| 358 | + | ||
| 359 | + public void setEligible(boolean eligible) { | ||
| 360 | + isEligible = eligible; | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | + public void setMsisdn(String msisdn) { | ||
| 364 | + this.msisdn = msisdn; | ||
| 365 | + } | ||
| 366 | + | ||
| 367 | + public void setProfileMetadata(String profileMetadata) { | ||
| 368 | + this.profileMetadata = profileMetadata; | ||
| 369 | + } | ||
| 370 | + | ||
| 371 | + public void setQuestionnaire(JSONObject questionnaire) { | ||
| 372 | + this.questionnaire = questionnaire; | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + public void setQuestionnaireAnswers(JSONObject questionnaireAnswers) { | ||
| 376 | + this.questionnaireAnswers = questionnaireAnswers; | ||
| 377 | + } | ||
| 378 | + | ||
| 379 | + public void setUserAnswers(JSONObject userAnswers) { | ||
| 380 | + this.userAnswers = userAnswers; | ||
| 381 | + } | ||
| 382 | + | ||
| 383 | + public void setUserId(String userId) { | ||
| 384 | + this.userId = userId; | ||
| 385 | + } | ||
| 386 | + | ||
| 387 | + public void setUserSegments(JSONArray userSegments) { | ||
| 388 | + this.userSegments = userSegments; | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + public void setUuid(String uuid) { | ||
| 392 | + this.uuid = uuid; | ||
| 393 | + } | ||
| 394 | + | ||
| 395 | + @Override | ||
| 396 | + public int describeContents() { | ||
| 397 | + return 0; | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + public static final Creator<User> CREATOR = new Creator<User>() { | ||
| 401 | + public User createFromParcel(Parcel source) { | ||
| 402 | + return new User(source); | ||
| 403 | + } | ||
| 404 | + | ||
| 405 | + public User[] newArray(int size) { | ||
| 406 | + return new User[size]; | ||
| 407 | + } | ||
| 408 | + }; | ||
| 409 | + | ||
| 410 | + private ArrayList<String> jsonArrayToList(JSONArray jArray) { | ||
| 411 | + ArrayList<String> listData = new ArrayList<String>(); | ||
| 412 | + if (jArray != null) { | ||
| 413 | + for (int i = 0; i < jArray.length(); i++) { | ||
| 414 | + listData.add(jArray.optString(i)); | ||
| 415 | + } | ||
| 416 | + } | ||
| 417 | + return listData; | ||
| 418 | + } | ||
| 419 | +} |
| ... | @@ -5,6 +5,7 @@ import java.util.concurrent.TimeUnit; | ... | @@ -5,6 +5,7 @@ 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; | ||
| 8 | import retrofit2.Retrofit; | 9 | import retrofit2.Retrofit; |
| 9 | import retrofit2.converter.gson.GsonConverterFactory; | 10 | import retrofit2.converter.gson.GsonConverterFactory; |
| 10 | 11 | ||
| ... | @@ -48,11 +49,11 @@ public class ApiClient { | ... | @@ -48,11 +49,11 @@ public class ApiClient { |
| 48 | 49 | ||
| 49 | private static OkHttpClient getClient() { | 50 | private static OkHttpClient getClient() { |
| 50 | /* Logs Enabled */ | 51 | /* Logs Enabled */ |
| 51 | -// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); | 52 | + HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); |
| 52 | -// interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); | 53 | + interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); |
| 53 | 54 | ||
| 54 | return new OkHttpClient.Builder() | 55 | return new OkHttpClient.Builder() |
| 55 | -// .addInterceptor(interceptor) // Logs Enabled | 56 | + .addInterceptor(interceptor) // Logs Enabled |
| 56 | .connectTimeout(30, TimeUnit.SECONDS) | 57 | .connectTimeout(30, TimeUnit.SECONDS) |
| 57 | .writeTimeout(30, TimeUnit.SECONDS) | 58 | .writeTimeout(30, TimeUnit.SECONDS) |
| 58 | .readTimeout(30, TimeUnit.SECONDS) | 59 | .readTimeout(30, TimeUnit.SECONDS) | ... | ... |
| ... | @@ -32,7 +32,7 @@ public interface ApiService { | ... | @@ -32,7 +32,7 @@ public interface ApiService { |
| 32 | 32 | ||
| 33 | @Headers("Content-Type: application/json") | 33 | @Headers("Content-Type: application/json") |
| 34 | @POST("/partners/dei/app_login") | 34 | @POST("/partners/dei/app_login") |
| 35 | - Call<ResponseBody> dehUser(@Body RequestBody request, | 35 | + Call<ResponseBody> loginUser(@Body RequestBody request, |
| 36 | @Header(WarpConstants.HEADER_DATE) String timeStamp, | 36 | @Header(WarpConstants.HEADER_DATE) String timeStamp, |
| 37 | @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, | 37 | @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, |
| 38 | @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | 38 | @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, |
| ... | @@ -41,14 +41,16 @@ public interface ApiService { | ... | @@ -41,14 +41,16 @@ public interface ApiService { |
| 41 | @Header(WarpConstants.HEADER_SIGNATURE) String signature); | 41 | @Header(WarpConstants.HEADER_SIGNATURE) String signature); |
| 42 | 42 | ||
| 43 | @Headers("Content-Type: application/json") | 43 | @Headers("Content-Type: application/json") |
| 44 | - @POST("/partners/dei/verify") | 44 | + @POST("/oauth/{appUuid}/context") |
| 45 | - Call<ResponseBody> verifyUser(@Body RequestBody request, | 45 | + Call<ResponseBody> getUser(@Path("appUuid") String appUuid, |
| 46 | + @Body RequestBody request, | ||
| 46 | @Header(WarpConstants.HEADER_DATE) String timeStamp, | 47 | @Header(WarpConstants.HEADER_DATE) String timeStamp, |
| 47 | @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, | 48 | @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, |
| 48 | @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | 49 | @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, |
| 49 | @Header(WarpConstants.HEADER_CHANNEL) String channel, | 50 | @Header(WarpConstants.HEADER_CHANNEL) String channel, |
| 50 | @Header(WarpConstants.HEADER_WEB_ID) String webId, | 51 | @Header(WarpConstants.HEADER_WEB_ID) String webId, |
| 51 | - @Header(WarpConstants.HEADER_SIGNATURE) String signature); | 52 | + @Header(WarpConstants.HEADER_SIGNATURE) String signature, |
| 53 | + @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer); | ||
| 52 | 54 | ||
| 53 | @Headers("Content-Type: application/json") | 55 | @Headers("Content-Type: application/json") |
| 54 | @POST("/oauth/{appUuid}/logout") | 56 | @POST("/oauth/{appUuid}/logout") |
| ... | @@ -59,7 +61,8 @@ public interface ApiService { | ... | @@ -59,7 +61,8 @@ public interface ApiService { |
| 59 | @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | 61 | @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, |
| 60 | @Header(WarpConstants.HEADER_CHANNEL) String channel, | 62 | @Header(WarpConstants.HEADER_CHANNEL) String channel, |
| 61 | @Header(WarpConstants.HEADER_WEB_ID) String webId, | 63 | @Header(WarpConstants.HEADER_WEB_ID) String webId, |
| 62 | - @Header(WarpConstants.HEADER_SIGNATURE) String signature); | 64 | + @Header(WarpConstants.HEADER_SIGNATURE) String signature, |
| 65 | + @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer); | ||
| 63 | 66 | ||
| 64 | @Headers("Content-Type: application/json") | 67 | @Headers("Content-Type: application/json") |
| 65 | @POST("/user/v5/{appUuid}/logout") | 68 | @POST("/user/v5/{appUuid}/logout") |
| ... | @@ -70,7 +73,8 @@ public interface ApiService { | ... | @@ -70,7 +73,8 @@ public interface ApiService { |
| 70 | @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | 73 | @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, |
| 71 | @Header(WarpConstants.HEADER_CHANNEL) String channel, | 74 | @Header(WarpConstants.HEADER_CHANNEL) String channel, |
| 72 | @Header(WarpConstants.HEADER_WEB_ID) String webId, | 75 | @Header(WarpConstants.HEADER_WEB_ID) String webId, |
| 73 | - @Header(WarpConstants.HEADER_SIGNATURE) String signature); | 76 | + @Header(WarpConstants.HEADER_SIGNATURE) String signature, |
| 77 | + @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer); | ||
| 74 | 78 | ||
| 75 | @Headers("Content-Type: application/json") | 79 | @Headers("Content-Type: application/json") |
| 76 | @POST("/oauth/{appUuid}/context") | 80 | @POST("/oauth/{appUuid}/context") | ... | ... |
| ... | @@ -29,12 +29,14 @@ import org.json.JSONException; | ... | @@ -29,12 +29,14 @@ import org.json.JSONException; |
| 29 | import org.json.JSONObject; | 29 | import org.json.JSONObject; |
| 30 | 30 | ||
| 31 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
| 32 | +import java.util.LinkedHashMap; | ||
| 32 | 33 | ||
| 33 | import ly.warp.sdk.Warply; | 34 | import ly.warp.sdk.Warply; |
| 34 | import ly.warp.sdk.db.WarplyDBHelper; | 35 | import ly.warp.sdk.db.WarplyDBHelper; |
| 35 | import ly.warp.sdk.io.models.BannerItem; | 36 | import ly.warp.sdk.io.models.BannerItem; |
| 36 | import ly.warp.sdk.io.models.Campaign; | 37 | import ly.warp.sdk.io.models.Campaign; |
| 37 | import ly.warp.sdk.io.models.CouponList; | 38 | import ly.warp.sdk.io.models.CouponList; |
| 39 | +import ly.warp.sdk.io.models.Couponset; | ||
| 38 | import ly.warp.sdk.utils.managers.WarplyManager; | 40 | import ly.warp.sdk.utils.managers.WarplyManager; |
| 39 | 41 | ||
| 40 | /** | 42 | /** |
| ... | @@ -54,6 +56,7 @@ public class WarplyManagerHelper { | ... | @@ -54,6 +56,7 @@ public class WarplyManagerHelper { |
| 54 | private static CouponList mCouponRedeemedList = new CouponList(); | 56 | private static CouponList mCouponRedeemedList = new CouponList(); |
| 55 | private static ArrayList<Campaign> mCampaignListAll = new ArrayList<Campaign>(); | 57 | private static ArrayList<Campaign> mCampaignListAll = new ArrayList<Campaign>(); |
| 56 | private static ArrayList<BannerItem> mBannerListAll = new ArrayList<BannerItem>(); | 58 | private static ArrayList<BannerItem> mBannerListAll = new ArrayList<BannerItem>(); |
| 59 | + private static LinkedHashMap<String, ArrayList<Couponset>> mCouponsetCategorizedMap = new LinkedHashMap<>(); | ||
| 57 | 60 | ||
| 58 | // =========================================================== | 61 | // =========================================================== |
| 59 | // Methods for/from SuperClass/Interfaces | 62 | // Methods for/from SuperClass/Interfaces |
| ... | @@ -81,6 +84,15 @@ public class WarplyManagerHelper { | ... | @@ -81,6 +84,15 @@ public class WarplyManagerHelper { |
| 81 | return mBannerListAll; | 84 | return mBannerListAll; |
| 82 | } | 85 | } |
| 83 | 86 | ||
| 87 | + public static void setCouponsetCategorizedMap(LinkedHashMap<String, ArrayList<Couponset>> couponsetMap) { | ||
| 88 | + mCouponsetCategorizedMap.clear(); | ||
| 89 | + mCouponsetCategorizedMap.putAll(couponsetMap); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public static LinkedHashMap<String, ArrayList<Couponset>> getCouponsetCategorizedMap() { | ||
| 93 | + return mCouponsetCategorizedMap; | ||
| 94 | + } | ||
| 95 | + | ||
| 84 | public static void setCouponRedeemedList(CouponList couponRedeemedList) { | 96 | public static void setCouponRedeemedList(CouponList couponRedeemedList) { |
| 85 | mCouponRedeemedList.clear(); | 97 | mCouponRedeemedList.clear(); |
| 86 | mCouponRedeemedList.addAll(couponRedeemedList); | 98 | mCouponRedeemedList.addAll(couponRedeemedList); | ... | ... |
| ... | @@ -45,6 +45,8 @@ import org.json.JSONObject; | ... | @@ -45,6 +45,8 @@ import org.json.JSONObject; |
| 45 | 45 | ||
| 46 | import java.util.ArrayList; | 46 | import java.util.ArrayList; |
| 47 | import java.util.Collections; | 47 | import java.util.Collections; |
| 48 | +import java.util.HashMap; | ||
| 49 | +import java.util.LinkedHashMap; | ||
| 48 | import java.util.LinkedHashSet; | 50 | import java.util.LinkedHashSet; |
| 49 | import java.util.List; | 51 | import java.util.List; |
| 50 | import java.util.Map; | 52 | import java.util.Map; |
| ... | @@ -62,8 +64,7 @@ import ly.warp.sdk.io.models.Coupon; | ... | @@ -62,8 +64,7 @@ import ly.warp.sdk.io.models.Coupon; |
| 62 | import ly.warp.sdk.io.models.CouponList; | 64 | import ly.warp.sdk.io.models.CouponList; |
| 63 | import ly.warp.sdk.io.models.Couponset; | 65 | import ly.warp.sdk.io.models.Couponset; |
| 64 | import ly.warp.sdk.io.models.Merchant; | 66 | import ly.warp.sdk.io.models.Merchant; |
| 65 | -import ly.warp.sdk.io.models.NewCampaign; | 67 | +import ly.warp.sdk.io.models.User; |
| 66 | -import ly.warp.sdk.io.models.RedeemedSMHistoryModel; | ||
| 67 | import ly.warp.sdk.io.request.WarplyRefreshTokenRequest; | 68 | import ly.warp.sdk.io.request.WarplyRefreshTokenRequest; |
| 68 | import ly.warp.sdk.io.volley.ApiClient; | 69 | import ly.warp.sdk.io.volley.ApiClient; |
| 69 | import ly.warp.sdk.io.volley.ApiService; | 70 | import ly.warp.sdk.io.volley.ApiService; |
| ... | @@ -149,7 +150,8 @@ public class WarplyManager { | ... | @@ -149,7 +150,8 @@ public class WarplyManager { |
| 149 | new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | 150 | new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), |
| 150 | "mobile", | 151 | "mobile", |
| 151 | webId, | 152 | webId, |
| 152 | - WarpUtils.produceSignature(apiKey + timeStamp) | 153 | + WarpUtils.produceSignature(apiKey + timeStamp), |
| 154 | + "Bearer " + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | ||
| 153 | ) | 155 | ) |
| 154 | : service.logoutUser(WarplyProperty.getAppUuid(Warply.getWarplyContext()), | 156 | : service.logoutUser(WarplyProperty.getAppUuid(Warply.getWarplyContext()), |
| 155 | loginRequest, | 157 | loginRequest, |
| ... | @@ -158,7 +160,8 @@ public class WarplyManager { | ... | @@ -158,7 +160,8 @@ public class WarplyManager { |
| 158 | new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | 160 | new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), |
| 159 | "mobile", | 161 | "mobile", |
| 160 | webId, | 162 | webId, |
| 161 | - WarpUtils.produceSignature(apiKey + timeStamp) | 163 | + WarpUtils.produceSignature(apiKey + timeStamp), |
| 164 | + "Bearer " + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | ||
| 162 | ); | 165 | ); |
| 163 | logoutCall.enqueue(new Callback<ResponseBody>() { | 166 | logoutCall.enqueue(new Callback<ResponseBody>() { |
| 164 | @Override | 167 | @Override |
| ... | @@ -187,23 +190,23 @@ public class WarplyManager { | ... | @@ -187,23 +190,23 @@ public class WarplyManager { |
| 187 | }); | 190 | }); |
| 188 | } | 191 | } |
| 189 | 192 | ||
| 190 | - public static void getDehUser(String email, final CallbackReceiver<JSONObject> receiver) { | 193 | + public static void login(String email, final CallbackReceiver<JSONObject> receiver) { |
| 191 | - WarpUtils.log("************* WARPLY Deh User Request ********************"); | 194 | + WarpUtils.log("************* WARPLY Login Request ********************"); |
| 192 | - WarpUtils.log("[WARP Trace] WARPLY Deh User Request is active"); | 195 | + WarpUtils.log("[WARP Trace] WARPLY Login is active"); |
| 193 | WarpUtils.log("**************************************************"); | 196 | WarpUtils.log("**************************************************"); |
| 194 | 197 | ||
| 195 | - if (WarplyDBHelper.getInstance(Warply.getWarplyContext()).isTableNotEmpty("auth")) { | 198 | +// if (WarplyDBHelper.getInstance(Warply.getWarplyContext()).isTableNotEmpty("auth")) { |
| 196 | - JSONObject newResult = new JSONObject(); | 199 | +// JSONObject newResult = new JSONObject(); |
| 197 | - try { | 200 | +// try { |
| 198 | - newResult.putOpt("status", 1); | 201 | +// newResult.putOpt("status", 1); |
| 199 | - newResult.putOpt("message", "Success"); | 202 | +// newResult.putOpt("message", "Success"); |
| 200 | - receiver.onSuccess(newResult); | 203 | +// receiver.onSuccess(newResult); |
| 201 | - } catch (JSONException e) { | 204 | +// } catch (JSONException e) { |
| 202 | - e.printStackTrace(); | 205 | +// e.printStackTrace(); |
| 203 | - receiver.onFailure(2); | 206 | +// receiver.onFailure(2); |
| 204 | - } | 207 | +// } |
| 205 | - return; | 208 | +// return; |
| 206 | - } | 209 | +// } |
| 207 | 210 | ||
| 208 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | 211 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); |
| 209 | 212 | ||
| ... | @@ -216,7 +219,7 @@ public class WarplyManager { | ... | @@ -216,7 +219,7 @@ public class WarplyManager { |
| 216 | 219 | ||
| 217 | RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); | 220 | RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); |
| 218 | 221 | ||
| 219 | - Call<ResponseBody> loginCall = service.dehUser( | 222 | + Call<ResponseBody> loginCall = service.loginUser( |
| 220 | loginRequest, | 223 | loginRequest, |
| 221 | timeStamp, | 224 | timeStamp, |
| 222 | "android:" + Warply.getWarplyContext().getPackageName(), | 225 | "android:" + Warply.getWarplyContext().getPackageName(), |
| ... | @@ -238,7 +241,7 @@ public class WarplyManager { | ... | @@ -238,7 +241,7 @@ public class WarplyManager { |
| 238 | } | 241 | } |
| 239 | 242 | ||
| 240 | if (jobjLoginResponse != null && jobjLoginResponse.has("status") && jobjLoginResponse.optString("status", "2").equals("1")) { | 243 | if (jobjLoginResponse != null && jobjLoginResponse.has("status") && jobjLoginResponse.optString("status", "2").equals("1")) { |
| 241 | - JSONObject tokens = jobjLoginResponse.optJSONObject("result"); | 244 | + JSONObject tokens = jobjLoginResponse.optJSONObject("tokens"); |
| 242 | if (tokens != null) { | 245 | if (tokens != null) { |
| 243 | WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveClientAccess(tokens.optString("client_id", ""), tokens.optString("client_secret", "")); | 246 | WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveClientAccess(tokens.optString("client_id", ""), tokens.optString("client_secret", "")); |
| 244 | 247 | ||
| ... | @@ -269,80 +272,93 @@ public class WarplyManager { | ... | @@ -269,80 +272,93 @@ public class WarplyManager { |
| 269 | }); | 272 | }); |
| 270 | } | 273 | } |
| 271 | 274 | ||
| 272 | - public static void verifyTicket(String ticket, String guid, final CallbackReceiver<JSONObject> receiver) { | 275 | + public static void getUser(final CallbackReceiver<User> receiver) { |
| 273 | - WarpUtils.log("************* WARPLY Verify Ticket Request ********************"); | 276 | + WarpUtils.log("************* WARPLY User Request ********************"); |
| 274 | - WarpUtils.log("[WARP Trace] WARPLY Verify Ticket Request is active"); | 277 | + WarpUtils.log("[WARP Trace] WARPLY User Request is active"); |
| 275 | WarpUtils.log("**************************************************"); | 278 | WarpUtils.log("**************************************************"); |
| 276 | 279 | ||
| 277 | - if (WarplyDBHelper.getInstance(Warply.getWarplyContext()).isTableNotEmpty("auth")) { | ||
| 278 | - JSONObject newResult = new JSONObject(); | ||
| 279 | - try { | ||
| 280 | - newResult.putOpt("status", 1); | ||
| 281 | - newResult.putOpt("message", "Success"); | ||
| 282 | - receiver.onSuccess(newResult); | ||
| 283 | - } catch (JSONException e) { | ||
| 284 | - e.printStackTrace(); | ||
| 285 | - receiver.onFailure(2); | ||
| 286 | - } | ||
| 287 | - return; | ||
| 288 | - } | ||
| 289 | - | ||
| 290 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | 280 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); |
| 291 | 281 | ||
| 292 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); | 282 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); |
| 293 | String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); | 283 | String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); |
| 294 | String webId = WarpUtils.getWebId(Warply.getWarplyContext()); | 284 | String webId = WarpUtils.getWebId(Warply.getWarplyContext()); |
| 295 | 285 | ||
| 286 | + Map<String, Object> jsonParamsUser = new ArrayMap<>(); | ||
| 296 | Map<String, Object> jsonParams = new ArrayMap<>(); | 287 | Map<String, Object> jsonParams = new ArrayMap<>(); |
| 297 | - jsonParams.put("app_uuid", WarplyProperty.getAppUuid(Warply.getWarplyContext())); | 288 | + jsonParams.put("action", "handle_user_details"); |
| 298 | - jsonParams.put("guid", guid); | 289 | + jsonParams.put("process", "get"); |
| 299 | - jsonParams.put("ticket", ticket); | ||
| 300 | 290 | ||
| 301 | - RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); | 291 | + jsonParamsUser.put("consumer_data", jsonParams); |
| 292 | + RequestBody userRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsUser)).toString()); | ||
| 302 | 293 | ||
| 303 | - Call<ResponseBody> loginCall = service.verifyUser( | 294 | + Call<ResponseBody> profileCall = service.getUser( |
| 304 | - loginRequest, | 295 | + WarplyProperty.getAppUuid(Warply.getWarplyContext()), |
| 296 | + userRequest, | ||
| 305 | timeStamp, | 297 | timeStamp, |
| 306 | "android:" + Warply.getWarplyContext().getPackageName(), | 298 | "android:" + Warply.getWarplyContext().getPackageName(), |
| 307 | new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | 299 | new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), |
| 308 | "mobile", | 300 | "mobile", |
| 309 | webId, | 301 | webId, |
| 310 | - WarpUtils.produceSignature(apiKey + timeStamp) | 302 | + WarpUtils.produceSignature(apiKey + timeStamp), |
| 303 | + "Bearer " + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | ||
| 311 | ); | 304 | ); |
| 312 | 305 | ||
| 313 | - loginCall.enqueue(new Callback<ResponseBody>() { | 306 | + profileCall.enqueue(new Callback<ResponseBody>() { |
| 314 | @Override | 307 | @Override |
| 315 | public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { | 308 | public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { |
| 316 | if (response.code() == 200 && response.body() != null) { | 309 | if (response.code() == 200 && response.body() != null) { |
| 317 | - JSONObject jobjLoginResponse = null; | 310 | + JSONObject jobjUserResponse = null; |
| 318 | try { | 311 | try { |
| 319 | - jobjLoginResponse = new JSONObject(response.body().string()); | 312 | + jobjUserResponse = new JSONObject(response.body().string()); |
| 320 | } catch (Exception e) { | 313 | } catch (Exception e) { |
| 321 | e.printStackTrace(); | 314 | e.printStackTrace(); |
| 322 | } | 315 | } |
| 323 | 316 | ||
| 324 | - if (jobjLoginResponse != null && jobjLoginResponse.has("result") && jobjLoginResponse.optString("result", "2").equals("1")) { | 317 | + if (jobjUserResponse != null && jobjUserResponse.has("status") && jobjUserResponse.optString("status", "2").equals("1")) { |
| 325 | - JSONObject tokens = jobjLoginResponse.optJSONObject("tokens"); | 318 | + JSONObject jUserBody = null; |
| 326 | - if (tokens != null) { | ||
| 327 | - WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveClientAccess(tokens.optString("client_id", ""), tokens.optString("client_secret", "")); | ||
| 328 | - | ||
| 329 | - WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveAuthAccess(tokens.optString("access_token", ""), tokens.optString("refresh_token", "")); | ||
| 330 | - | ||
| 331 | - JSONObject newResult = new JSONObject(); | ||
| 332 | try { | 319 | try { |
| 333 | - newResult.putOpt("status", 1); | 320 | + jUserBody = jobjUserResponse.optJSONObject("result"); |
| 334 | - newResult.putOpt("message", "Success"); | 321 | + } catch (Exception e) { |
| 335 | - receiver.onSuccess(newResult); | ||
| 336 | - } catch (JSONException e) { | ||
| 337 | e.printStackTrace(); | 322 | e.printStackTrace(); |
| 338 | - receiver.onFailure(2); | ||
| 339 | } | 323 | } |
| 324 | + | ||
| 325 | + if (jUserBody != null) { | ||
| 326 | + User user = new User(jUserBody); | ||
| 327 | + | ||
| 328 | + receiver.onSuccess(user); | ||
| 340 | } else { | 329 | } else { |
| 341 | receiver.onFailure(2); | 330 | receiver.onFailure(2); |
| 342 | } | 331 | } |
| 343 | } else { | 332 | } else { |
| 344 | receiver.onFailure(2); | 333 | receiver.onFailure(2); |
| 345 | } | 334 | } |
| 335 | + } else if (response.code() == 401) { | ||
| 336 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
| 337 | + @Override | ||
| 338 | + public void onSuccess(JSONObject result) { | ||
| 339 | + int status = result.optInt("status", 2); | ||
| 340 | + if (status == 1) | ||
| 341 | + getUser(receiver/*, tries*/); | ||
| 342 | + else { | ||
| 343 | +// if (tries < MAX_RETRIES) { | ||
| 344 | +// getUser(receiver, (tries + 1)); | ||
| 345 | +// } else { | ||
| 346 | + receiver.onFailure(status); | ||
| 347 | +// } | ||
| 348 | + } | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + @Override | ||
| 352 | + public void onFailure(int errorCode) { | ||
| 353 | +// if (tries < MAX_RETRIES) { | ||
| 354 | +// getUser(receiver, (tries + 1)); | ||
| 355 | +// } else { | ||
| 356 | + receiver.onFailure(2); | ||
| 357 | +// } | ||
| 358 | + } | ||
| 359 | + }); | ||
| 360 | + } else if (String.valueOf(response.code()).startsWith("5")) { | ||
| 361 | + receiver.onFailure(2); | ||
| 346 | } else { | 362 | } else { |
| 347 | receiver.onFailure(response.code()); | 363 | receiver.onFailure(response.code()); |
| 348 | } | 364 | } |
| ... | @@ -387,7 +403,59 @@ public class WarplyManager { | ... | @@ -387,7 +403,59 @@ public class WarplyManager { |
| 387 | }, executorService); | 403 | }, executorService); |
| 388 | } | 404 | } |
| 389 | 405 | ||
| 390 | - public static void getCouponsets(final CallbackReceiver<ArrayList<Couponset>> receiver) { | 406 | + private static LinkedHashMap<String, ArrayList<Couponset>> mergeCouponsetsResults(ArrayList<Couponset> resultCouponsets, ArrayList<Merchant> resultMerchants) { |
| 407 | + LinkedHashMap<String, ArrayList<Couponset>> categorizedMap = new LinkedHashMap<>(); | ||
| 408 | + | ||
| 409 | + if (resultCouponsets == null || resultCouponsets.isEmpty()) { | ||
| 410 | + WarplyManagerHelper.setCouponsetCategorizedMap(categorizedMap); | ||
| 411 | + return categorizedMap; | ||
| 412 | + } | ||
| 413 | + | ||
| 414 | + HashMap<String, Merchant> merchantLookup = new HashMap<>(); | ||
| 415 | + if (resultMerchants != null) { | ||
| 416 | + for (Merchant merchant : resultMerchants) { | ||
| 417 | + if (merchant.getUuid() != null) { | ||
| 418 | + merchantLookup.put(merchant.getUuid(), merchant); | ||
| 419 | + } | ||
| 420 | + } | ||
| 421 | + } | ||
| 422 | + | ||
| 423 | + ArrayList<Couponset> topOffers = new ArrayList<>(); | ||
| 424 | + LinkedHashMap<String, ArrayList<Couponset>> categoryGroups = new LinkedHashMap<>(); | ||
| 425 | + | ||
| 426 | + for (Couponset couponset : resultCouponsets) { | ||
| 427 | + // Match merchant by merchantUuid | ||
| 428 | + if (couponset.getMerchantUuid() != null && merchantLookup.containsKey(couponset.getMerchantUuid())) { | ||
| 429 | + couponset.setMerchant(merchantLookup.get(couponset.getMerchantUuid())); | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + if (couponset.isPromoted()) { | ||
| 433 | + topOffers.add(couponset); | ||
| 434 | + } else { | ||
| 435 | + String category = couponset.getOfferCategory(); | ||
| 436 | + if (category == null || category.isEmpty()) { | ||
| 437 | + category = "Other"; | ||
| 438 | + } | ||
| 439 | + categoryGroups.computeIfAbsent(category, k -> new ArrayList<>()).add(couponset); | ||
| 440 | + } | ||
| 441 | + } | ||
| 442 | + | ||
| 443 | + if (!topOffers.isEmpty()) { | ||
| 444 | + categorizedMap.put("Top offers", topOffers); | ||
| 445 | + } | ||
| 446 | + | ||
| 447 | + for (Map.Entry<String, ArrayList<Couponset>> entry : categoryGroups.entrySet()) { | ||
| 448 | + if (!entry.getValue().isEmpty()) { | ||
| 449 | + categorizedMap.put(entry.getKey(), entry.getValue()); | ||
| 450 | + } | ||
| 451 | + } | ||
| 452 | + | ||
| 453 | + WarplyManagerHelper.setCouponsetCategorizedMap(categorizedMap); | ||
| 454 | + | ||
| 455 | + return categorizedMap; | ||
| 456 | + } | ||
| 457 | + | ||
| 458 | + public static void getCouponsets(final CallbackReceiver<LinkedHashMap<String, ArrayList<Couponset>>> receiver) { | ||
| 391 | WarpUtils.log("************* WARPLY Couponsets Request ********************"); | 459 | WarpUtils.log("************* WARPLY Couponsets Request ********************"); |
| 392 | WarpUtils.log("[WARP Trace] WARPLY Couponsets Request is active"); | 460 | WarpUtils.log("[WARP Trace] WARPLY Couponsets Request is active"); |
| 393 | WarpUtils.log("**************************************************"); | 461 | WarpUtils.log("**************************************************"); |
| ... | @@ -399,14 +467,15 @@ public class WarplyManager { | ... | @@ -399,14 +467,15 @@ public class WarplyManager { |
| 399 | ListenableFuture<ArrayList<Merchant>> futureMerchants = getMerchantsRetro(service); | 467 | ListenableFuture<ArrayList<Merchant>> futureMerchants = getMerchantsRetro(service); |
| 400 | 468 | ||
| 401 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCouponsets, futureMerchants); | 469 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCouponsets, futureMerchants); |
| 402 | - ListenableFuture<ArrayList<Couponset>> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { | 470 | + ListenableFuture<LinkedHashMap<String, ArrayList<Couponset>>> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { |
| 403 | - ArrayList<Couponset> resultCoupons = (ArrayList<Couponset>) results.get(0); | 471 | + ArrayList<Couponset> resultCouponsets = (ArrayList<Couponset>) results.get(0); |
| 404 | - return executorService.submit(() -> resultCoupons/*createCouponSetsSection(resultCoupons)*/); | 472 | + ArrayList<Merchant> resultMerchants = (ArrayList<Merchant>) results.get(1); |
| 473 | + return executorService.submit(() -> mergeCouponsetsResults(resultCouponsets, resultMerchants)); | ||
| 405 | }, executorService); | 474 | }, executorService); |
| 406 | 475 | ||
| 407 | - Futures.addCallback(mergedResultFuture, new FutureCallback<ArrayList<Couponset>>() { | 476 | + Futures.addCallback(mergedResultFuture, new FutureCallback<LinkedHashMap<String, ArrayList<Couponset>>>() { |
| 408 | @Override | 477 | @Override |
| 409 | - public void onSuccess(ArrayList<Couponset> mergedResult) { | 478 | + public void onSuccess(LinkedHashMap<String, ArrayList<Couponset>> mergedResult) { |
| 410 | executorService.shutdownNow(); | 479 | executorService.shutdownNow(); |
| 411 | new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mergedResult)); | 480 | new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mergedResult)); |
| 412 | } | 481 | } |
| ... | @@ -511,10 +580,10 @@ public class WarplyManager { | ... | @@ -511,10 +580,10 @@ public class WarplyManager { |
| 511 | jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext())); | 580 | jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext())); |
| 512 | jsonParamsMerchants.put("shops", jsonParams); | 581 | jsonParamsMerchants.put("shops", jsonParams); |
| 513 | 582 | ||
| 514 | - RequestBody couponsetsRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsMerchants)).toString()); | 583 | + RequestBody merchantsRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsMerchants)).toString()); |
| 515 | Call<ResponseBody> merchantsCall = service.getMerchants( | 584 | Call<ResponseBody> merchantsCall = service.getMerchants( |
| 516 | WarplyProperty.getAppUuid(Warply.getWarplyContext()), | 585 | WarplyProperty.getAppUuid(Warply.getWarplyContext()), |
| 517 | - couponsetsRequest, | 586 | + merchantsRequest, |
| 518 | timeStamp, | 587 | timeStamp, |
| 519 | "android:" + Warply.getWarplyContext().getPackageName(), | 588 | "android:" + Warply.getWarplyContext().getPackageName(), |
| 520 | new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | 589 | new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), |
| ... | @@ -546,8 +615,8 @@ public class WarplyManager { | ... | @@ -546,8 +615,8 @@ public class WarplyManager { |
| 546 | JSONArray finalJMerchantsBody = jMerchantsBody; | 615 | JSONArray finalJMerchantsBody = jMerchantsBody; |
| 547 | executorCouponsets.submit(() -> { | 616 | executorCouponsets.submit(() -> { |
| 548 | for (int i = 0; i < finalJMerchantsBody.length(); ++i) { | 617 | for (int i = 0; i < finalJMerchantsBody.length(); ++i) { |
| 549 | - Merchant tempCouponset = new Merchant(finalJMerchantsBody.optJSONObject(i)); | 618 | + Merchant tempMerchant = new Merchant(finalJMerchantsBody.optJSONObject(i)); |
| 550 | - mMerchantList.add(tempCouponset); | 619 | + mMerchantList.add(tempMerchant); |
| 551 | } | 620 | } |
| 552 | 621 | ||
| 553 | executorCouponsets.shutdownNow(); | 622 | executorCouponsets.shutdownNow(); |
| ... | @@ -574,15 +643,15 @@ public class WarplyManager { | ... | @@ -574,15 +643,15 @@ public class WarplyManager { |
| 574 | return future; | 643 | return future; |
| 575 | } | 644 | } |
| 576 | 645 | ||
| 577 | - private static ArrayList<BannerItem> mergeCampaignResults(ArrayList<Campaign> resultCampaigns, ArrayList<Campaign> resultPersonalizedCampaigns, ArrayList<Content> resultArticles) { | 646 | + private static ArrayList<BannerItem> mergeCampaignResults(ArrayList<Campaign> resultCampaigns, /*ArrayList<Campaign> resultPersonalizedCampaigns,*/ ArrayList<Content> resultArticles) { |
| 578 | ArrayList<BannerItem> allItems = new ArrayList<>(); | 647 | ArrayList<BannerItem> allItems = new ArrayList<>(); |
| 579 | 648 | ||
| 580 | ArrayList<Campaign> newCampaignList = new ArrayList<Campaign>(); | 649 | ArrayList<Campaign> newCampaignList = new ArrayList<Campaign>(); |
| 581 | ArrayList<Campaign> campaignLoyaltyList = new ArrayList<>(); | 650 | ArrayList<Campaign> campaignLoyaltyList = new ArrayList<>(); |
| 582 | if (resultCampaigns != null && !resultCampaigns.isEmpty()) | 651 | if (resultCampaigns != null && !resultCampaigns.isEmpty()) |
| 583 | newCampaignList.addAll(resultCampaigns); | 652 | newCampaignList.addAll(resultCampaigns); |
| 584 | - if (resultPersonalizedCampaigns != null && !resultPersonalizedCampaigns.isEmpty()) | 653 | +// if (resultPersonalizedCampaigns != null && !resultPersonalizedCampaigns.isEmpty()) |
| 585 | - newCampaignList.addAll(resultPersonalizedCampaigns); | 654 | +// newCampaignList.addAll(resultPersonalizedCampaigns); |
| 586 | 655 | ||
| 587 | if (newCampaignList != null && !newCampaignList.isEmpty()) { | 656 | if (newCampaignList != null && !newCampaignList.isEmpty()) { |
| 588 | newCampaignList.stream().filter((item) -> item.getType().equals("contest") || item.getOfferCategory().equals("contest")); | 657 | newCampaignList.stream().filter((item) -> item.getType().equals("contest") || item.getOfferCategory().equals("contest")); |
| ... | @@ -616,18 +685,18 @@ public class WarplyManager { | ... | @@ -616,18 +685,18 @@ public class WarplyManager { |
| 616 | WarpUtils.log("**************************************************"); | 685 | WarpUtils.log("**************************************************"); |
| 617 | 686 | ||
| 618 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | 687 | ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); |
| 619 | - ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(3)); | 688 | + ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2)); |
| 620 | 689 | ||
| 621 | ListenableFuture<ArrayList<Campaign>> futureCampaigns = getCampaignsRetro(service); | 690 | ListenableFuture<ArrayList<Campaign>> futureCampaigns = getCampaignsRetro(service); |
| 622 | - ListenableFuture<ArrayList<Campaign>> futurePersonalizedCampaigns = getCampaignsPersonalizedRetro(service, 0); | 691 | +// ListenableFuture<ArrayList<Campaign>> futurePersonalizedCampaigns = getCampaignsPersonalizedRetro(service, 0); |
| 623 | ListenableFuture<ArrayList<Content>> futureArticles = getArticlesRetro(service, new JSONArray().put("Carousel")); | 692 | ListenableFuture<ArrayList<Content>> futureArticles = getArticlesRetro(service, new JSONArray().put("Carousel")); |
| 624 | 693 | ||
| 625 | - ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCampaigns, futurePersonalizedCampaigns, futureArticles); | 694 | + ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCampaigns, /*futurePersonalizedCampaigns,*/ futureArticles); |
| 626 | ListenableFuture<ArrayList<BannerItem>> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { | 695 | ListenableFuture<ArrayList<BannerItem>> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { |
| 627 | ArrayList<Campaign> resultCampaigns = (ArrayList<Campaign>) results.get(0); | 696 | ArrayList<Campaign> resultCampaigns = (ArrayList<Campaign>) results.get(0); |
| 628 | - ArrayList<Campaign> resultPersonalizedCampaigns = (ArrayList<Campaign>) results.get(1); | 697 | +// ArrayList<Campaign> resultPersonalizedCampaigns = (ArrayList<Campaign>) results.get(1); |
| 629 | - ArrayList<Content> resultArticles = (ArrayList<Content>) results.get(2); | 698 | + ArrayList<Content> resultArticles = (ArrayList<Content>) results.get(1); |
| 630 | - return executorService.submit(() -> mergeCampaignResults(resultCampaigns, resultPersonalizedCampaigns, resultArticles)); | 699 | + return executorService.submit(() -> mergeCampaignResults(resultCampaigns, /*resultPersonalizedCampaigns,*/ resultArticles)); |
| 631 | }, executorService); | 700 | }, executorService); |
| 632 | 701 | ||
| 633 | Futures.addCallback(mergedResultFuture, new FutureCallback<ArrayList<BannerItem>>() { | 702 | Futures.addCallback(mergedResultFuture, new FutureCallback<ArrayList<BannerItem>>() { |
| ... | @@ -689,25 +758,7 @@ public class WarplyManager { | ... | @@ -689,25 +758,7 @@ public class WarplyManager { |
| 689 | JSONArray finalCampaignsJBody = jCampaignsBody; | 758 | JSONArray finalCampaignsJBody = jCampaignsBody; |
| 690 | executorCampaigns.submit(() -> { | 759 | executorCampaigns.submit(() -> { |
| 691 | for (int i = 0; i < finalCampaignsJBody.length(); ++i) { | 760 | for (int i = 0; i < finalCampaignsJBody.length(); ++i) { |
| 692 | - Campaign camp = new Campaign(); | 761 | + Campaign camp = new Campaign(finalCampaignsJBody.optJSONObject(i)); |
| 693 | - NewCampaign tempNewCampaign = new NewCampaign(finalCampaignsJBody.optJSONObject(i)); | ||
| 694 | - | ||
| 695 | - camp.setIndexUrl(tempNewCampaign.getCampaignUrl()); | ||
| 696 | - camp.setLogoUrl(tempNewCampaign.getBannerImageMobile()); | ||
| 697 | - camp.setMessage(tempNewCampaign.getMessage()); | ||
| 698 | - camp.setOfferCategory(tempNewCampaign.getCommunicationCategory()); | ||
| 699 | - camp.setSessionUUID(tempNewCampaign.getCommunicationUUID()); | ||
| 700 | - camp.setTitle(tempNewCampaign.getTitle()); | ||
| 701 | - camp.setSubtitle(tempNewCampaign.getSubtitle()); | ||
| 702 | - camp.setSorting(tempNewCampaign.getSorting()); | ||
| 703 | - camp.setNew(tempNewCampaign.getIsNew()); | ||
| 704 | - camp.setType(tempNewCampaign.getCampaignType()); | ||
| 705 | - camp.setEndDate(tempNewCampaign.getEndDate()); | ||
| 706 | - camp.setStartDate(tempNewCampaign.getStartDate()); | ||
| 707 | - camp.setShowExpiration(tempNewCampaign.isShowExpiration()); | ||
| 708 | - camp.setCouponImg(tempNewCampaign.getCouponImg()); | ||
| 709 | - camp.setFilter(tempNewCampaign.getFilter()); | ||
| 710 | - | ||
| 711 | mCampaignsList.add(camp); | 762 | mCampaignsList.add(camp); |
| 712 | } | 763 | } |
| 713 | 764 | ||
| ... | @@ -784,25 +835,7 @@ public class WarplyManager { | ... | @@ -784,25 +835,7 @@ public class WarplyManager { |
| 784 | JSONArray finalCampaignsJBody = jCampaignsBody; | 835 | JSONArray finalCampaignsJBody = jCampaignsBody; |
| 785 | executorPersonalizedCampaigns.submit(() -> { | 836 | executorPersonalizedCampaigns.submit(() -> { |
| 786 | for (int i = 0; i < finalCampaignsJBody.length(); ++i) { | 837 | for (int i = 0; i < finalCampaignsJBody.length(); ++i) { |
| 787 | - Campaign camp = new Campaign(); | 838 | + Campaign camp = new Campaign(finalCampaignsJBody.optJSONObject(i)); |
| 788 | - NewCampaign tempNewCampaign = new NewCampaign(finalCampaignsJBody.optJSONObject(i)); | ||
| 789 | - | ||
| 790 | - camp.setIndexUrl(tempNewCampaign.getCampaignUrl()); | ||
| 791 | - camp.setLogoUrl(tempNewCampaign.getBannerImageMobile()); | ||
| 792 | - camp.setMessage(tempNewCampaign.getMessage()); | ||
| 793 | - camp.setOfferCategory(tempNewCampaign.getCommunicationCategory()); | ||
| 794 | - camp.setSessionUUID(tempNewCampaign.getCommunicationUUID()); | ||
| 795 | - camp.setTitle(tempNewCampaign.getTitle()); | ||
| 796 | - camp.setSubtitle(tempNewCampaign.getSubtitle()); | ||
| 797 | - camp.setSorting(tempNewCampaign.getSorting()); | ||
| 798 | - camp.setNew(tempNewCampaign.getIsNew()); | ||
| 799 | - camp.setType(tempNewCampaign.getCampaignType()); | ||
| 800 | - camp.setEndDate(tempNewCampaign.getEndDate()); | ||
| 801 | - camp.setStartDate(tempNewCampaign.getStartDate()); | ||
| 802 | - camp.setShowExpiration(tempNewCampaign.isShowExpiration()); | ||
| 803 | - camp.setCouponImg(tempNewCampaign.getCouponImg()); | ||
| 804 | - camp.setFilter(tempNewCampaign.getFilter()); | ||
| 805 | - | ||
| 806 | mCampaignsList.add(camp); | 839 | mCampaignsList.add(camp); |
| 807 | } | 840 | } |
| 808 | 841 | ... | ... |
| ... | @@ -24,7 +24,8 @@ | ... | @@ -24,7 +24,8 @@ |
| 24 | android:layout_gravity="center" | 24 | android:layout_gravity="center" |
| 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 | 29 | ||
| 29 | <LinearLayout | 30 | <LinearLayout |
| 30 | android:layout_width="0dp" | 31 | android:layout_width="0dp" |
| ... | @@ -85,12 +86,12 @@ | ... | @@ -85,12 +86,12 @@ |
| 85 | android:layout_width="wrap_content" | 86 | android:layout_width="wrap_content" |
| 86 | android:layout_height="wrap_content" | 87 | android:layout_height="wrap_content" |
| 87 | android:background="@android:color/transparent" | 88 | android:background="@android:color/transparent" |
| 88 | - app:layout_constraintStart_toStartOf="@+id/banner_viewpager" | ||
| 89 | - app:layout_constraintEnd_toEndOf="@+id/banner_viewpager" | ||
| 90 | - app:layout_constraintTop_toTopOf="@+id/banner_viewpager" | ||
| 91 | - app:layout_constraintBottom_toBottomOf="@+id/banner_viewpager" | ||
| 92 | android:translationZ="100dp" | 89 | android:translationZ="100dp" |
| 93 | android:visibility="gone" | 90 | android:visibility="gone" |
| 91 | + app:layout_constraintBottom_toBottomOf="@+id/banner_viewpager" | ||
| 92 | + app:layout_constraintEnd_toEndOf="@+id/banner_viewpager" | ||
| 93 | + app:layout_constraintStart_toStartOf="@+id/banner_viewpager" | ||
| 94 | + app:layout_constraintTop_toTopOf="@+id/banner_viewpager" | ||
| 94 | tools:visibility="visible"> | 95 | tools:visibility="visible"> |
| 95 | 96 | ||
| 96 | <ProgressBar | 97 | <ProgressBar |
| ... | @@ -103,374 +104,31 @@ | ... | @@ -103,374 +104,31 @@ |
| 103 | </RelativeLayout> | 104 | </RelativeLayout> |
| 104 | </androidx.constraintlayout.widget.ConstraintLayout> | 105 | </androidx.constraintlayout.widget.ConstraintLayout> |
| 105 | 106 | ||
| 106 | - <!-- Top Offers Section --> | ||
| 107 | - <RelativeLayout | ||
| 108 | - android:layout_width="match_parent" | ||
| 109 | - android:layout_height="wrap_content" | ||
| 110 | - android:layout_marginTop="24dp"> | ||
| 111 | - | ||
| 112 | - <LinearLayout | ||
| 113 | - android:id="@+id/ll_recycler1" | ||
| 114 | - android:layout_width="match_parent" | ||
| 115 | - android:layout_height="wrap_content" | ||
| 116 | - android:layout_gravity="center" | ||
| 117 | - android:orientation="horizontal" | ||
| 118 | - android:paddingHorizontal="16dp"> | ||
| 119 | - | ||
| 120 | - <TextView | ||
| 121 | - android:id="@+id/tv_recycler_category1" | ||
| 122 | - android:layout_width="0dp" | ||
| 123 | - android:layout_height="wrap_content" | ||
| 124 | - android:layout_weight="1" | ||
| 125 | - android:textColor="@color/custom_black2" | ||
| 126 | - android:textSize="16sp" | ||
| 127 | - tools:text="Top Offers (10)" /> | ||
| 128 | - | ||
| 129 | - <TextView | ||
| 130 | - android:id="@+id/tv_recycler_all1" | ||
| 131 | - android:layout_width="wrap_content" | ||
| 132 | - android:layout_height="wrap_content" | ||
| 133 | - android:background="@drawable/demo_shape_transparent_border_black" | ||
| 134 | - android:paddingHorizontal="16dp" | ||
| 135 | - android:paddingVertical="5dp" | ||
| 136 | - android:text="@string/demo_all" | ||
| 137 | - android:textColor="@color/custom_black3" | ||
| 138 | - android:textSize="14sp" /> | ||
| 139 | - </LinearLayout> | ||
| 140 | - | ||
| 141 | - <androidx.recyclerview.widget.RecyclerView | ||
| 142 | - android:id="@+id/rl_recycler1" | ||
| 143 | - android:layout_width="match_parent" | ||
| 144 | - android:layout_height="wrap_content" | ||
| 145 | - android:layout_below="@+id/ll_recycler1" | ||
| 146 | - android:layout_marginTop="16dp" | ||
| 147 | - android:clipToPadding="false" | ||
| 148 | - android:orientation="horizontal" | ||
| 149 | - android:paddingHorizontal="16dp" /> | ||
| 150 | - </RelativeLayout> | ||
| 151 | - | ||
| 152 | - <!-- Favorites Section --> | ||
| 153 | - <RelativeLayout | ||
| 154 | - android:layout_width="match_parent" | ||
| 155 | - android:layout_height="wrap_content" | ||
| 156 | - android:layout_marginTop="48dp"> | ||
| 157 | - | ||
| 158 | - <LinearLayout | ||
| 159 | - android:id="@+id/ll_recycler2" | ||
| 160 | - android:layout_width="match_parent" | ||
| 161 | - android:layout_height="wrap_content" | ||
| 162 | - android:layout_gravity="center" | ||
| 163 | - android:orientation="horizontal" | ||
| 164 | - android:paddingHorizontal="16dp"> | ||
| 165 | - | ||
| 166 | - <TextView | ||
| 167 | - android:id="@+id/tv_recycler_category2" | ||
| 168 | - android:layout_width="0dp" | ||
| 169 | - android:layout_height="wrap_content" | ||
| 170 | - android:layout_weight="1" | ||
| 171 | - android:textColor="@color/custom_black2" | ||
| 172 | - android:textSize="16sp" | ||
| 173 | - tools:text="Favorites (10)" /> | ||
| 174 | - | ||
| 175 | - <TextView | ||
| 176 | - android:id="@+id/tv_recycler_all2" | ||
| 177 | - android:layout_width="wrap_content" | ||
| 178 | - android:layout_height="wrap_content" | ||
| 179 | - android:background="@drawable/demo_shape_transparent_border_black" | ||
| 180 | - android:paddingHorizontal="16dp" | ||
| 181 | - android:paddingVertical="5dp" | ||
| 182 | - android:text="@string/demo_all" | ||
| 183 | - android:textColor="@color/custom_black3" | ||
| 184 | - android:textSize="14sp" /> | ||
| 185 | - </LinearLayout> | ||
| 186 | - | ||
| 187 | - <androidx.recyclerview.widget.RecyclerView | ||
| 188 | - android:id="@+id/rl_recycler2" | ||
| 189 | - android:layout_width="match_parent" | ||
| 190 | - android:layout_height="wrap_content" | ||
| 191 | - android:layout_below="@+id/ll_recycler2" | ||
| 192 | - android:layout_marginTop="16dp" | ||
| 193 | - android:clipToPadding="false" | ||
| 194 | - android:orientation="horizontal" | ||
| 195 | - android:paddingHorizontal="16dp" /> | ||
| 196 | - </RelativeLayout> | ||
| 197 | - | ||
| 198 | - <!-- Viability Section --> | ||
| 199 | - <RelativeLayout | ||
| 200 | - android:layout_width="match_parent" | ||
| 201 | - android:layout_height="wrap_content" | ||
| 202 | - android:layout_marginTop="48dp"> | ||
| 203 | - | ||
| 204 | - <LinearLayout | ||
| 205 | - android:id="@+id/ll_recycler3" | ||
| 206 | - android:layout_width="match_parent" | ||
| 207 | - android:layout_height="wrap_content" | ||
| 208 | - android:layout_gravity="center" | ||
| 209 | - android:orientation="horizontal" | ||
| 210 | - android:paddingHorizontal="16dp"> | ||
| 211 | - | ||
| 212 | - <TextView | ||
| 213 | - android:id="@+id/tv_recycler_category3" | ||
| 214 | - android:layout_width="0dp" | ||
| 215 | - android:layout_height="wrap_content" | ||
| 216 | - android:layout_weight="1" | ||
| 217 | - android:textColor="@color/custom_black2" | ||
| 218 | - android:textSize="16sp" | ||
| 219 | - tools:text="Viability (10)" /> | ||
| 220 | - | ||
| 221 | - <TextView | ||
| 222 | - android:id="@+id/tv_recycler_all3" | ||
| 223 | - android:layout_width="wrap_content" | ||
| 224 | - android:layout_height="wrap_content" | ||
| 225 | - android:background="@drawable/demo_shape_transparent_border_black" | ||
| 226 | - android:paddingHorizontal="16dp" | ||
| 227 | - android:paddingVertical="5dp" | ||
| 228 | - android:text="@string/demo_all" | ||
| 229 | - android:textColor="@color/custom_black3" | ||
| 230 | - android:textSize="14sp" /> | ||
| 231 | - </LinearLayout> | ||
| 232 | - | ||
| 233 | - <androidx.recyclerview.widget.RecyclerView | ||
| 234 | - android:id="@+id/rl_recycler3" | ||
| 235 | - android:layout_width="match_parent" | ||
| 236 | - android:layout_height="wrap_content" | ||
| 237 | - android:layout_below="@+id/ll_recycler3" | ||
| 238 | - android:layout_marginTop="16dp" | ||
| 239 | - android:clipToPadding="false" | ||
| 240 | - android:orientation="horizontal" | ||
| 241 | - android:paddingHorizontal="16dp" /> | ||
| 242 | - </RelativeLayout> | ||
| 243 | - | ||
| 244 | - <!-- Family Section --> | ||
| 245 | - <RelativeLayout | ||
| 246 | - android:layout_width="match_parent" | ||
| 247 | - android:layout_height="wrap_content" | ||
| 248 | - android:layout_marginTop="48dp"> | ||
| 249 | - | ||
| 250 | - <LinearLayout | ||
| 251 | - android:id="@+id/ll_recycler4" | ||
| 252 | - android:layout_width="match_parent" | ||
| 253 | - android:layout_height="wrap_content" | ||
| 254 | - android:layout_gravity="center" | ||
| 255 | - android:orientation="horizontal" | ||
| 256 | - android:paddingHorizontal="16dp"> | ||
| 257 | - | ||
| 258 | - <TextView | ||
| 259 | - android:id="@+id/tv_recycler_category4" | ||
| 260 | - android:layout_width="0dp" | ||
| 261 | - android:layout_height="wrap_content" | ||
| 262 | - android:layout_weight="1" | ||
| 263 | - android:textColor="@color/custom_black2" | ||
| 264 | - android:textSize="16sp" | ||
| 265 | - tools:text="Family (10)" /> | ||
| 266 | - | ||
| 267 | - <TextView | ||
| 268 | - android:id="@+id/tv_recycler_all4" | ||
| 269 | - android:layout_width="wrap_content" | ||
| 270 | - android:layout_height="wrap_content" | ||
| 271 | - android:background="@drawable/demo_shape_transparent_border_black" | ||
| 272 | - android:paddingHorizontal="16dp" | ||
| 273 | - android:paddingVertical="5dp" | ||
| 274 | - android:text="@string/demo_all" | ||
| 275 | - android:textColor="@color/custom_black3" | ||
| 276 | - android:textSize="14sp" /> | ||
| 277 | - </LinearLayout> | ||
| 278 | - | ||
| 279 | - <androidx.recyclerview.widget.RecyclerView | ||
| 280 | - android:id="@+id/rl_recycler4" | ||
| 281 | - android:layout_width="match_parent" | ||
| 282 | - android:layout_height="wrap_content" | ||
| 283 | - android:layout_below="@+id/ll_recycler4" | ||
| 284 | - android:layout_marginTop="16dp" | ||
| 285 | - android:clipToPadding="false" | ||
| 286 | - android:orientation="horizontal" | ||
| 287 | - android:paddingHorizontal="16dp" /> | ||
| 288 | - </RelativeLayout> | ||
| 289 | - | ||
| 290 | - <!-- Food and Coffee Section --> | ||
| 291 | - <RelativeLayout | ||
| 292 | - android:layout_width="match_parent" | ||
| 293 | - android:layout_height="wrap_content" | ||
| 294 | - android:layout_marginTop="48dp"> | ||
| 295 | - | ||
| 296 | - <LinearLayout | ||
| 297 | - android:id="@+id/ll_recycler5" | ||
| 298 | - android:layout_width="match_parent" | ||
| 299 | - android:layout_height="wrap_content" | ||
| 300 | - android:layout_gravity="center" | ||
| 301 | - android:orientation="horizontal" | ||
| 302 | - android:paddingHorizontal="16dp"> | ||
| 303 | - | ||
| 304 | - <TextView | ||
| 305 | - android:id="@+id/tv_recycler_category5" | ||
| 306 | - android:layout_width="0dp" | ||
| 307 | - android:layout_height="wrap_content" | ||
| 308 | - android:layout_weight="1" | ||
| 309 | - android:textColor="@color/custom_black2" | ||
| 310 | - android:textSize="16sp" | ||
| 311 | - tools:text="Food and Coffee (10)" /> | ||
| 312 | - | ||
| 313 | - <TextView | ||
| 314 | - android:id="@+id/tv_recycler_all5" | ||
| 315 | - android:layout_width="wrap_content" | ||
| 316 | - android:layout_height="wrap_content" | ||
| 317 | - android:background="@drawable/demo_shape_transparent_border_black" | ||
| 318 | - android:paddingHorizontal="16dp" | ||
| 319 | - android:paddingVertical="5dp" | ||
| 320 | - android:text="@string/demo_all" | ||
| 321 | - android:textColor="@color/custom_black3" | ||
| 322 | - android:textSize="14sp" /> | ||
| 323 | - </LinearLayout> | ||
| 324 | - | ||
| 325 | - <androidx.recyclerview.widget.RecyclerView | ||
| 326 | - android:id="@+id/rl_recycler5" | ||
| 327 | - android:layout_width="match_parent" | ||
| 328 | - android:layout_height="wrap_content" | ||
| 329 | - android:layout_below="@+id/ll_recycler5" | ||
| 330 | - android:layout_marginTop="16dp" | ||
| 331 | - android:clipToPadding="false" | ||
| 332 | - android:orientation="horizontal" | ||
| 333 | - android:paddingHorizontal="16dp" /> | ||
| 334 | - </RelativeLayout> | ||
| 335 | - | ||
| 336 | - <!-- Travelling Section --> | ||
| 337 | - <RelativeLayout | ||
| 338 | - android:layout_width="match_parent" | ||
| 339 | - android:layout_height="wrap_content" | ||
| 340 | - android:layout_marginTop="48dp"> | ||
| 341 | - | ||
| 342 | - <LinearLayout | ||
| 343 | - android:id="@+id/ll_recycler6" | ||
| 344 | - android:layout_width="match_parent" | ||
| 345 | - android:layout_height="wrap_content" | ||
| 346 | - android:layout_gravity="center" | ||
| 347 | - android:orientation="horizontal" | ||
| 348 | - android:paddingHorizontal="16dp"> | ||
| 349 | - | ||
| 350 | - <TextView | ||
| 351 | - android:id="@+id/tv_recycler_category6" | ||
| 352 | - android:layout_width="0dp" | ||
| 353 | - android:layout_height="wrap_content" | ||
| 354 | - android:layout_weight="1" | ||
| 355 | - android:textColor="@color/custom_black2" | ||
| 356 | - android:textSize="16sp" | ||
| 357 | - tools:text="Travelling (10)" /> | ||
| 358 | - | ||
| 359 | - <TextView | ||
| 360 | - android:id="@+id/tv_recycler_all6" | ||
| 361 | - android:layout_width="wrap_content" | ||
| 362 | - android:layout_height="wrap_content" | ||
| 363 | - android:background="@drawable/demo_shape_transparent_border_black" | ||
| 364 | - android:paddingHorizontal="16dp" | ||
| 365 | - android:paddingVertical="5dp" | ||
| 366 | - android:text="@string/demo_all" | ||
| 367 | - android:textColor="@color/custom_black3" | ||
| 368 | - android:textSize="14sp" /> | ||
| 369 | - </LinearLayout> | ||
| 370 | - | ||
| 371 | - <androidx.recyclerview.widget.RecyclerView | ||
| 372 | - android:id="@+id/rl_recycler6" | ||
| 373 | - android:layout_width="match_parent" | ||
| 374 | - android:layout_height="wrap_content" | ||
| 375 | - android:layout_below="@+id/ll_recycler6" | ||
| 376 | - android:layout_marginTop="16dp" | ||
| 377 | - android:clipToPadding="false" | ||
| 378 | - android:orientation="horizontal" | ||
| 379 | - android:paddingHorizontal="16dp" /> | ||
| 380 | - </RelativeLayout> | ||
| 381 | - | ||
| 382 | - <!-- Kids Section --> | ||
| 383 | <RelativeLayout | 107 | <RelativeLayout |
| 108 | + android:id="@+id/rl_sections_loading" | ||
| 384 | android:layout_width="match_parent" | 109 | android:layout_width="match_parent" |
| 385 | android:layout_height="wrap_content" | 110 | android:layout_height="wrap_content" |
| 386 | - android:layout_marginTop="48dp"> | 111 | + android:background="@android:color/transparent" |
| 387 | - | 112 | + android:layout_marginTop="48dp" |
| 388 | - <LinearLayout | 113 | + android:translationZ="100dp" |
| 389 | - android:id="@+id/ll_recycler7" | 114 | + android:visibility="gone" |
| 390 | - android:layout_width="match_parent" | 115 | + tools:visibility="visible"> |
| 391 | - android:layout_height="wrap_content" | ||
| 392 | - android:layout_gravity="center" | ||
| 393 | - android:orientation="horizontal" | ||
| 394 | - android:paddingHorizontal="16dp"> | ||
| 395 | - | ||
| 396 | - <TextView | ||
| 397 | - android:id="@+id/tv_recycler_category7" | ||
| 398 | - android:layout_width="0dp" | ||
| 399 | - android:layout_height="wrap_content" | ||
| 400 | - android:layout_weight="1" | ||
| 401 | - android:textColor="@color/custom_black2" | ||
| 402 | - android:textSize="16sp" | ||
| 403 | - tools:text="Kids (10)" /> | ||
| 404 | - | ||
| 405 | - <TextView | ||
| 406 | - android:id="@+id/tv_recycler_all7" | ||
| 407 | - android:layout_width="wrap_content" | ||
| 408 | - android:layout_height="wrap_content" | ||
| 409 | - android:background="@drawable/demo_shape_transparent_border_black" | ||
| 410 | - android:paddingHorizontal="16dp" | ||
| 411 | - android:paddingVertical="5dp" | ||
| 412 | - android:text="@string/demo_all" | ||
| 413 | - android:textColor="@color/custom_black3" | ||
| 414 | - android:textSize="14sp" /> | ||
| 415 | - </LinearLayout> | ||
| 416 | 116 | ||
| 417 | - <androidx.recyclerview.widget.RecyclerView | 117 | + <ProgressBar |
| 418 | - android:id="@+id/rl_recycler7" | 118 | + android:layout_width="40dp" |
| 419 | - android:layout_width="match_parent" | 119 | + android:layout_height="40dp" |
| 420 | - android:layout_height="wrap_content" | 120 | + android:layout_centerInParent="true" |
| 421 | - android:layout_below="@+id/ll_recycler7" | 121 | + android:indeterminate="true" |
| 422 | - android:layout_marginTop="16dp" | 122 | + android:indeterminateTint="@color/custom_light_blue" |
| 423 | - android:clipToPadding="false" | 123 | + android:indeterminateTintMode="src_atop" /> |
| 424 | - android:orientation="horizontal" | ||
| 425 | - android:paddingHorizontal="16dp" /> | ||
| 426 | </RelativeLayout> | 124 | </RelativeLayout> |
| 427 | 125 | ||
| 428 | - <!-- Purchases Section --> | ||
| 429 | - <RelativeLayout | ||
| 430 | - android:layout_width="match_parent" | ||
| 431 | - android:layout_height="wrap_content" | ||
| 432 | - android:layout_marginTop="48dp" | ||
| 433 | - android:layout_marginBottom="48dp"> | ||
| 434 | - | ||
| 435 | <LinearLayout | 126 | <LinearLayout |
| 436 | - android:id="@+id/ll_recycler8" | 127 | + android:id="@+id/ll_sections_container" |
| 437 | android:layout_width="match_parent" | 128 | android:layout_width="match_parent" |
| 438 | android:layout_height="wrap_content" | 129 | android:layout_height="wrap_content" |
| 439 | - android:layout_gravity="center" | 130 | + android:layout_marginBottom="48dp" |
| 440 | - android:orientation="horizontal" | 131 | + android:orientation="vertical" /> |
| 441 | - android:paddingHorizontal="16dp"> | ||
| 442 | - | ||
| 443 | - <TextView | ||
| 444 | - android:id="@+id/tv_recycler_category8" | ||
| 445 | - android:layout_width="0dp" | ||
| 446 | - android:layout_height="wrap_content" | ||
| 447 | - android:layout_weight="1" | ||
| 448 | - android:textColor="@color/custom_black2" | ||
| 449 | - android:textSize="16sp" | ||
| 450 | - tools:text="Purchases (10)" /> | ||
| 451 | - | ||
| 452 | - <TextView | ||
| 453 | - android:id="@+id/tv_recycler_all8" | ||
| 454 | - android:layout_width="wrap_content" | ||
| 455 | - android:layout_height="wrap_content" | ||
| 456 | - android:background="@drawable/demo_shape_transparent_border_black" | ||
| 457 | - android:paddingHorizontal="16dp" | ||
| 458 | - android:paddingVertical="5dp" | ||
| 459 | - android:text="@string/demo_all" | ||
| 460 | - android:textColor="@color/custom_black3" | ||
| 461 | - android:textSize="14sp" /> | ||
| 462 | - </LinearLayout> | ||
| 463 | - | ||
| 464 | - <androidx.recyclerview.widget.RecyclerView | ||
| 465 | - android:id="@+id/rl_recycler8" | ||
| 466 | - android:layout_width="match_parent" | ||
| 467 | - android:layout_height="wrap_content" | ||
| 468 | - android:layout_below="@+id/ll_recycler8" | ||
| 469 | - android:layout_marginTop="16dp" | ||
| 470 | - android:clipToPadding="false" | ||
| 471 | - android:orientation="horizontal" | ||
| 472 | - android:paddingHorizontal="16dp" /> | ||
| 473 | - </RelativeLayout> | ||
| 474 | </LinearLayout> | 132 | </LinearLayout> |
| 475 | </androidx.core.widget.NestedScrollView> | 133 | </androidx.core.widget.NestedScrollView> |
| 476 | </RelativeLayout> | 134 | </RelativeLayout> | ... | ... |
| ... | @@ -6,15 +6,12 @@ | ... | @@ -6,15 +6,12 @@ |
| 6 | android:layout_height="260dp" | 6 | android:layout_height="260dp" |
| 7 | android:background="@drawable/demo_shape_white_border_grey"> | 7 | android:background="@drawable/demo_shape_white_border_grey"> |
| 8 | 8 | ||
| 9 | - <!-- Main Offer Image --> | ||
| 10 | <ImageView | 9 | <ImageView |
| 11 | android:id="@+id/iv_offer_image" | 10 | android:id="@+id/iv_offer_image" |
| 12 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
| 13 | android:layout_height="140dp" | 12 | android:layout_height="140dp" |
| 14 | - android:scaleType="centerCrop" | 13 | + android:scaleType="centerCrop" /> |
| 15 | - tools:src="@drawable/demo_home_banner1" /> | ||
| 16 | 14 | ||
| 17 | - <!-- Heart Icon (Favorite) --> | ||
| 18 | <ImageView | 15 | <ImageView |
| 19 | android:id="@+id/iv_favorite" | 16 | android:id="@+id/iv_favorite" |
| 20 | android:layout_width="32dp" | 17 | android:layout_width="32dp" |
| ... | @@ -22,7 +19,6 @@ | ... | @@ -22,7 +19,6 @@ |
| 22 | android:layout_margin="8dp" | 19 | android:layout_margin="8dp" |
| 23 | android:src="@drawable/demo_heart" /> | 20 | android:src="@drawable/demo_heart" /> |
| 24 | 21 | ||
| 25 | - <!-- Price Badge --> | ||
| 26 | <TextView | 22 | <TextView |
| 27 | android:id="@+id/tv_price" | 23 | android:id="@+id/tv_price" |
| 28 | android:layout_width="68dp" | 24 | android:layout_width="68dp" |
| ... | @@ -35,7 +31,6 @@ | ... | @@ -35,7 +31,6 @@ |
| 35 | android:textSize="16sp" | 31 | android:textSize="16sp" |
| 36 | tools:text="17,95€" /> | 32 | tools:text="17,95€" /> |
| 37 | 33 | ||
| 38 | - <!-- Content Section --> | ||
| 39 | <androidx.constraintlayout.widget.ConstraintLayout | 34 | <androidx.constraintlayout.widget.ConstraintLayout |
| 40 | android:layout_width="match_parent" | 35 | android:layout_width="match_parent" |
| 41 | android:layout_height="match_parent" | 36 | android:layout_height="match_parent" |
| ... | @@ -50,7 +45,6 @@ | ... | @@ -50,7 +45,6 @@ |
| 50 | android:orientation="vertical" | 45 | android:orientation="vertical" |
| 51 | app:layout_constraintGuide_percent="0.7" /> | 46 | app:layout_constraintGuide_percent="0.7" /> |
| 52 | 47 | ||
| 53 | - <!-- Title --> | ||
| 54 | <TextView | 48 | <TextView |
| 55 | android:id="@+id/tv_title" | 49 | android:id="@+id/tv_title" |
| 56 | android:layout_width="0dp" | 50 | android:layout_width="0dp" |
| ... | @@ -63,7 +57,6 @@ | ... | @@ -63,7 +57,6 @@ |
| 63 | app:layout_constraintTop_toTopOf="parent" | 57 | app:layout_constraintTop_toTopOf="parent" |
| 64 | tools:text="Móvo 17,95" /> | 58 | tools:text="Móvo 17,95" /> |
| 65 | 59 | ||
| 66 | - <!-- Description --> | ||
| 67 | <TextView | 60 | <TextView |
| 68 | android:id="@+id/tv_description" | 61 | android:id="@+id/tv_description" |
| 69 | android:layout_width="0dp" | 62 | android:layout_width="0dp" |
| ... | @@ -77,7 +70,6 @@ | ... | @@ -77,7 +70,6 @@ |
| 77 | app:layout_constraintTop_toBottomOf="@+id/tv_title" | 70 | app:layout_constraintTop_toBottomOf="@+id/tv_title" |
| 78 | tools:text="2 πίτσες & Coca-COLA 1,5lt" /> | 71 | tools:text="2 πίτσες & Coca-COLA 1,5lt" /> |
| 79 | 72 | ||
| 80 | - <!-- Validity Date --> | ||
| 81 | <TextView | 73 | <TextView |
| 82 | android:id="@+id/tv_validity" | 74 | android:id="@+id/tv_validity" |
| 83 | android:layout_width="wrap_content" | 75 | android:layout_width="wrap_content" |
| ... | @@ -92,7 +84,6 @@ | ... | @@ -92,7 +84,6 @@ |
| 92 | app:layout_constraintBottom_toBottomOf="parent" | 84 | app:layout_constraintBottom_toBottomOf="parent" |
| 93 | tools:text="έως 30-09" /> | 85 | tools:text="έως 30-09" /> |
| 94 | 86 | ||
| 95 | - <!-- Brand Logo --> | ||
| 96 | <ImageView | 87 | <ImageView |
| 97 | android:id="@+id/iv_logo" | 88 | android:id="@+id/iv_logo" |
| 98 | android:layout_width="60dp" | 89 | android:layout_width="60dp" |
| ... | @@ -100,7 +91,6 @@ | ... | @@ -100,7 +91,6 @@ |
| 100 | android:layout_alignParentEnd="true" | 91 | android:layout_alignParentEnd="true" |
| 101 | android:layout_centerVertical="true" | 92 | android:layout_centerVertical="true" |
| 102 | android:scaleType="centerInside" | 93 | android:scaleType="centerInside" |
| 103 | - app:layout_constraintBottom_toBottomOf="parent" | ||
| 104 | app:layout_constraintEnd_toEndOf="parent" | 94 | app:layout_constraintEnd_toEndOf="parent" |
| 105 | app:layout_constraintTop_toTopOf="parent" | 95 | app:layout_constraintTop_toTopOf="parent" |
| 106 | tools:src="@drawable/demo_avis" /> | 96 | tools:src="@drawable/demo_avis" /> | ... | ... |
| ... | @@ -43,8 +43,8 @@ | ... | @@ -43,8 +43,8 @@ |
| 43 | android:layout_marginBottom="8dp" | 43 | android:layout_marginBottom="8dp" |
| 44 | android:maxLines="1" | 44 | android:maxLines="1" |
| 45 | android:scrollHorizontally="true" | 45 | android:scrollHorizontally="true" |
| 46 | - android:textColor="@color/custom_black2" | 46 | + android:text="@string/welcome_user" |
| 47 | - android:text="@string/welcome_user" /> | 47 | + android:textColor="@color/custom_black2" /> |
| 48 | </RelativeLayout> | 48 | </RelativeLayout> |
| 49 | 49 | ||
| 50 | <ImageView | 50 | <ImageView |
| ... | @@ -83,7 +83,8 @@ | ... | @@ -83,7 +83,8 @@ |
| 83 | android:layout_marginHorizontal="8dp" | 83 | android:layout_marginHorizontal="8dp" |
| 84 | android:layout_marginTop="24dp" | 84 | android:layout_marginTop="24dp" |
| 85 | android:layout_marginBottom="16dp" | 85 | android:layout_marginBottom="16dp" |
| 86 | - android:background="@drawable/shape_rectangle_rounded_white"> | 86 | + android:background="@drawable/shape_rectangle_rounded_white" |
| 87 | + android:visibility="gone"> | ||
| 87 | 88 | ||
| 88 | <LinearLayout | 89 | <LinearLayout |
| 89 | android:id="@+id/ll_sm_flow" | 90 | android:id="@+id/ll_sm_flow" |
| ... | @@ -94,7 +95,8 @@ | ... | @@ -94,7 +95,8 @@ |
| 94 | android:layout_marginStart="16dp" | 95 | android:layout_marginStart="16dp" |
| 95 | android:background="@drawable/selector_button_light_blue" | 96 | android:background="@drawable/selector_button_light_blue" |
| 96 | android:gravity="center" | 97 | android:gravity="center" |
| 97 | - android:orientation="horizontal"> | 98 | + android:orientation="horizontal" |
| 99 | + android:visibility="gone"> | ||
| 98 | 100 | ||
| 99 | <TextView | 101 | <TextView |
| 100 | android:layout_width="wrap_content" | 102 | android:layout_width="wrap_content" |
| ... | @@ -107,5 +109,40 @@ | ... | @@ -107,5 +109,40 @@ |
| 107 | </LinearLayout> | 109 | </LinearLayout> |
| 108 | </RelativeLayout> | 110 | </RelativeLayout> |
| 109 | 111 | ||
| 112 | + <LinearLayout | ||
| 113 | + android:id="@+id/ll_login_view" | ||
| 114 | + android:layout_width="match_parent" | ||
| 115 | + android:layout_height="wrap_content" | ||
| 116 | + android:layout_below="@+id/rl_header" | ||
| 117 | + android:layout_marginTop="24dp" | ||
| 118 | + android:paddingHorizontal="24dp" | ||
| 119 | + android:orientation="vertical"> | ||
| 120 | + | ||
| 121 | + <EditText | ||
| 122 | + android:id="@+id/et_login" | ||
| 123 | + android:layout_width="match_parent" | ||
| 124 | + android:layout_height="wrap_content" | ||
| 125 | + android:inputType="textEmailAddress" | ||
| 126 | + android:text="p.anagnostou+1201@dei.gr"/> | ||
| 127 | + | ||
| 128 | + <LinearLayout | ||
| 129 | + android:id="@+id/ll_login" | ||
| 130 | + android:layout_width="match_parent" | ||
| 131 | + android:layout_height="45dp" | ||
| 132 | + android:layout_marginTop="16dp" | ||
| 133 | + android:background="@drawable/selector_button_light_blue" | ||
| 134 | + android:gravity="center" | ||
| 135 | + android:orientation="horizontal"> | ||
| 136 | + | ||
| 137 | + <TextView | ||
| 138 | + android:layout_width="wrap_content" | ||
| 139 | + android:layout_height="wrap_content" | ||
| 140 | + android:gravity="center" | ||
| 141 | + android:includeFontPadding="false" | ||
| 142 | + android:text="@string/demo_login" | ||
| 143 | + android:textColor="@color/white" | ||
| 144 | + android:textSize="16sp" /> | ||
| 145 | + </LinearLayout> | ||
| 146 | + </LinearLayout> | ||
| 110 | </RelativeLayout> | 147 | </RelativeLayout> |
| 111 | </ScrollView> | 148 | </ScrollView> | ... | ... |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 4 | + android:layout_width="match_parent" | ||
| 5 | + android:layout_height="wrap_content" | ||
| 6 | + android:layout_marginTop="48dp"> | ||
| 7 | + | ||
| 8 | + <LinearLayout | ||
| 9 | + android:id="@+id/ll_section_header" | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:layout_gravity="center" | ||
| 13 | + android:orientation="horizontal" | ||
| 14 | + android:paddingHorizontal="16dp"> | ||
| 15 | + | ||
| 16 | + <TextView | ||
| 17 | + android:id="@+id/tv_section_title" | ||
| 18 | + android:layout_width="0dp" | ||
| 19 | + android:layout_height="wrap_content" | ||
| 20 | + android:layout_weight="1" | ||
| 21 | + android:textColor="@color/custom_black2" | ||
| 22 | + android:textSize="16sp" | ||
| 23 | + tools:text="Top Offers (10)" /> | ||
| 24 | + | ||
| 25 | + <TextView | ||
| 26 | + android:id="@+id/tv_section_all" | ||
| 27 | + android:layout_width="wrap_content" | ||
| 28 | + android:layout_height="wrap_content" | ||
| 29 | + android:background="@drawable/demo_shape_transparent_border_black" | ||
| 30 | + android:paddingHorizontal="16dp" | ||
| 31 | + android:paddingVertical="5dp" | ||
| 32 | + android:text="@string/demo_all" | ||
| 33 | + android:textColor="@color/custom_black3" | ||
| 34 | + android:textSize="14sp" /> | ||
| 35 | + </LinearLayout> | ||
| 36 | + | ||
| 37 | + <androidx.recyclerview.widget.RecyclerView | ||
| 38 | + android:id="@+id/rv_section_list" | ||
| 39 | + android:layout_width="match_parent" | ||
| 40 | + android:layout_height="wrap_content" | ||
| 41 | + android:layout_below="@+id/ll_section_header" | ||
| 42 | + android:layout_marginTop="16dp" | ||
| 43 | + android:clipToPadding="false" | ||
| 44 | + android:orientation="horizontal" | ||
| 45 | + android:paddingHorizontal="16dp" /> | ||
| 46 | +</RelativeLayout> |
| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | <string name="welcome_user">User</string> | 6 | <string name="welcome_user">User</string> |
| 7 | <string name="menu_home">Αρχική</string> | 7 | <string name="menu_home">Αρχική</string> |
| 8 | <string name="demo_home">Αρχική οθόνη</string> | 8 | <string name="demo_home">Αρχική οθόνη</string> |
| 9 | + <string name="demo_login">Σύνδεση</string> | ||
| 9 | <string name="demo_all">Όλα</string> | 10 | <string name="demo_all">Όλα</string> |
| 10 | <string name="demo_offer">Προσφορά</string> | 11 | <string name="demo_offer">Προσφορά</string> |
| 11 | <string name="demo_more">Περισσότερα</string> | 12 | <string name="demo_more">Περισσότερα</string> | ... | ... |
-
Please register or login to post a comment