Showing
5 changed files
with
147 additions
and
105 deletions
| ... | @@ -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.5.4r10' | 5 | + PUBLISH_VERSION = '4.5.5.4r11' |
| 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
| 7 | } | 7 | } |
| 8 | 8 | ... | ... |
| ... | @@ -23,7 +23,6 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver; | ... | @@ -23,7 +23,6 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 23 | import ly.warp.sdk.io.models.Campaign; | 23 | import ly.warp.sdk.io.models.Campaign; |
| 24 | import ly.warp.sdk.io.models.CouponList; | 24 | import ly.warp.sdk.io.models.CouponList; |
| 25 | import ly.warp.sdk.io.models.UnifiedCoupon; | 25 | import ly.warp.sdk.io.models.UnifiedCoupon; |
| 26 | -import ly.warp.sdk.io.request.WarplyGetCampaignsRequest; | ||
| 27 | import ly.warp.sdk.utils.managers.WarplyManager; | 26 | import ly.warp.sdk.utils.managers.WarplyManager; |
| 28 | 27 | ||
| 29 | public class BaseFragmentActivity extends FragmentActivity implements NavigationBarView.OnItemSelectedListener { | 28 | public class BaseFragmentActivity extends FragmentActivity implements NavigationBarView.OnItemSelectedListener { | ... | ... |
| ... | @@ -11,18 +11,18 @@ import java.util.ArrayList; | ... | @@ -11,18 +11,18 @@ import java.util.ArrayList; |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | public class UnifiedCampaignModel implements Serializable { | 13 | public class UnifiedCampaignModel implements Serializable { |
| 14 | - private String id, title, affiliatedId, shortDescription, longDescription, | 14 | + private String id, title, shortDescription, longDescription, |
| 15 | logoImagePath, bigLogoImagePath, dayText, imagePath, bigImagePath, | 15 | logoImagePath, bigLogoImagePath, dayText, imagePath, bigImagePath, |
| 16 | - markerImagePath, details; | 16 | + markerImagePath, details, couponsetUuid, storeId; |
| 17 | - private int position, days; | 17 | + private int position, affiliatedId; |
| 18 | + private ArrayList<String> days; | ||
| 18 | private boolean isHot; | 19 | private boolean isHot; |
| 19 | private ArrayList<UnifiedCampaignLocation> locations; | 20 | private ArrayList<UnifiedCampaignLocation> locations; |
| 20 | 21 | ||
| 21 | - | ||
| 22 | public UnifiedCampaignModel() { | 22 | public UnifiedCampaignModel() { |
| 23 | this.id = ""; | 23 | this.id = ""; |
| 24 | this.title = ""; | 24 | this.title = ""; |
| 25 | - this.affiliatedId = ""; | 25 | + this.affiliatedId = 0; |
| 26 | this.shortDescription = ""; | 26 | this.shortDescription = ""; |
| 27 | this.longDescription = ""; | 27 | this.longDescription = ""; |
| 28 | this.logoImagePath = ""; | 28 | this.logoImagePath = ""; |
| ... | @@ -33,27 +33,39 @@ public class UnifiedCampaignModel implements Serializable { | ... | @@ -33,27 +33,39 @@ public class UnifiedCampaignModel implements Serializable { |
| 33 | this.markerImagePath = ""; | 33 | this.markerImagePath = ""; |
| 34 | this.details = ""; | 34 | this.details = ""; |
| 35 | this.position = 0; | 35 | this.position = 0; |
| 36 | - this.days = 0; | 36 | + this.days = new ArrayList<String>(); |
| 37 | this.isHot = false; | 37 | this.isHot = false; |
| 38 | this.locations = new ArrayList<UnifiedCampaignLocation>(); | 38 | this.locations = new ArrayList<UnifiedCampaignLocation>(); |
| 39 | + this.couponsetUuid = ""; | ||
| 40 | + this.storeId = ""; | ||
| 39 | } | 41 | } |
| 40 | 42 | ||
| 41 | public UnifiedCampaignModel(JSONObject jobj) { | 43 | public UnifiedCampaignModel(JSONObject jobj) { |
| 42 | if (jobj != null) { | 44 | if (jobj != null) { |
| 45 | + this.couponsetUuid = jobj.optString("COUPONSET_UUID"); | ||
| 43 | this.id = jobj.optString("id", ""); | 46 | this.id = jobj.optString("id", ""); |
| 44 | - this.title = jobj.optString("title", ""); | 47 | + this.title = jobj.optString("title"); |
| 45 | - this.affiliatedId = jobj.optString("affiliatedId", ""); | 48 | + this.affiliatedId = jobj.optInt("affiliatedId", 0); |
| 46 | - this.shortDescription = jobj.optString("shortDescription", ""); | 49 | + this.shortDescription = jobj.optString("shortDescription"); |
| 47 | - this.longDescription = jobj.optString("longDescription", ""); | 50 | + this.longDescription = jobj.optString("longDescription"); |
| 48 | - this.logoImagePath = jobj.optString("logoImagePath", ""); | 51 | + this.logoImagePath = jobj.optString("logoImagePath"); |
| 49 | - this.bigLogoImagePath = jobj.optString("bigLogoImagePath", ""); | 52 | + this.bigLogoImagePath = jobj.optString("bigLogoImagePath"); |
| 50 | - this.dayText = jobj.optString("dayText", ""); | 53 | + this.dayText = jobj.optString("dayText"); |
| 51 | - this.imagePath = jobj.optString("imagePath", ""); | 54 | + this.imagePath = jobj.optString("imagePath"); |
| 52 | - this.bigImagePath = jobj.optString("bigImagePath", ""); | 55 | + this.bigImagePath = jobj.optString("bigImagePath"); |
| 53 | - this.markerImagePath = jobj.optString("markerImagePath", ""); | 56 | + this.markerImagePath = jobj.optString("markerImagePath"); |
| 54 | - this.details = jobj.optString("details", ""); | 57 | + this.details = jobj.optString("details"); |
| 55 | - this.position = jobj.optInt("position", 0); | 58 | + this.position = jobj.optInt("position"); |
| 56 | - this.days = jobj.optInt("days", 0); | 59 | + this.days = new ArrayList<>(); |
| 60 | + JSONArray tempDays = new JSONArray(); | ||
| 61 | + tempDays = jobj.optJSONArray("days"); | ||
| 62 | + if (tempDays != null && tempDays.length() > 0) { | ||
| 63 | + ArrayList<String> daysList = new ArrayList<>(); | ||
| 64 | + for (int i = 0; i < tempDays.length(); i++) { | ||
| 65 | + daysList.add(tempDays.optString(i)); | ||
| 66 | + } | ||
| 67 | + this.days.addAll(daysList); | ||
| 68 | + } | ||
| 57 | this.isHot = jobj.optBoolean("isHot", false); | 69 | this.isHot = jobj.optBoolean("isHot", false); |
| 58 | this.locations = new ArrayList<>(); | 70 | this.locations = new ArrayList<>(); |
| 59 | JSONArray tempLocations = new JSONArray(); | 71 | JSONArray tempLocations = new JSONArray(); |
| ... | @@ -65,13 +77,14 @@ public class UnifiedCampaignModel implements Serializable { | ... | @@ -65,13 +77,14 @@ public class UnifiedCampaignModel implements Serializable { |
| 65 | } | 77 | } |
| 66 | this.locations.addAll(locationsList); | 78 | this.locations.addAll(locationsList); |
| 67 | } | 79 | } |
| 80 | + this.storeId = jobj.optString("store_id"); | ||
| 68 | } | 81 | } |
| 69 | } | 82 | } |
| 70 | 83 | ||
| 71 | public class UnifiedCampaignLocation { | 84 | public class UnifiedCampaignLocation { |
| 72 | private String id, title, address, municipality, telephone, | 85 | private String id, title, address, municipality, telephone, |
| 73 | - afiliateId, url, logoImage, pinLogoImage; | 86 | + url, logoImage, pinLogoImage; |
| 74 | - private int roadNumber; | 87 | + private int roadNumber, afiliateId; |
| 75 | private double latitude = 0.0; | 88 | private double latitude = 0.0; |
| 76 | private double longitude = 0.0; | 89 | private double longitude = 0.0; |
| 77 | 90 | ||
| ... | @@ -81,7 +94,7 @@ public class UnifiedCampaignModel implements Serializable { | ... | @@ -81,7 +94,7 @@ public class UnifiedCampaignModel implements Serializable { |
| 81 | this.address = ""; | 94 | this.address = ""; |
| 82 | this.municipality = ""; | 95 | this.municipality = ""; |
| 83 | this.telephone = ""; | 96 | this.telephone = ""; |
| 84 | - this.afiliateId = ""; | 97 | + this.afiliateId = 0; |
| 85 | this.url = ""; | 98 | this.url = ""; |
| 86 | this.logoImage = ""; | 99 | this.logoImage = ""; |
| 87 | this.pinLogoImage = ""; | 100 | this.pinLogoImage = ""; |
| ... | @@ -93,15 +106,15 @@ public class UnifiedCampaignModel implements Serializable { | ... | @@ -93,15 +106,15 @@ public class UnifiedCampaignModel implements Serializable { |
| 93 | public UnifiedCampaignLocation(JSONObject jobj) { | 106 | public UnifiedCampaignLocation(JSONObject jobj) { |
| 94 | if (jobj != null) { | 107 | if (jobj != null) { |
| 95 | this.id = jobj.optString("id", ""); | 108 | this.id = jobj.optString("id", ""); |
| 96 | - this.title = jobj.optString("title", ""); | 109 | + this.title = jobj.optString("title"); |
| 97 | - this.address = jobj.optString("address", ""); | 110 | + this.address = jobj.optString("address"); |
| 98 | - this.municipality = jobj.optString("municipality", ""); | 111 | + this.municipality = jobj.optString("municipality"); |
| 99 | - this.telephone = jobj.optString("telephone", ""); | 112 | + this.telephone = jobj.optString("telephone"); |
| 100 | - this.afiliateId = jobj.optString("afiliateId", ""); | 113 | + this.afiliateId = jobj.optInt("afiliateId"); |
| 101 | - this.url = jobj.optString("url", ""); | 114 | + this.url = jobj.optString("url"); |
| 102 | - this.logoImage = jobj.optString("logoImage", ""); | 115 | + this.logoImage = jobj.optString("logoImage"); |
| 103 | - this.pinLogoImage = jobj.optString("pinLogoImage", ""); | 116 | + this.pinLogoImage = jobj.optString("pinLogoImage"); |
| 104 | - this.roadNumber = jobj.optInt("roadNumber", 0); | 117 | + this.roadNumber = jobj.optInt("roadNumber"); |
| 105 | this.latitude = jobj.optDouble("latitude", 0.0); | 118 | this.latitude = jobj.optDouble("latitude", 0.0); |
| 106 | this.longitude = jobj.optDouble("longitude", 0.0); | 119 | this.longitude = jobj.optDouble("longitude", 0.0); |
| 107 | } | 120 | } |
| ... | @@ -147,11 +160,11 @@ public class UnifiedCampaignModel implements Serializable { | ... | @@ -147,11 +160,11 @@ public class UnifiedCampaignModel implements Serializable { |
| 147 | this.telephone = telephone; | 160 | this.telephone = telephone; |
| 148 | } | 161 | } |
| 149 | 162 | ||
| 150 | - public String getAfiliateId() { | 163 | + public int getAfiliateId() { |
| 151 | return afiliateId; | 164 | return afiliateId; |
| 152 | } | 165 | } |
| 153 | 166 | ||
| 154 | - public void setAfiliateId(String afiliateId) { | 167 | + public void setAfiliateId(int afiliateId) { |
| 155 | this.afiliateId = afiliateId; | 168 | this.afiliateId = afiliateId; |
| 156 | } | 169 | } |
| 157 | 170 | ||
| ... | @@ -220,11 +233,11 @@ public class UnifiedCampaignModel implements Serializable { | ... | @@ -220,11 +233,11 @@ public class UnifiedCampaignModel implements Serializable { |
| 220 | this.title = title; | 233 | this.title = title; |
| 221 | } | 234 | } |
| 222 | 235 | ||
| 223 | - public String getAffiliatedId() { | 236 | + public int getAffiliatedId() { |
| 224 | return affiliatedId; | 237 | return affiliatedId; |
| 225 | } | 238 | } |
| 226 | 239 | ||
| 227 | - public void setAffiliatedId(String affiliatedId) { | 240 | + public void setAffiliatedId(int affiliatedId) { |
| 228 | this.affiliatedId = affiliatedId; | 241 | this.affiliatedId = affiliatedId; |
| 229 | } | 242 | } |
| 230 | 243 | ||
| ... | @@ -308,11 +321,11 @@ public class UnifiedCampaignModel implements Serializable { | ... | @@ -308,11 +321,11 @@ public class UnifiedCampaignModel implements Serializable { |
| 308 | this.position = position; | 321 | this.position = position; |
| 309 | } | 322 | } |
| 310 | 323 | ||
| 311 | - public int getDays() { | 324 | + public ArrayList<String> getDays() { |
| 312 | return days; | 325 | return days; |
| 313 | } | 326 | } |
| 314 | 327 | ||
| 315 | - public void setDays(int days) { | 328 | + public void setDays(ArrayList<String> days) { |
| 316 | this.days = days; | 329 | this.days = days; |
| 317 | } | 330 | } |
| 318 | 331 | ||
| ... | @@ -331,4 +344,20 @@ public class UnifiedCampaignModel implements Serializable { | ... | @@ -331,4 +344,20 @@ public class UnifiedCampaignModel implements Serializable { |
| 331 | public void setLocations(ArrayList<UnifiedCampaignLocation> locations) { | 344 | public void setLocations(ArrayList<UnifiedCampaignLocation> locations) { |
| 332 | this.locations = locations; | 345 | this.locations = locations; |
| 333 | } | 346 | } |
| 347 | + | ||
| 348 | + public String getCouponsetUuid() { | ||
| 349 | + return couponsetUuid; | ||
| 350 | + } | ||
| 351 | + | ||
| 352 | + public void setCouponsetUuid(String couponsetUuid) { | ||
| 353 | + this.couponsetUuid = couponsetUuid; | ||
| 354 | + } | ||
| 355 | + | ||
| 356 | + public String getStoreId() { | ||
| 357 | + return storeId; | ||
| 358 | + } | ||
| 359 | + | ||
| 360 | + public void setStoreId(String storeId) { | ||
| 361 | + this.storeId = storeId; | ||
| 362 | + } | ||
| 334 | } | 363 | } | ... | ... |
| ... | @@ -5,10 +5,12 @@ import okhttp3.RequestBody; | ... | @@ -5,10 +5,12 @@ import okhttp3.RequestBody; |
| 5 | import okhttp3.ResponseBody; | 5 | import okhttp3.ResponseBody; |
| 6 | import retrofit2.Call; | 6 | import retrofit2.Call; |
| 7 | import retrofit2.http.Body; | 7 | import retrofit2.http.Body; |
| 8 | +import retrofit2.http.GET; | ||
| 8 | import retrofit2.http.Header; | 9 | import retrofit2.http.Header; |
| 9 | import retrofit2.http.Headers; | 10 | import retrofit2.http.Headers; |
| 10 | import retrofit2.http.POST; | 11 | import retrofit2.http.POST; |
| 11 | import retrofit2.http.Path; | 12 | import retrofit2.http.Path; |
| 13 | +import retrofit2.http.Query; | ||
| 12 | 14 | ||
| 13 | /** | 15 | /** |
| 14 | * Created by Panagiotis Triantafyllou on 24/Νοε/2022. | 16 | * Created by Panagiotis Triantafyllou on 24/Νοε/2022. |
| ... | @@ -99,6 +101,10 @@ public interface ApiService { | ... | @@ -99,6 +101,10 @@ public interface ApiService { |
| 99 | @Header(WarpConstants.HEADER_WEB_ID) String webId, | 101 | @Header(WarpConstants.HEADER_WEB_ID) String webId, |
| 100 | @Header(WarpConstants.HEADER_SIGNATURE) String signature); | 102 | @Header(WarpConstants.HEADER_SIGNATURE) String signature); |
| 101 | 103 | ||
| 104 | + @GET("/partners/cosmote/{env}/map_data/") | ||
| 105 | + Call<ResponseBody> getMapData(@Path("env") String env, | ||
| 106 | + @Query("language") String language); | ||
| 107 | + | ||
| 102 | @Headers("Content-Type: application/json") | 108 | @Headers("Content-Type: application/json") |
| 103 | @POST("/api/mobile/v2/{appUuid}/context/") | 109 | @POST("/api/mobile/v2/{appUuid}/context/") |
| 104 | Call<ResponseBody> getCampaignsAvailability(@Path("appUuid") String appUuid, | 110 | Call<ResponseBody> getCampaignsAvailability(@Path("appUuid") String appUuid, | ... | ... |
| ... | @@ -114,6 +114,7 @@ import ly.warp.sdk.io.models.TagsList; | ... | @@ -114,6 +114,7 @@ import ly.warp.sdk.io.models.TagsList; |
| 114 | import ly.warp.sdk.io.models.TelematicsHistory; | 114 | import ly.warp.sdk.io.models.TelematicsHistory; |
| 115 | import ly.warp.sdk.io.models.TransactionsList; | 115 | import ly.warp.sdk.io.models.TransactionsList; |
| 116 | import ly.warp.sdk.io.models.TripMetrics; | 116 | import ly.warp.sdk.io.models.TripMetrics; |
| 117 | +import ly.warp.sdk.io.models.UnifiedCampaignModel; | ||
| 117 | import ly.warp.sdk.io.models.UnifiedCoupon; | 118 | import ly.warp.sdk.io.models.UnifiedCoupon; |
| 118 | import ly.warp.sdk.io.models.WarplyPacingEventModel; | 119 | import ly.warp.sdk.io.models.WarplyPacingEventModel; |
| 119 | import ly.warp.sdk.io.request.CosmoteCouponSharingRequest; | 120 | import ly.warp.sdk.io.request.CosmoteCouponSharingRequest; |
| ... | @@ -2112,6 +2113,79 @@ public class WarplyManager { | ... | @@ -2112,6 +2113,79 @@ public class WarplyManager { |
| 2112 | return future; | 2113 | return future; |
| 2113 | } | 2114 | } |
| 2114 | 2115 | ||
| 2116 | + public static void getMapData(final CallbackReceiver<ArrayList<UnifiedCampaignModel>> receiver) { | ||
| 2117 | + WarpUtils.log("************* WARPLY Get Map Data Request ********************"); | ||
| 2118 | + WarpUtils.log("[WARP Trace] WARPLY Get Map Data Request is active"); | ||
| 2119 | + WarpUtils.log("**************************************************"); | ||
| 2120 | + | ||
| 2121 | + ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | ||
| 2122 | + getMapDataRetro(service, receiver); | ||
| 2123 | + } | ||
| 2124 | + | ||
| 2125 | + private static void getMapDataRetro(ApiService service, final CallbackReceiver<ArrayList<UnifiedCampaignModel>> receiver) { | ||
| 2126 | + String serviceEnv = WarplyProperty.getAppUuid(Warply.getWarplyContext()).equals("0086a2088301440792091b9f814c2267") ? "prod" : "dev"; | ||
| 2127 | + Call<ResponseBody> call = service.getMapData( | ||
| 2128 | + serviceEnv, | ||
| 2129 | + WarplyProperty.getLanguage(Warply.getWarplyContext()) | ||
| 2130 | + ); | ||
| 2131 | + | ||
| 2132 | + call.enqueue(new Callback<ResponseBody>() { | ||
| 2133 | + @Override | ||
| 2134 | + public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { | ||
| 2135 | + if (response.code() == 200 && response.body() != null) { | ||
| 2136 | + JSONObject jobjMapDataResponse = null; | ||
| 2137 | + try { | ||
| 2138 | + jobjMapDataResponse = new JSONObject(response.body().string()); | ||
| 2139 | + } catch (Exception e) { | ||
| 2140 | + e.printStackTrace(); | ||
| 2141 | + } | ||
| 2142 | + | ||
| 2143 | + if (jobjMapDataResponse != null && jobjMapDataResponse.has("status") && jobjMapDataResponse.optString("status", "2").equals("1")) { | ||
| 2144 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
| 2145 | + dynatraceEvent.setEventName("custom_success_map_data"); | ||
| 2146 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
| 2147 | + | ||
| 2148 | + JSONArray jMapDataBody = null; | ||
| 2149 | + try { | ||
| 2150 | + jMapDataBody = jobjMapDataResponse.optJSONObject("result").optJSONArray("offers"); | ||
| 2151 | + } catch (Exception e) { | ||
| 2152 | + e.printStackTrace(); | ||
| 2153 | + } | ||
| 2154 | + | ||
| 2155 | + if (jMapDataBody != null) { | ||
| 2156 | + ArrayList<UnifiedCampaignModel> mMapDataList = new ArrayList<>(); | ||
| 2157 | + final ExecutorService executorMapData = Executors.newFixedThreadPool(1); | ||
| 2158 | + JSONArray finalMapDataJBody = jMapDataBody; | ||
| 2159 | + executorMapData.submit(() -> { | ||
| 2160 | + for (int i = 0; i < finalMapDataJBody.length(); ++i) { | ||
| 2161 | + mMapDataList.add(new UnifiedCampaignModel(finalMapDataJBody.optJSONObject(i))); | ||
| 2162 | + } | ||
| 2163 | + | ||
| 2164 | + executorMapData.shutdownNow(); | ||
| 2165 | + new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mMapDataList)); | ||
| 2166 | + }); | ||
| 2167 | + } | ||
| 2168 | + } else { | ||
| 2169 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
| 2170 | + dynatraceEvent.setEventName("custom_error_map_data"); | ||
| 2171 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
| 2172 | + receiver.onFailure(2); | ||
| 2173 | + } | ||
| 2174 | + } else { | ||
| 2175 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
| 2176 | + dynatraceEvent.setEventName("custom_error_map_data"); | ||
| 2177 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
| 2178 | + receiver.onFailure(response.code()); | ||
| 2179 | + } | ||
| 2180 | + } | ||
| 2181 | + | ||
| 2182 | + @Override | ||
| 2183 | + public void onFailure(Call<ResponseBody> call, Throwable t) { | ||
| 2184 | + receiver.onFailure(2); | ||
| 2185 | + } | ||
| 2186 | + }); | ||
| 2187 | + } | ||
| 2188 | + | ||
| 2115 | public static void getCampaignsPersonalized(WarplyGetCampaignsRequest request, final CallbackReceiver<ArrayList<Campaign>> receiver) { | 2189 | public static void getCampaignsPersonalized(WarplyGetCampaignsRequest request, final CallbackReceiver<ArrayList<Campaign>> receiver) { |
| 2116 | WarpUtils.log("************* WARPLY Get Campaigns Request ********************"); | 2190 | WarpUtils.log("************* WARPLY Get Campaigns Request ********************"); |
| 2117 | WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active"); | 2191 | WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active"); |
| ... | @@ -4470,72 +4544,6 @@ public class WarplyManager { | ... | @@ -4470,72 +4544,6 @@ public class WarplyManager { |
| 4470 | }, null); | 4544 | }, null); |
| 4471 | } | 4545 | } |
| 4472 | 4546 | ||
| 4473 | - public static void makeGetRequest(String url) { | ||
| 4474 | -// Always run it in a new Thread, not in the main, ie Executors | ||
| 4475 | -// new Thread(() -> { | ||
| 4476 | -// makeGetRequest(session_uuid); | ||
| 4477 | -// }).start(); | ||
| 4478 | - | ||
| 4479 | -// Also add those two dependencies | ||
| 4480 | -// api 'com.squareup.retrofit2:retrofit:2.9.0' | ||
| 4481 | -// api 'com.squareup.okhttp3:okhttp:4.10.0' | ||
| 4482 | - | ||
| 4483 | -// And uncomment the code inside ApiService.java | ||
| 4484 | - | ||
| 4485 | -// OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); | ||
| 4486 | -// httpClient.followRedirects(false) | ||
| 4487 | -// .followSslRedirects(false); | ||
| 4488 | -// | ||
| 4489 | -// Retrofit retrofit = new Retrofit.Builder() | ||
| 4490 | -// .baseUrl(WarplyProperty.getBaseUrl(Warply.getWarplyContext())) | ||
| 4491 | -// .client(httpClient.build()) | ||
| 4492 | -// .build(); | ||
| 4493 | -// | ||
| 4494 | -// RetrofitInterface service = retrofit.create(RetrofitInterface.class); | ||
| 4495 | -// Call<ResponseBody> respo = service.getSingleCampaign(url); | ||
| 4496 | -// respo.enqueue(new Callback<ResponseBody>() { | ||
| 4497 | -// @Override | ||
| 4498 | -// public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { | ||
| 4499 | -// LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
| 4500 | -// dynatraceEvent.setEventName("custom_success_read_campaign_loyalty"); | ||
| 4501 | -// EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
| 4502 | -// | ||
| 4503 | -// getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), new CallbackReceiver<ArrayList<Campaign>>() { | ||
| 4504 | -// @Override | ||
| 4505 | -// public void onSuccess(ArrayList<Campaign> result) { | ||
| 4506 | -// OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build(); | ||
| 4507 | -// WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork); | ||
| 4508 | -// } | ||
| 4509 | -// | ||
| 4510 | -// @Override | ||
| 4511 | -// public void onFailure(int errorCode) { | ||
| 4512 | -// | ||
| 4513 | -// } | ||
| 4514 | -// }); | ||
| 4515 | -// } | ||
| 4516 | -// | ||
| 4517 | -// @Override | ||
| 4518 | -// public void onFailure(Call<ResponseBody> call, Throwable t) { | ||
| 4519 | -// LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
| 4520 | -// dynatraceEvent.setEventName("custom_success_read_campaign_loyalty"); | ||
| 4521 | -// EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
| 4522 | -// | ||
| 4523 | -// getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), new CallbackReceiver<ArrayList<Campaign>>() { | ||
| 4524 | -// @Override | ||
| 4525 | -// public void onSuccess(ArrayList<Campaign> result) { | ||
| 4526 | -// OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build(); | ||
| 4527 | -// WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork); | ||
| 4528 | -// } | ||
| 4529 | -// | ||
| 4530 | -// @Override | ||
| 4531 | -// public void onFailure(int errorCode) { | ||
| 4532 | -// | ||
| 4533 | -// } | ||
| 4534 | -// }); | ||
| 4535 | -// } | ||
| 4536 | -// }); | ||
| 4537 | - } | ||
| 4538 | - | ||
| 4539 | private static boolean isMyServiceRunning(Class<?> serviceClass) { | 4547 | private static boolean isMyServiceRunning(Class<?> serviceClass) { |
| 4540 | ActivityManager manager = (ActivityManager) Warply.getWarplyContext().getSystemService(Context.ACTIVITY_SERVICE); | 4548 | ActivityManager manager = (ActivityManager) Warply.getWarplyContext().getSystemService(Context.ACTIVITY_SERVICE); |
| 4541 | for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { | 4549 | for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { | ... | ... |
-
Please register or login to post a comment