Showing
11 changed files
with
84 additions
and
25 deletions
... | @@ -100,7 +100,7 @@ | ... | @@ -100,7 +100,7 @@ |
100 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_coupons.xml" value="0.358695652173913" /> | 100 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_coupons.xml" value="0.358695652173913" /> |
101 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_gifts.xml" value="0.36666666666666664" /> | 101 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_gifts.xml" value="0.36666666666666664" /> |
102 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_rewards.xml" value="0.358695652173913" /> | 102 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_rewards.xml" value="0.358695652173913" /> |
103 | - <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_base_fragment.xml" value="0.358695652173913" /> | 103 | + <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_base_fragment.xml" value="0.25" /> |
104 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_bill_payment.xml" value="0.358695652173913" /> | 104 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_bill_payment.xml" value="0.358695652173913" /> |
105 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_contextual.xml" value="0.36666666666666664" /> | 105 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_contextual.xml" value="0.36666666666666664" /> |
106 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_coupon_gift.xml" value="0.36666666666666664" /> | 106 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_coupon_gift.xml" value="0.36666666666666664" /> |
... | @@ -133,7 +133,7 @@ | ... | @@ -133,7 +133,7 @@ |
133 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/dl_share.xml" value="0.36666666666666664" /> | 133 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/dl_share.xml" value="0.36666666666666664" /> |
134 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/dlg_success.xml" value="0.358695652173913" /> | 134 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/dlg_success.xml" value="0.358695652173913" /> |
135 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/expired_coupon_layout.xml" value="0.36666666666666664" /> | 135 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/expired_coupon_layout.xml" value="0.36666666666666664" /> |
136 | - <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_home.xml" value="0.358695652173913" /> | 136 | + <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_home.xml" value="0.22" /> |
137 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_loyalty.xml" value="0.358695652173913" /> | 137 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_loyalty.xml" value="0.358695652173913" /> |
138 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_profile.xml" value="0.358695652173913" /> | 138 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_profile.xml" value="0.358695652173913" /> |
139 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/gift_layout.xml" value="0.358695652173913" /> | 139 | <entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/gift_layout.xml" value="0.358695652173913" /> | ... | ... |
... | @@ -36,7 +36,7 @@ public class SplashActivity extends BaseActivity { | ... | @@ -36,7 +36,7 @@ public class SplashActivity extends BaseActivity { |
36 | public void onWarplyReady() { | 36 | public void onWarplyReady() { |
37 | if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) { | 37 | if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) { |
38 | WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest() | 38 | WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest() |
39 | - .setGuid("6010139202"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, live 3000184910 | 39 | + .setGuid("6005892749"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, prod 6005892749, live 3000184910 |
40 | mLoginReceiver); | 40 | mLoginReceiver); |
41 | } else { | 41 | } else { |
42 | startNextActivity(); | 42 | startNextActivity(); | ... | ... |
... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' | ... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' |
2 | 2 | ||
3 | ext { | 3 | ext { |
4 | PUBLISH_GROUP_ID = 'ly.warp' | 4 | PUBLISH_GROUP_ID = 'ly.warp' |
5 | - PUBLISH_VERSION = '4.5.4.6rc20' | 5 | + PUBLISH_VERSION = '4.5.4.6rc21' |
6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
7 | } | 7 | } |
8 | 8 | ||
... | @@ -42,6 +42,7 @@ android { | ... | @@ -42,6 +42,7 @@ android { |
42 | 42 | ||
43 | dependencies { | 43 | dependencies { |
44 | //------------------------------ Support -----------------------------// | 44 | //------------------------------ Support -----------------------------// |
45 | + implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' | ||
45 | implementation 'androidx.appcompat:appcompat:1.4.1' | 46 | implementation 'androidx.appcompat:appcompat:1.4.1' |
46 | implementation 'androidx.recyclerview:recyclerview:1.2.1' | 47 | implementation 'androidx.recyclerview:recyclerview:1.2.1' |
47 | implementation 'androidx.cardview:cardview:1.0.0' | 48 | implementation 'androidx.cardview:cardview:1.0.0' | ... | ... |
... | @@ -7,6 +7,7 @@ import android.os.Looper; | ... | @@ -7,6 +7,7 @@ import android.os.Looper; |
7 | import android.view.MenuItem; | 7 | import android.view.MenuItem; |
8 | import android.widget.LinearLayout; | 8 | import android.widget.LinearLayout; |
9 | import android.widget.TextView; | 9 | import android.widget.TextView; |
10 | +import android.widget.Toast; | ||
10 | 11 | ||
11 | import androidx.annotation.NonNull; | 12 | import androidx.annotation.NonNull; |
12 | import androidx.fragment.app.Fragment; | 13 | import androidx.fragment.app.Fragment; |
... | @@ -136,28 +137,27 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -136,28 +137,27 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
136 | // Inner and Anonymous Classes | 137 | // Inner and Anonymous Classes |
137 | // =========================================================== | 138 | // =========================================================== |
138 | 139 | ||
139 | - private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() { | 140 | + private final CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() { |
140 | @Override | 141 | @Override |
141 | public void onSuccess(ArrayList<Campaign> result) { | 142 | public void onSuccess(ArrayList<Campaign> result) { |
142 | - | 143 | + Toast.makeText(BaseFragmentActivity.this, "Campaigns Success", Toast.LENGTH_SHORT).show(); |
143 | } | 144 | } |
144 | 145 | ||
145 | @Override | 146 | @Override |
146 | public void onFailure(int errorCode) { | 147 | public void onFailure(int errorCode) { |
147 | - | 148 | + Toast.makeText(BaseFragmentActivity.this, "Campaigns Error", Toast.LENGTH_SHORT).show(); |
148 | } | 149 | } |
149 | }; | 150 | }; |
150 | 151 | ||
151 | - | ||
152 | private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { | 152 | private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { |
153 | @Override | 153 | @Override |
154 | public void onSuccess(CouponList result) { | 154 | public void onSuccess(CouponList result) { |
155 | - | 155 | + Toast.makeText(BaseFragmentActivity.this, "Coupons Success " + String.valueOf(result.size()), Toast.LENGTH_SHORT).show(); |
156 | } | 156 | } |
157 | 157 | ||
158 | @Override | 158 | @Override |
159 | public void onFailure(int errorCode) { | 159 | public void onFailure(int errorCode) { |
160 | - | 160 | + Toast.makeText(BaseFragmentActivity.this, "Coupons Error", Toast.LENGTH_SHORT).show(); |
161 | } | 161 | } |
162 | }; | 162 | }; |
163 | 163 | ... | ... |
... | @@ -325,7 +325,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene | ... | @@ -325,7 +325,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene |
325 | public void onSuccess(JSONObject result) { | 325 | public void onSuccess(JSONObject result) { |
326 | int status = result.optInt("status", 2); | 326 | int status = result.optInt("status", 2); |
327 | String message = result.optString("msg", ""); | 327 | String message = result.optString("msg", ""); |
328 | - WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver); | 328 | + WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); |
329 | runOnUiThread(() -> { | 329 | runOnUiThread(() -> { |
330 | if (status == 1) | 330 | if (status == 1) |
331 | acceptSharingDialog(); | 331 | acceptSharingDialog(); | ... | ... |
... | @@ -212,7 +212,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe | ... | @@ -212,7 +212,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe |
212 | showDialog(true, 1); | 212 | showDialog(true, 1); |
213 | new Thread(() -> { | 213 | new Thread(() -> { |
214 | if (!Thread.currentThread().isInterrupted()) { | 214 | if (!Thread.currentThread().isInterrupted()) { |
215 | - WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver); | 215 | + WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); |
216 | WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback); | 216 | WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback); |
217 | } | 217 | } |
218 | }).start(); | 218 | }).start(); | ... | ... |
... | @@ -9,20 +9,29 @@ import android.widget.ImageView; | ... | @@ -9,20 +9,29 @@ import android.widget.ImageView; |
9 | import android.widget.LinearLayout; | 9 | 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 | +import android.widget.Toast; | ||
12 | 13 | ||
13 | import androidx.annotation.NonNull; | 14 | import androidx.annotation.NonNull; |
14 | import androidx.constraintlayout.widget.ConstraintLayout; | 15 | import androidx.constraintlayout.widget.ConstraintLayout; |
15 | import androidx.fragment.app.Fragment; | 16 | import androidx.fragment.app.Fragment; |
16 | import androidx.recyclerview.widget.LinearLayoutManager; | 17 | import androidx.recyclerview.widget.LinearLayoutManager; |
17 | import androidx.recyclerview.widget.RecyclerView; | 18 | import androidx.recyclerview.widget.RecyclerView; |
19 | +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; | ||
20 | + | ||
21 | +import java.util.ArrayList; | ||
18 | 22 | ||
19 | import ly.warp.sdk.R; | 23 | import ly.warp.sdk.R; |
20 | import ly.warp.sdk.activities.ActiveCouponsActivity; | 24 | import ly.warp.sdk.activities.ActiveCouponsActivity; |
21 | import ly.warp.sdk.activities.WarpViewActivity; | 25 | import ly.warp.sdk.activities.WarpViewActivity; |
26 | +import ly.warp.sdk.io.callbacks.CallbackReceiver; | ||
27 | +import ly.warp.sdk.io.models.Campaign; | ||
28 | +import ly.warp.sdk.io.models.CouponList; | ||
29 | +import ly.warp.sdk.io.request.WarplyGetCampaignsRequest; | ||
22 | import ly.warp.sdk.utils.WarplyManagerHelper; | 30 | import ly.warp.sdk.utils.WarplyManagerHelper; |
31 | +import ly.warp.sdk.utils.managers.WarplyManager; | ||
23 | import ly.warp.sdk.views.adapters.HomeCampaignAdapter; | 32 | import ly.warp.sdk.views.adapters.HomeCampaignAdapter; |
24 | 33 | ||
25 | -public class HomeFragment extends Fragment implements View.OnClickListener { | 34 | +public class HomeFragment extends Fragment implements View.OnClickListener, SwipeRefreshLayout.OnRefreshListener { |
26 | 35 | ||
27 | private RelativeLayout mOptionOne, mOptionTwo, mOptionThree; | 36 | private RelativeLayout mOptionOne, mOptionTwo, mOptionThree; |
28 | private RecyclerView mRecyclerCampaigns; | 37 | private RecyclerView mRecyclerCampaigns; |
... | @@ -31,6 +40,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -31,6 +40,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
31 | private TextView mTvUsername, mTvActiveCoupons; | 40 | private TextView mTvUsername, mTvActiveCoupons; |
32 | private ConstraintLayout mClActiveCoupons; | 41 | private ConstraintLayout mClActiveCoupons; |
33 | private ImageView mIvStepsActivity; | 42 | private ImageView mIvStepsActivity; |
43 | + private SwipeRefreshLayout mSwipeRefresh; | ||
34 | 44 | ||
35 | @Override | 45 | @Override |
36 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | 46 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
... | @@ -40,6 +50,8 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -40,6 +50,8 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
40 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { | 50 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { |
41 | super.onViewCreated(view, savedInstanceState); | 51 | super.onViewCreated(view, savedInstanceState); |
42 | 52 | ||
53 | + mSwipeRefresh = view.findViewById(R.id.sw_refresh); | ||
54 | + mSwipeRefresh.setOnRefreshListener(this); | ||
43 | mOptionOne = view.findViewById(R.id.info_button); | 55 | mOptionOne = view.findViewById(R.id.info_button); |
44 | TextView mOptionOneText = mOptionOne.findViewById(R.id.option_text); | 56 | TextView mOptionOneText = mOptionOne.findViewById(R.id.option_text); |
45 | ImageView mOptionOneImage = mOptionOne.findViewById(R.id.option_icon); | 57 | ImageView mOptionOneImage = mOptionOne.findViewById(R.id.option_icon); |
... | @@ -93,6 +105,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -93,6 +105,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
93 | } | 105 | } |
94 | 106 | ||
95 | @Override | 107 | @Override |
108 | + public void onRefresh() { | ||
109 | + WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); | ||
110 | + WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback); | ||
111 | + mSwipeRefresh.setRefreshing(false); | ||
112 | + } | ||
113 | + | ||
114 | + @Override | ||
96 | public void onClick(View view) { | 115 | public void onClick(View view) { |
97 | if (view.getId() == R.id.cl_coupon) { | 116 | if (view.getId() == R.id.cl_coupon) { |
98 | Intent intent = new Intent(getContext(), ActiveCouponsActivity.class); | 117 | Intent intent = new Intent(getContext(), ActiveCouponsActivity.class); |
... | @@ -105,4 +124,29 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -105,4 +124,29 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
105 | HomeFragment homeFragment = new HomeFragment(); | 124 | HomeFragment homeFragment = new HomeFragment(); |
106 | return homeFragment; | 125 | return homeFragment; |
107 | } | 126 | } |
127 | + | ||
128 | + private final CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() { | ||
129 | + @Override | ||
130 | + public void onSuccess(ArrayList<Campaign> result) { | ||
131 | + Toast.makeText(getActivity(), "Campaigns Success", Toast.LENGTH_SHORT).show(); | ||
132 | + } | ||
133 | + | ||
134 | + @Override | ||
135 | + public void onFailure(int errorCode) { | ||
136 | + Toast.makeText(getActivity(), "Campaigns Error", Toast.LENGTH_SHORT).show(); | ||
137 | + } | ||
138 | + }; | ||
139 | + | ||
140 | + | ||
141 | + private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { | ||
142 | + @Override | ||
143 | + public void onSuccess(CouponList result) { | ||
144 | + Toast.makeText(getActivity(), "Coupons Success " + String.valueOf(result.size()), Toast.LENGTH_SHORT).show(); | ||
145 | + } | ||
146 | + | ||
147 | + @Override | ||
148 | + public void onFailure(int errorCode) { | ||
149 | + Toast.makeText(getActivity(), "Coupons Error", Toast.LENGTH_SHORT).show(); | ||
150 | + } | ||
151 | + }; | ||
108 | } | 152 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -38,7 +38,7 @@ public class EventCampaignCouponService extends Worker { | ... | @@ -38,7 +38,7 @@ public class EventCampaignCouponService extends Worker { |
38 | @NonNull | 38 | @NonNull |
39 | @Override | 39 | @Override |
40 | public Result doWork() { | 40 | public Result doWork() { |
41 | - WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver); | 41 | + WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); |
42 | WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback); | 42 | WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback); |
43 | 43 | ||
44 | return Result.success(); | 44 | return Result.success(); | ... | ... |
... | @@ -261,7 +261,7 @@ public class WarplyManagerHelper { | ... | @@ -261,7 +261,7 @@ public class WarplyManagerHelper { |
261 | public void onSuccess(JSONObject result) { | 261 | public void onSuccess(JSONObject result) { |
262 | int status = result.optInt("status", 2); | 262 | int status = result.optInt("status", 2); |
263 | if (status == 1) { | 263 | if (status == 1) { |
264 | - WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), new CallbackReceiver<CouponList>() { | 264 | + WarplyManager.getUserCouponsWithCouponsets(new CallbackReceiver<CouponList>() { |
265 | @Override | 265 | @Override |
266 | public void onSuccess(CouponList result) { | 266 | public void onSuccess(CouponList result) { |
267 | WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel(); | 267 | WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel(); |
... | @@ -393,7 +393,7 @@ public class WarplyManagerHelper { | ... | @@ -393,7 +393,7 @@ public class WarplyManagerHelper { |
393 | public void onSuccess(JSONObject result) { | 393 | public void onSuccess(JSONObject result) { |
394 | int status = result.optInt("status", 2); | 394 | int status = result.optInt("status", 2); |
395 | if (status == 1) { | 395 | if (status == 1) { |
396 | - WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), new CallbackReceiver<CouponList>() { | 396 | + WarplyManager.getUserCouponsWithCouponsets(new CallbackReceiver<CouponList>() { |
397 | @Override | 397 | @Override |
398 | public void onSuccess(CouponList result) { | 398 | public void onSuccess(CouponList result) { |
399 | WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel(); | 399 | WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel(); | ... | ... |
... | @@ -32,6 +32,7 @@ import android.app.AlarmManager; | ... | @@ -32,6 +32,7 @@ import android.app.AlarmManager; |
32 | import android.app.PendingIntent; | 32 | import android.app.PendingIntent; |
33 | import android.content.Context; | 33 | import android.content.Context; |
34 | import android.content.Intent; | 34 | import android.content.Intent; |
35 | +import android.os.AsyncTask; | ||
35 | import android.os.Build; | 36 | import android.os.Build; |
36 | import android.os.Handler; | 37 | import android.os.Handler; |
37 | import android.os.Looper; | 38 | import android.os.Looper; |
... | @@ -2593,9 +2594,9 @@ public class WarplyManager { | ... | @@ -2593,9 +2594,9 @@ public class WarplyManager { |
2593 | dynatraceEvent.setEventName("custom_success_user_coupons_loyalty"); | 2594 | dynatraceEvent.setEventName("custom_success_user_coupons_loyalty"); |
2594 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 2595 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
2595 | 2596 | ||
2596 | - CouponList mActiveCouponList = new CouponList(); | 2597 | + new AsyncTask<Void, CouponList, CouponList>() { |
2597 | - final ExecutorService executor = Executors.newFixedThreadPool(2); | 2598 | + @Override |
2598 | - executor.submit(() -> { | 2599 | + protected CouponList doInBackground(Void... voids) { |
2599 | CouponList mCouponList = new CouponList(); | 2600 | CouponList mCouponList = new CouponList(); |
2600 | for (CouponModel.CouponResult coupon : responseCoupons.body().getResult()) { | 2601 | for (CouponModel.CouponResult coupon : responseCoupons.body().getResult()) { |
2601 | for (CouponsetModel.MappCoupon couponset : response.body().getContext().getMappCoupon()) { | 2602 | for (CouponsetModel.MappCoupon couponset : response.body().getContext().getMappCoupon()) { |
... | @@ -2611,7 +2612,7 @@ public class WarplyManager { | ... | @@ -2611,7 +2612,7 @@ public class WarplyManager { |
2611 | } catch (JSONException e) { | 2612 | } catch (JSONException e) { |
2612 | e.printStackTrace(); | 2613 | e.printStackTrace(); |
2613 | } | 2614 | } |
2614 | - newCoupon.setImage(coupon.getImage()); | 2615 | + newCoupon.setImage(couponset.getImgPreview()); |
2615 | newCoupon.setMerchantUuid(coupon.getMerchantUuid()); | 2616 | newCoupon.setMerchantUuid(coupon.getMerchantUuid()); |
2616 | newCoupon.setCoupon(coupon.getCoupon()); | 2617 | newCoupon.setCoupon(coupon.getCoupon()); |
2617 | newCoupon.setCouponsetUuid(coupon.getCouponsetUuid()); | 2618 | newCoupon.setCouponsetUuid(coupon.getCouponsetUuid()); |
... | @@ -2629,6 +2630,7 @@ public class WarplyManager { | ... | @@ -2629,6 +2630,7 @@ public class WarplyManager { |
2629 | } | 2630 | } |
2630 | WarplyManagerHelper.setCouponList(mCouponList); | 2631 | WarplyManagerHelper.setCouponList(mCouponList); |
2631 | 2632 | ||
2633 | + CouponList mActiveCouponList = new CouponList(); | ||
2632 | for (Coupon coupon : mCouponList) { | 2634 | for (Coupon coupon : mCouponList) { |
2633 | if (coupon.getStatus() == 1) { | 2635 | if (coupon.getStatus() == 1) { |
2634 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 2636 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); |
... | @@ -2663,10 +2665,16 @@ public class WarplyManager { | ... | @@ -2663,10 +2665,16 @@ public class WarplyManager { |
2663 | newCouponstList.add(newCouponset); | 2665 | newCouponstList.add(newCouponset); |
2664 | } | 2666 | } |
2665 | WarplyManagerHelper.setCouponsets(newCouponstList); | 2667 | WarplyManagerHelper.setCouponsets(newCouponstList); |
2666 | - }); | ||
2667 | - executor.shutdownNow(); | ||
2668 | 2668 | ||
2669 | - new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mActiveCouponList)); | 2669 | + return mActiveCouponList; |
2670 | + } | ||
2671 | + | ||
2672 | + @Override | ||
2673 | + protected void onPostExecute(CouponList couponsResponse) { | ||
2674 | + super.onPostExecute(couponsResponse); | ||
2675 | + receiver.onSuccess(couponsResponse); | ||
2676 | + } | ||
2677 | + }.execute(); | ||
2670 | } else { | 2678 | } else { |
2671 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 2679 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
2672 | dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); | 2680 | dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); | ... | ... |
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | ||
3 | -<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | 3 | +<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" |
4 | xmlns:app="http://schemas.android.com/apk/res-auto" | 4 | xmlns:app="http://schemas.android.com/apk/res-auto" |
5 | xmlns:tools="http://schemas.android.com/tools" | 5 | xmlns:tools="http://schemas.android.com/tools" |
6 | + android:id="@+id/sw_refresh" | ||
7 | + android:layout_width="match_parent" | ||
8 | + android:layout_height="match_parent"> | ||
9 | + | ||
10 | + <ScrollView | ||
6 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
7 | android:layout_height="match_parent" | 12 | android:layout_height="match_parent" |
8 | android:background="@android:color/white"> | 13 | android:background="@android:color/white"> |
... | @@ -283,4 +288,5 @@ | ... | @@ -283,4 +288,5 @@ |
283 | </HorizontalScrollView> | 288 | </HorizontalScrollView> |
284 | </RelativeLayout> | 289 | </RelativeLayout> |
285 | </RelativeLayout> | 290 | </RelativeLayout> |
286 | -</ScrollView> | 291 | + </ScrollView> |
292 | +</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> | ... | ... |
-
Please register or login to post a comment