Showing
1 changed file
with
25 additions
and
18 deletions
1 | package ly.warp.sdk.activities; | 1 | package ly.warp.sdk.activities; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | +import android.os.Handler; | ||
5 | +import android.os.Looper; | ||
4 | import android.view.MenuItem; | 6 | import android.view.MenuItem; |
5 | 7 | ||
6 | import androidx.annotation.NonNull; | 8 | import androidx.annotation.NonNull; |
... | @@ -10,6 +12,8 @@ import androidx.fragment.app.FragmentActivity; | ... | @@ -10,6 +12,8 @@ import androidx.fragment.app.FragmentActivity; |
10 | import com.google.android.material.bottomnavigation.BottomNavigationView; | 12 | import com.google.android.material.bottomnavigation.BottomNavigationView; |
11 | import com.google.android.material.navigation.NavigationBarView; | 13 | import com.google.android.material.navigation.NavigationBarView; |
12 | 14 | ||
15 | +import org.json.JSONException; | ||
16 | + | ||
13 | import java.util.HashMap; | 17 | import java.util.HashMap; |
14 | 18 | ||
15 | import ly.warp.sdk.R; | 19 | import ly.warp.sdk.R; |
... | @@ -61,19 +65,19 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -61,19 +65,19 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
61 | } | 65 | } |
62 | }).start(); | 66 | }).start(); |
63 | 67 | ||
64 | - new Thread(() -> { | 68 | +// new Thread(() -> { |
65 | - if (!Thread.currentThread().isInterrupted()) { | 69 | +// if (!Thread.currentThread().isInterrupted()) { |
66 | - Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver); | 70 | +// Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver); |
67 | - } | 71 | +// } |
68 | - }).start(); | 72 | +// }).start(); |
69 | - | 73 | +// |
70 | - new Thread(() -> { | 74 | +// new Thread(() -> { |
71 | - if (!Thread.currentThread().isInterrupted()) { | 75 | +// if (!Thread.currentThread().isInterrupted()) { |
72 | - WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver); | 76 | +// WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver); |
73 | - } | 77 | +// } |
74 | - }).start(); | 78 | +// }).start(); |
75 | 79 | ||
76 | - initViews(); | 80 | +// initViews(); |
77 | } | 81 | } |
78 | 82 | ||
79 | @Override | 83 | @Override |
... | @@ -145,7 +149,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -145,7 +149,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
145 | @Override | 149 | @Override |
146 | public void onSuccess(Consumer result) { | 150 | public void onSuccess(Consumer result) { |
147 | mConsumer = result; | 151 | mConsumer = result; |
148 | - Thread.currentThread().interrupt(); | 152 | +// Thread.currentThread().interrupt(); |
153 | + Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver); | ||
149 | } | 154 | } |
150 | 155 | ||
151 | @Override | 156 | @Override |
... | @@ -154,8 +159,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -154,8 +159,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
154 | } | 159 | } |
155 | }; | 160 | }; |
156 | 161 | ||
157 | - private final CallbackReceiver<CampaignList> mInboxReceiver = | 162 | + private final CallbackReceiver<CampaignList> mInboxReceiver = new CallbackReceiver<CampaignList>() { |
158 | - new CallbackReceiver<CampaignList>() { | ||
159 | @Override | 163 | @Override |
160 | public void onSuccess(CampaignList result) { | 164 | public void onSuccess(CampaignList result) { |
161 | for (Campaign campaign : result) { | 165 | for (Campaign campaign : result) { |
... | @@ -170,7 +174,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -170,7 +174,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
170 | } | 174 | } |
171 | } | 175 | } |
172 | 176 | ||
173 | - Thread.currentThread().interrupt(); | 177 | +// Thread.currentThread().interrupt(); |
178 | + WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver); | ||
174 | } | 179 | } |
175 | 180 | ||
176 | @Override | 181 | @Override |
... | @@ -179,12 +184,14 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -179,12 +184,14 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
179 | } | 184 | } |
180 | }; | 185 | }; |
181 | 186 | ||
182 | - private final CallbackReceiver<CouponList> mUserCouponsReceiver = | 187 | + private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { |
183 | - new CallbackReceiver<CouponList>() { | ||
184 | @Override | 188 | @Override |
185 | public void onSuccess(CouponList result) { | 189 | public void onSuccess(CouponList result) { |
186 | mCouponList = result; | 190 | mCouponList = result; |
187 | Thread.currentThread().interrupt(); | 191 | Thread.currentThread().interrupt(); |
192 | + new Handler(Looper.getMainLooper()).post(() -> { | ||
193 | + initViews(); | ||
194 | + }); | ||
188 | } | 195 | } |
189 | 196 | ||
190 | @Override | 197 | @Override | ... | ... |
-
Please register or login to post a comment