added back register device request, campaigns and articles implementation, new libs
Showing
22 changed files
with
126 additions
and
239 deletions
.idea/.gitignore
deleted
100644 → 0
.idea/compiler.xml
deleted
100644 → 0
.idea/deploymentTargetDropDown.xml
deleted
100644 → 0
.idea/deploymentTargetSelector.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<project version="4"> | ||
3 | - <component name="deploymentTargetSelector"> | ||
4 | - <selectionStates> | ||
5 | - <SelectionState runConfigName="app"> | ||
6 | - <option name="selectionMode" value="DROPDOWN" /> | ||
7 | - <DropdownSelection timestamp="2025-02-13T08:44:19.612560Z"> | ||
8 | - <Target type="DEFAULT_BOOT"> | ||
9 | - <handle> | ||
10 | - <DeviceId pluginId="PhysicalDevice" identifier="serial=R58M42EM7YT" /> | ||
11 | - </handle> | ||
12 | - </Target> | ||
13 | - </DropdownSelection> | ||
14 | - <DialogSelection /> | ||
15 | - </SelectionState> | ||
16 | - </selectionStates> | ||
17 | - </component> | ||
18 | -</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
.idea/gradle.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<project version="4"> | ||
3 | - <component name="GradleMigrationSettings" migrationVersion="1" /> | ||
4 | - <component name="GradleSettings"> | ||
5 | - <option name="linkedExternalProjectsSettings"> | ||
6 | - <GradleProjectSettings> | ||
7 | - <option name="testRunner" value="CHOOSE_PER_TEST" /> | ||
8 | - <option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||
9 | - <option name="gradleHome" value="$PROJECT_DIR$/../../../../../../gradle-6.6.1" /> | ||
10 | - <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" /> | ||
11 | - <option name="modules"> | ||
12 | - <set> | ||
13 | - <option value="$PROJECT_DIR$" /> | ||
14 | - <option value="$PROJECT_DIR$/app" /> | ||
15 | - <option value="$PROJECT_DIR$/warply_android_sdk" /> | ||
16 | - </set> | ||
17 | - </option> | ||
18 | - <option name="resolveExternalAnnotations" value="false" /> | ||
19 | - </GradleProjectSettings> | ||
20 | - </option> | ||
21 | - </component> | ||
22 | -</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -<component name="InspectionProjectProfileManager"> | ||
2 | - <profile version="1.0"> | ||
3 | - <option name="myName" value="Project Default" /> | ||
4 | - <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true"> | ||
5 | - <option name="TOP_LEVEL_CLASS_OPTIONS"> | ||
6 | - <value> | ||
7 | - <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||
8 | - <option name="REQUIRED_TAGS" value="" /> | ||
9 | - </value> | ||
10 | - </option> | ||
11 | - <option name="INNER_CLASS_OPTIONS"> | ||
12 | - <value> | ||
13 | - <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||
14 | - <option name="REQUIRED_TAGS" value="" /> | ||
15 | - </value> | ||
16 | - </option> | ||
17 | - <option name="METHOD_OPTIONS"> | ||
18 | - <value> | ||
19 | - <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||
20 | - <option name="REQUIRED_TAGS" value="@return@param@throws or @exception" /> | ||
21 | - </value> | ||
22 | - </option> | ||
23 | - <option name="FIELD_OPTIONS"> | ||
24 | - <value> | ||
25 | - <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||
26 | - <option name="REQUIRED_TAGS" value="" /> | ||
27 | - </value> | ||
28 | - </option> | ||
29 | - <option name="IGNORE_DEPRECATED" value="false" /> | ||
30 | - <option name="IGNORE_JAVADOC_PERIOD" value="true" /> | ||
31 | - <option name="IGNORE_DUPLICATED_THROWS" value="false" /> | ||
32 | - <option name="IGNORE_POINT_TO_ITSELF" value="false" /> | ||
33 | - <option name="myAdditionalJavadocTags" value="guide" /> | ||
34 | - </inspection_tool> | ||
35 | - </profile> | ||
36 | -</component> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
.idea/jarRepositories.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<project version="4"> | ||
3 | - <component name="RemoteRepositoriesConfiguration"> | ||
4 | - <remote-repository> | ||
5 | - <option name="id" value="central" /> | ||
6 | - <option name="name" value="Maven Central repository" /> | ||
7 | - <option name="url" value="https://repo1.maven.org/maven2" /> | ||
8 | - </remote-repository> | ||
9 | - <remote-repository> | ||
10 | - <option name="id" value="jboss.community" /> | ||
11 | - <option name="name" value="JBoss Community repository" /> | ||
12 | - <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> | ||
13 | - </remote-repository> | ||
14 | - <remote-repository> | ||
15 | - <option name="id" value="maven" /> | ||
16 | - <option name="name" value="maven" /> | ||
17 | - <option name="url" value="https://developer.huawei.com/repo/" /> | ||
18 | - </remote-repository> | ||
19 | - <remote-repository> | ||
20 | - <option name="id" value="MavenRepo" /> | ||
21 | - <option name="name" value="MavenRepo" /> | ||
22 | - <option name="url" value="https://repo.maven.apache.org/maven2/" /> | ||
23 | - </remote-repository> | ||
24 | - <remote-repository> | ||
25 | - <option name="id" value="Google" /> | ||
26 | - <option name="name" value="Google" /> | ||
27 | - <option name="url" value="https://dl.google.com/dl/android/maven2/" /> | ||
28 | - </remote-repository> | ||
29 | - <remote-repository> | ||
30 | - <option name="id" value="maven2" /> | ||
31 | - <option name="name" value="maven2" /> | ||
32 | - <option name="url" value="https://plugins.gradle.org/m2/" /> | ||
33 | - </remote-repository> | ||
34 | - </component> | ||
35 | -</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
.idea/migrations.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<project version="4"> | ||
3 | - <component name="ProjectMigrations"> | ||
4 | - <option name="MigrateToGradleLocalJavaHome"> | ||
5 | - <set> | ||
6 | - <option value="$PROJECT_DIR$" /> | ||
7 | - </set> | ||
8 | - </option> | ||
9 | - </component> | ||
10 | -</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
.idea/misc.xml
deleted
100644 → 0
This diff is collapsed. Click to expand it.
.idea/runConfigurations.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<project version="4"> | ||
3 | - <component name="RunConfigurationProducerService"> | ||
4 | - <option name="ignoredProducers"> | ||
5 | - <set> | ||
6 | - <option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" /> | ||
7 | - <option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" /> | ||
8 | - <option value="com.intellij.execution.junit.PatternConfigurationProducer" /> | ||
9 | - <option value="com.intellij.execution.junit.TestInClassConfigurationProducer" /> | ||
10 | - <option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" /> | ||
11 | - <option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" /> | ||
12 | - <option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" /> | ||
13 | - <option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" /> | ||
14 | - </set> | ||
15 | - </option> | ||
16 | - </component> | ||
17 | -</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
.idea/vcs.xml
deleted
100644 → 0
... | @@ -68,7 +68,7 @@ dependencies { | ... | @@ -68,7 +68,7 @@ dependencies { |
68 | implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' | 68 | implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' |
69 | implementation 'io.reactivex.rxjava3:rxjava:3.1.8' | 69 | implementation 'io.reactivex.rxjava3:rxjava:3.1.8' |
70 | implementation 'io.reactivex.rxjava3:rxandroid:3.0.2' | 70 | implementation 'io.reactivex.rxjava3:rxandroid:3.0.2' |
71 | - implementation 'com.google.android.material:material:1.12.0' | 71 | + implementation 'com.google.android.material:material:1.13.0' |
72 | implementation 'org.greenrobot:eventbus:3.3.1' | 72 | implementation 'org.greenrobot:eventbus:3.3.1' |
73 | implementation 'com.google.guava:guava:33.0.0-android' | 73 | implementation 'com.google.guava:guava:33.0.0-android' |
74 | 74 | ||
... | @@ -99,14 +99,14 @@ dependencies { | ... | @@ -99,14 +99,14 @@ dependencies { |
99 | implementation 'androidx.sqlite:sqlite:2.5.2' | 99 | implementation 'androidx.sqlite:sqlite:2.5.2' |
100 | 100 | ||
101 | //------------------------------ Retrofit -----------------------------// | 101 | //------------------------------ Retrofit -----------------------------// |
102 | - implementation 'com.squareup.retrofit2:retrofit:2.9.0' | 102 | + implementation 'com.squareup.retrofit2:retrofit:3.0.0' |
103 | - implementation 'com.squareup.retrofit2:converter-gson:2.9.0' | 103 | + implementation 'com.squareup.retrofit2:converter-gson:3.0.0' |
104 | 104 | ||
105 | //------------------------------ Lifecycle -----------------------------// | 105 | //------------------------------ Lifecycle -----------------------------// |
106 | implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" | 106 | implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" |
107 | 107 | ||
108 | //------------------------------ Retrofit Logs -----------------------------// | 108 | //------------------------------ Retrofit Logs -----------------------------// |
109 | -// implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' | 109 | + implementation 'com.squareup.okhttp3:logging-interceptor:5.1.0' |
110 | } | 110 | } |
111 | 111 | ||
112 | // In every export please update the version number | 112 | // In every export please update the version number | ... | ... |
... | @@ -744,7 +744,7 @@ public enum Warply { | ... | @@ -744,7 +744,7 @@ public enum Warply { |
744 | return; | 744 | return; |
745 | } | 745 | } |
746 | if (!WarpUtils.isRegisteredWarply(context)) { | 746 | if (!WarpUtils.isRegisteredWarply(context)) { |
747 | - registerWarply(context); | 747 | + registerWarply(); |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | if (WarpUtils.getIsDEVICEINFOENABLED(context)) | 750 | if (WarpUtils.getIsDEVICEINFOENABLED(context)) |
... | @@ -1378,7 +1378,7 @@ public enum Warply { | ... | @@ -1378,7 +1378,7 @@ public enum Warply { |
1378 | WarplyDBHelper.getInstance(mContext).deleteAllRequests(); | 1378 | WarplyDBHelper.getInstance(mContext).deleteAllRequests(); |
1379 | WarplyDBHelper.getInstance(mContext).deleteAllPushRequests(); | 1379 | WarplyDBHelper.getInstance(mContext).deleteAllPushRequests(); |
1380 | WarplyDBHelper.getInstance(mContext).deleteAllPushAckRequests(); | 1380 | WarplyDBHelper.getInstance(mContext).deleteAllPushAckRequests(); |
1381 | - String webId = result.optString("web_id", ""); | 1381 | + String webId = result.optString("web_id", "deprecated"); |
1382 | WarpUtils.setWebId(mContext, webId); | 1382 | WarpUtils.setWebId(mContext, webId); |
1383 | String apiKey = result.optString("api_key", ""); | 1383 | String apiKey = result.optString("api_key", ""); |
1384 | WarpUtils.setApiKey(mContext, apiKey); | 1384 | WarpUtils.setApiKey(mContext, apiKey); | ... | ... |
... | @@ -10,6 +10,7 @@ import android.widget.LinearLayout; | ... | @@ -10,6 +10,7 @@ import android.widget.LinearLayout; |
10 | import android.widget.RelativeLayout; | 10 | import android.widget.RelativeLayout; |
11 | import android.widget.TextView; | 11 | import android.widget.TextView; |
12 | 12 | ||
13 | +import androidx.constraintlayout.widget.ConstraintLayout; | ||
13 | import androidx.recyclerview.widget.LinearLayoutManager; | 14 | import androidx.recyclerview.widget.LinearLayoutManager; |
14 | import androidx.recyclerview.widget.RecyclerView; | 15 | import androidx.recyclerview.widget.RecyclerView; |
15 | import androidx.viewpager2.widget.ViewPager2; | 16 | import androidx.viewpager2.widget.ViewPager2; |
... | @@ -24,7 +25,7 @@ import ly.warp.sdk.R; | ... | @@ -24,7 +25,7 @@ import ly.warp.sdk.R; |
24 | import ly.warp.sdk.io.adapters.BannerAdapter; | 25 | import ly.warp.sdk.io.adapters.BannerAdapter; |
25 | import ly.warp.sdk.io.adapters.OfferAdapter; | 26 | import ly.warp.sdk.io.adapters.OfferAdapter; |
26 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 27 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
27 | -import ly.warp.sdk.io.models.Campaign; | 28 | +import ly.warp.sdk.io.models.BannerItem; |
28 | import ly.warp.sdk.io.models.DummyDataProvider; | 29 | import ly.warp.sdk.io.models.DummyDataProvider; |
29 | import ly.warp.sdk.io.models.OfferCategory; | 30 | import ly.warp.sdk.io.models.OfferCategory; |
30 | import ly.warp.sdk.io.models.OfferItem; | 31 | import ly.warp.sdk.io.models.OfferItem; |
... | @@ -85,6 +86,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -85,6 +86,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
85 | private TextView mTvAllOffers, mTvAllFavorites, mTvAllViability, mTvAllFamily, | 86 | private TextView mTvAllOffers, mTvAllFavorites, mTvAllViability, mTvAllFamily, |
86 | mTvAllCoffee, mTvAllTravelling, mTvAllKids, mTvAllPurchases; | 87 | mTvAllCoffee, mTvAllTravelling, mTvAllKids, mTvAllPurchases; |
87 | private ImageView mIvProfile; | 88 | private ImageView mIvProfile; |
89 | + private ConstraintLayout mViewPager; | ||
88 | 90 | ||
89 | // =========================================================== | 91 | // =========================================================== |
90 | // Methods for/from SuperClass/Interfaces | 92 | // Methods for/from SuperClass/Interfaces |
... | @@ -143,6 +145,8 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -143,6 +145,8 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
143 | mPbLoading = findViewById(R.id.pb_loading); | 145 | mPbLoading = findViewById(R.id.pb_loading); |
144 | mPbLoading.setOnTouchListener((v, event) -> true); | 146 | mPbLoading.setOnTouchListener((v, event) -> true); |
145 | 147 | ||
148 | + mViewPager = findViewById(R.id.cl_viewpager); | ||
149 | + | ||
146 | mIvProfile = findViewById(R.id.profile_icon); | 150 | mIvProfile = findViewById(R.id.profile_icon); |
147 | mIvProfile.setOnClickListener(this); | 151 | mIvProfile.setOnClickListener(this); |
148 | 152 | ||
... | @@ -421,10 +425,14 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -421,10 +425,14 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
421 | mBannerViewPager = findViewById(R.id.banner_viewpager); | 425 | mBannerViewPager = findViewById(R.id.banner_viewpager); |
422 | mDotsContainer = findViewById(R.id.dots_container); | 426 | mDotsContainer = findViewById(R.id.dots_container); |
423 | 427 | ||
424 | - mBannerAdapter = new BannerAdapter(this, WarplyManagerHelper.getCampaignList()); | 428 | + mBannerAdapter = new BannerAdapter(this, WarplyManagerHelper.getBannerList()); |
425 | - mBannerAdapter.setOnBannerClickListener(campaign -> { | 429 | + mBannerAdapter.setOnBannerCampaignClickListener(campaign -> { |
426 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(campaign))); | 430 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(campaign))); |
427 | }); | 431 | }); |
432 | + mBannerAdapter.setOnBannerContentClickListener(article -> { | ||
433 | + //TODO: click article | ||
434 | + String s = ""; | ||
435 | + }); | ||
428 | 436 | ||
429 | // Set the number of pages to preload for adjacent items | 437 | // Set the number of pages to preload for adjacent items |
430 | mBannerViewPager.setOffscreenPageLimit(5); | 438 | mBannerViewPager.setOffscreenPageLimit(5); |
... | @@ -432,7 +440,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -432,7 +440,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
432 | mBannerViewPager.setAdapter(mBannerAdapter); | 440 | mBannerViewPager.setAdapter(mBannerAdapter); |
433 | 441 | ||
434 | // Setup pagination dots | 442 | // Setup pagination dots |
435 | - setupPaginationDots(WarplyManagerHelper.getCampaignList().size()); | 443 | + setupPaginationDots(WarplyManagerHelper.getBannerList().size()); |
436 | 444 | ||
437 | // Handle page changes | 445 | // Handle page changes |
438 | mBannerViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { | 446 | mBannerViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
... | @@ -486,26 +494,29 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -486,26 +494,29 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
486 | } | 494 | } |
487 | } | 495 | } |
488 | 496 | ||
489 | - private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() { | 497 | + private CallbackReceiver<ArrayList<BannerItem>> mCampaignsCallback = new CallbackReceiver<ArrayList<BannerItem>>() { |
490 | @Override | 498 | @Override |
491 | - public void onSuccess(ArrayList<Campaign> result) { | 499 | + public void onSuccess(ArrayList<BannerItem> result) { |
492 | mPbLoading.setVisibility(View.GONE); | 500 | mPbLoading.setVisibility(View.GONE); |
493 | if (result != null && !result.isEmpty()) { | 501 | if (result != null && !result.isEmpty()) { |
494 | // Preloads the campaigns' images | 502 | // Preloads the campaigns' images |
495 | - result.forEach(campaign -> { | 503 | + result.forEach(bannerItem -> { |
496 | Glide.with(getApplicationContext()) | 504 | Glide.with(getApplicationContext()) |
497 | - .load(campaign.getLogoUrl()) | 505 | + .load(bannerItem.isCampaign() ? bannerItem.getCampaign().getLogoUrl() : bannerItem.getContent().getImgPreview()) |
498 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 506 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
499 | .preload(); | 507 | .preload(); |
500 | }); | 508 | }); |
501 | 509 | ||
502 | setupBannerCarousel(); | 510 | setupBannerCarousel(); |
511 | + } else { | ||
512 | + mViewPager.setVisibility(View.GONE); | ||
503 | } | 513 | } |
504 | } | 514 | } |
505 | 515 | ||
506 | @Override | 516 | @Override |
507 | public void onFailure(int errorCode) { | 517 | public void onFailure(int errorCode) { |
508 | mPbLoading.setVisibility(View.GONE); | 518 | mPbLoading.setVisibility(View.GONE); |
519 | + mViewPager.setVisibility(View.GONE); | ||
509 | } | 520 | } |
510 | }; | 521 | }; |
511 | } | 522 | } | ... | ... |
... | @@ -15,25 +15,36 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy; | ... | @@ -15,25 +15,36 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy; |
15 | import java.util.ArrayList; | 15 | import java.util.ArrayList; |
16 | 16 | ||
17 | import ly.warp.sdk.R; | 17 | import ly.warp.sdk.R; |
18 | +import ly.warp.sdk.io.models.BannerItem; | ||
18 | import ly.warp.sdk.io.models.Campaign; | 19 | import ly.warp.sdk.io.models.Campaign; |
20 | +import ly.warp.sdk.io.models.Content; | ||
19 | 21 | ||
20 | public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerViewHolder> { | 22 | public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerViewHolder> { |
21 | 23 | ||
22 | private final Context mContext; | 24 | private final Context mContext; |
23 | - private final ArrayList<Campaign> mCampaigns; | 25 | + private final ArrayList<BannerItem> mBannerItems; |
24 | - private OnBannerClickListener mListener; | 26 | + private OnBannerCampaignClickListener mListenerCampaign; |
27 | + private OnBannerContentClickListener mListenerContent; | ||
25 | 28 | ||
26 | - public interface OnBannerClickListener { | 29 | + public interface OnBannerCampaignClickListener { |
27 | - void onBannerClick(Campaign campaign); | 30 | + void onBannerCampaignClick(Campaign campaign); |
28 | } | 31 | } |
29 | 32 | ||
30 | - public BannerAdapter(Context context, ArrayList<Campaign> campaigns) { | 33 | + public interface OnBannerContentClickListener { |
34 | + void onBannerContentClick(Content content); | ||
35 | + } | ||
36 | + | ||
37 | + public BannerAdapter(Context context, ArrayList<BannerItem> campaigns) { | ||
31 | this.mContext = context; | 38 | this.mContext = context; |
32 | - this.mCampaigns = campaigns; | 39 | + this.mBannerItems = campaigns; |
40 | + } | ||
41 | + | ||
42 | + public void setOnBannerCampaignClickListener(OnBannerCampaignClickListener listener) { | ||
43 | + this.mListenerCampaign = listener; | ||
33 | } | 44 | } |
34 | 45 | ||
35 | - public void setOnBannerClickListener(OnBannerClickListener listener) { | 46 | + public void setOnBannerContentClickListener(OnBannerContentClickListener listener) { |
36 | - this.mListener = listener; | 47 | + this.mListenerContent = listener; |
37 | } | 48 | } |
38 | 49 | ||
39 | @NonNull | 50 | @NonNull |
... | @@ -45,27 +56,44 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView | ... | @@ -45,27 +56,44 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView |
45 | 56 | ||
46 | @Override | 57 | @Override |
47 | public void onBindViewHolder(@NonNull BannerViewHolder holder, int position) { | 58 | public void onBindViewHolder(@NonNull BannerViewHolder holder, int position) { |
48 | - Campaign campaignItem = mCampaigns.get(position); | 59 | + BannerItem bannerItem = mBannerItems.get(position); |
60 | + | ||
61 | + if (bannerItem.isCampaign()) { | ||
62 | + Glide.with(mContext) | ||
63 | +// .setDefaultRequestOptions( | ||
64 | +// RequestOptions | ||
65 | +// .placeholderOf(R.drawable.demo_logo) | ||
66 | +// .error(R.drawable.demo_logo)) | ||
67 | + .load(bannerItem.getCampaign().getLogoUrl()) | ||
68 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
69 | + .into(holder.imageView); | ||
49 | 70 | ||
71 | + holder.itemView.setOnClickListener(v -> { | ||
72 | + if (mListenerCampaign != null) { | ||
73 | + mListenerCampaign.onBannerCampaignClick(bannerItem.getCampaign()); | ||
74 | + } | ||
75 | + }); | ||
76 | + } else { | ||
50 | Glide.with(mContext) | 77 | Glide.with(mContext) |
51 | // .setDefaultRequestOptions( | 78 | // .setDefaultRequestOptions( |
52 | // RequestOptions | 79 | // RequestOptions |
53 | // .placeholderOf(R.drawable.demo_logo) | 80 | // .placeholderOf(R.drawable.demo_logo) |
54 | // .error(R.drawable.demo_logo)) | 81 | // .error(R.drawable.demo_logo)) |
55 | - .load(campaignItem.getLogoUrl()) | 82 | + .load(bannerItem.getContent().getImgPreview()) |
56 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 83 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
57 | .into(holder.imageView); | 84 | .into(holder.imageView); |
58 | 85 | ||
59 | holder.itemView.setOnClickListener(v -> { | 86 | holder.itemView.setOnClickListener(v -> { |
60 | - if (mListener != null) { | 87 | + if (mListenerContent != null) { |
61 | - mListener.onBannerClick(campaignItem); | 88 | + mListenerContent.onBannerContentClick(bannerItem.getContent()); |
62 | } | 89 | } |
63 | }); | 90 | }); |
64 | } | 91 | } |
92 | + } | ||
65 | 93 | ||
66 | @Override | 94 | @Override |
67 | public int getItemCount() { | 95 | public int getItemCount() { |
68 | - return mCampaigns.size(); | 96 | + return mBannerItems.size(); |
69 | } | 97 | } |
70 | 98 | ||
71 | static class BannerViewHolder extends RecyclerView.ViewHolder { | 99 | static class BannerViewHolder extends RecyclerView.ViewHolder { | ... | ... |
1 | +package ly.warp.sdk.io.models; | ||
2 | + | ||
3 | +public class BannerItem { | ||
4 | + public enum ItemType { | ||
5 | + CAMPAIGN, | ||
6 | + CONTENT | ||
7 | + } | ||
8 | + | ||
9 | + private ItemType type; | ||
10 | + private Campaign campaign; | ||
11 | + private Content content; | ||
12 | + private int sorting; | ||
13 | + | ||
14 | + public BannerItem(Campaign campaign) { | ||
15 | + this.type = ItemType.CAMPAIGN; | ||
16 | + this.campaign = campaign; | ||
17 | + this.content = null; | ||
18 | + this.sorting = campaign.getSorting(); | ||
19 | + } | ||
20 | + | ||
21 | + public BannerItem(Content content) { | ||
22 | + this.type = ItemType.CONTENT; | ||
23 | + this.content = content; | ||
24 | + this.campaign = null; | ||
25 | + this.sorting = content.getSorting(); | ||
26 | + } | ||
27 | + | ||
28 | + public ItemType getType() { | ||
29 | + return type; | ||
30 | + } | ||
31 | + | ||
32 | + public Campaign getCampaign() { | ||
33 | + return campaign; | ||
34 | + } | ||
35 | + | ||
36 | + public Content getContent() { | ||
37 | + return content; | ||
38 | + } | ||
39 | + | ||
40 | + public boolean isCampaign() { | ||
41 | + return type == ItemType.CAMPAIGN; | ||
42 | + } | ||
43 | + | ||
44 | + public boolean isContent() { | ||
45 | + return type == ItemType.CONTENT; | ||
46 | + } | ||
47 | +} |
... | @@ -72,8 +72,6 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -72,8 +72,6 @@ public class Campaign implements Parcelable, Serializable { |
72 | private static final String ACTIONS = "actions"; | 72 | private static final String ACTIONS = "actions"; |
73 | private static final String BUS_ID = "busId"; | 73 | private static final String BUS_ID = "busId"; |
74 | private static final String CAMPAIGN_TYPE_SETTINGS = "campaign_type_settings"; | 74 | private static final String CAMPAIGN_TYPE_SETTINGS = "campaign_type_settings"; |
75 | - private static final String BANNER_IMAGE = "Banner_img"; | ||
76 | - private static final String BANNER_TITLE = "Banner_title"; | ||
77 | private static final String CATEGORY_ID = "category_id"; | 75 | private static final String CATEGORY_ID = "category_id"; |
78 | private static final String COUPON_AVAILABILITY = "coupon_availability"; | 76 | private static final String COUPON_AVAILABILITY = "coupon_availability"; |
79 | 77 | ||
... | @@ -103,8 +101,6 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -103,8 +101,6 @@ public class Campaign implements Parcelable, Serializable { |
103 | private String busId; | 101 | private String busId; |
104 | private ArrayList<CampaignAction> actions = new ArrayList<>(); | 102 | private ArrayList<CampaignAction> actions = new ArrayList<>(); |
105 | private String campaignTypeSettings; | 103 | private String campaignTypeSettings; |
106 | - private String bannerImage; | ||
107 | - private String bannerTitle; | ||
108 | private String categoryId; | 104 | private String categoryId; |
109 | private Integer couponAvailability; | 105 | private Integer couponAvailability; |
110 | private String endDate, startDate; | 106 | private String endDate, startDate; |
... | @@ -148,8 +144,6 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -148,8 +144,6 @@ public class Campaign implements Parcelable, Serializable { |
148 | this.busId = ""; | 144 | this.busId = ""; |
149 | this.actions = new ArrayList<>(); | 145 | this.actions = new ArrayList<>(); |
150 | this.campaignTypeSettings = ""; | 146 | this.campaignTypeSettings = ""; |
151 | - this.bannerImage = ""; | ||
152 | - this.bannerTitle = ""; | ||
153 | this.couponAvailability = null; | 147 | this.couponAvailability = null; |
154 | this.categoryId = ""; | 148 | this.categoryId = ""; |
155 | this.endDate = ""; | 149 | this.endDate = ""; |
... | @@ -186,20 +180,6 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -186,20 +180,6 @@ public class Campaign implements Parcelable, Serializable { |
186 | this.isNew = json.optBoolean(IS_NEW); | 180 | this.isNew = json.optBoolean(IS_NEW); |
187 | this.sorting = json.optInt(SORTING); | 181 | this.sorting = json.optInt(SORTING); |
188 | this.extraFields = json.optString(EXTRA_FIELDS); | 182 | this.extraFields = json.optString(EXTRA_FIELDS); |
189 | - if (!TextUtils.isEmpty(this.extraFields)) { | ||
190 | - JSONObject extraFieldsResp = WarpJSONParser.getJSONFromString(this.extraFields); | ||
191 | - if (extraFieldsResp != null) { | ||
192 | - if (extraFieldsResp.has("Banner_title")) { | ||
193 | - this.bannerTitle = extraFieldsResp.optString(BANNER_TITLE, ""); | ||
194 | - } | ||
195 | - if (extraFieldsResp.has("Banner_img")) { | ||
196 | - this.bannerImage = extraFieldsResp.optString(BANNER_IMAGE, ""); | ||
197 | - } | ||
198 | - } | ||
199 | - } else { | ||
200 | - this.bannerImage = ""; | ||
201 | - this.bannerTitle = ""; | ||
202 | - } | ||
203 | this.type = json.optString(TYPE); | 183 | this.type = json.optString(TYPE); |
204 | this.expired = json.optBoolean(EXPIRED); | 184 | this.expired = json.optBoolean(EXPIRED); |
205 | this.show = json.optBoolean(SHOW); | 185 | this.show = json.optBoolean(SHOW); |
... | @@ -651,22 +631,6 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -651,22 +631,6 @@ public class Campaign implements Parcelable, Serializable { |
651 | this.campaignTypeSettings = campaignTypeSettings; | 631 | this.campaignTypeSettings = campaignTypeSettings; |
652 | } | 632 | } |
653 | 633 | ||
654 | - public String getBannerImage() { | ||
655 | - return this.bannerImage; | ||
656 | - } | ||
657 | - | ||
658 | - public String getBannerTitle() { | ||
659 | - return this.bannerTitle; | ||
660 | - } | ||
661 | - | ||
662 | - public void setBannerImage(String bannerImage) { | ||
663 | - this.bannerImage = bannerImage; | ||
664 | - } | ||
665 | - | ||
666 | - public void setBannerTitle(String bannerTitle) { | ||
667 | - this.bannerTitle = bannerTitle; | ||
668 | - } | ||
669 | - | ||
670 | public String getEndDate() { | 634 | public String getEndDate() { |
671 | return endDate; | 635 | return endDate; |
672 | } | 636 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -97,7 +97,7 @@ public interface ApiService { | ... | @@ -97,7 +97,7 @@ public interface ApiService { |
97 | 97 | ||
98 | @Headers("Content-Type: application/json") | 98 | @Headers("Content-Type: application/json") |
99 | @POST("/api/mobile/v2/{appUuid}/context/") | 99 | @POST("/api/mobile/v2/{appUuid}/context/") |
100 | - Call<ResponseBody> getCampaignsAvailability(@Path("appUuid") String appUuid, | 100 | + Call<ResponseBody> getArticles(@Path("appUuid") String appUuid, |
101 | @Body RequestBody request, | 101 | @Body RequestBody request, |
102 | @Header(WarpConstants.HEADER_DATE) String timeStamp, | 102 | @Header(WarpConstants.HEADER_DATE) String timeStamp, |
103 | @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, | 103 | @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, |
... | @@ -118,18 +118,6 @@ public interface ApiService { | ... | @@ -118,18 +118,6 @@ public interface ApiService { |
118 | @Header(WarpConstants.HEADER_SIGNATURE) String signature, | 118 | @Header(WarpConstants.HEADER_SIGNATURE) String signature, |
119 | @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer); | 119 | @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer); |
120 | 120 | ||
121 | - @Headers("Content-Type: application/json") | ||
122 | - @POST("/oauth/{appUuid}/context") | ||
123 | - Call<ResponseBody> getMarketPassDetails(@Path("appUuid") String appUuid, | ||
124 | - @Body RequestBody request, | ||
125 | - @Header(WarpConstants.HEADER_DATE) String timeStamp, | ||
126 | - @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, | ||
127 | - @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | ||
128 | - @Header(WarpConstants.HEADER_CHANNEL) String channel, | ||
129 | - @Header(WarpConstants.HEADER_WEB_ID) String webId, | ||
130 | - @Header(WarpConstants.HEADER_SIGNATURE) String signature, | ||
131 | - @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer); | ||
132 | - | ||
133 | // =========================================================== | 121 | // =========================================================== |
134 | // Getter & Setter | 122 | // Getter & Setter |
135 | // =========================================================== | 123 | // =========================================================== | ... | ... |
... | @@ -32,6 +32,7 @@ import java.util.ArrayList; | ... | @@ -32,6 +32,7 @@ import java.util.ArrayList; |
32 | 32 | ||
33 | import ly.warp.sdk.Warply; | 33 | import ly.warp.sdk.Warply; |
34 | import ly.warp.sdk.db.WarplyDBHelper; | 34 | import ly.warp.sdk.db.WarplyDBHelper; |
35 | +import ly.warp.sdk.io.models.BannerItem; | ||
35 | import ly.warp.sdk.io.models.Campaign; | 36 | import ly.warp.sdk.io.models.Campaign; |
36 | import ly.warp.sdk.io.models.CouponList; | 37 | import ly.warp.sdk.io.models.CouponList; |
37 | import ly.warp.sdk.utils.managers.WarplyManager; | 38 | import ly.warp.sdk.utils.managers.WarplyManager; |
... | @@ -52,6 +53,7 @@ public class WarplyManagerHelper { | ... | @@ -52,6 +53,7 @@ public class WarplyManagerHelper { |
52 | 53 | ||
53 | private static CouponList mCouponRedeemedList = new CouponList(); | 54 | private static CouponList mCouponRedeemedList = new CouponList(); |
54 | private static ArrayList<Campaign> mCampaignListAll = new ArrayList<Campaign>(); | 55 | private static ArrayList<Campaign> mCampaignListAll = new ArrayList<Campaign>(); |
56 | + private static ArrayList<BannerItem> mBannerListAll = new ArrayList<BannerItem>(); | ||
55 | 57 | ||
56 | // =========================================================== | 58 | // =========================================================== |
57 | // Methods for/from SuperClass/Interfaces | 59 | // Methods for/from SuperClass/Interfaces |
... | @@ -70,6 +72,15 @@ public class WarplyManagerHelper { | ... | @@ -70,6 +72,15 @@ public class WarplyManagerHelper { |
70 | return mCampaignListAll; | 72 | return mCampaignListAll; |
71 | } | 73 | } |
72 | 74 | ||
75 | + public static void setBannerList(ArrayList<BannerItem> bannerList) { | ||
76 | + mBannerListAll.clear(); | ||
77 | + mBannerListAll.addAll(bannerList); | ||
78 | + } | ||
79 | + | ||
80 | + public static ArrayList<BannerItem> getBannerList() { | ||
81 | + return mBannerListAll; | ||
82 | + } | ||
83 | + | ||
73 | public static void setCouponRedeemedList(CouponList couponRedeemedList) { | 84 | public static void setCouponRedeemedList(CouponList couponRedeemedList) { |
74 | mCouponRedeemedList.clear(); | 85 | mCouponRedeemedList.clear(); |
75 | mCouponRedeemedList.addAll(couponRedeemedList); | 86 | mCouponRedeemedList.addAll(couponRedeemedList); | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -55,6 +55,7 @@ | ... | @@ -55,6 +55,7 @@ |
55 | </LinearLayout> | 55 | </LinearLayout> |
56 | 56 | ||
57 | <androidx.constraintlayout.widget.ConstraintLayout | 57 | <androidx.constraintlayout.widget.ConstraintLayout |
58 | + android:id="@+id/cl_viewpager" | ||
58 | android:layout_width="match_parent" | 59 | android:layout_width="match_parent" |
59 | android:layout_height="wrap_content"> | 60 | android:layout_height="wrap_content"> |
60 | 61 | ... | ... |
-
Please register or login to post a comment