Showing
2 changed files
with
35 additions
and
2 deletions
| ... | @@ -25,6 +25,8 @@ | ... | @@ -25,6 +25,8 @@ |
| 25 | 25 | ||
| 26 | package ly.warp.sdk.io.callbacks; | 26 | package ly.warp.sdk.io.callbacks; |
| 27 | 27 | ||
| 28 | +import android.text.TextUtils; | ||
| 29 | + | ||
| 28 | import org.json.JSONObject; | 30 | import org.json.JSONObject; |
| 29 | 31 | ||
| 30 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
| ... | @@ -33,6 +35,7 @@ import ly.warp.sdk.io.models.Campaign; | ... | @@ -33,6 +35,7 @@ import ly.warp.sdk.io.models.Campaign; |
| 33 | import ly.warp.sdk.io.models.CampaignList; | 35 | import ly.warp.sdk.io.models.CampaignList; |
| 34 | import ly.warp.sdk.io.models.NewCampaign; | 36 | import ly.warp.sdk.io.models.NewCampaign; |
| 35 | import ly.warp.sdk.io.models.NewCampaignList; | 37 | import ly.warp.sdk.io.models.NewCampaignList; |
| 38 | +import ly.warp.sdk.utils.WarpJSONParser; | ||
| 36 | 39 | ||
| 37 | /** | 40 | /** |
| 38 | * Created by Panagiotis Triantafyllou on 12-May-22. | 41 | * Created by Panagiotis Triantafyllou on 12-May-22. |
| ... | @@ -67,12 +70,26 @@ public class NewCampaignsHook implements CallbackReceiver<JSONObject> { | ... | @@ -67,12 +70,26 @@ public class NewCampaignsHook implements CallbackReceiver<JSONObject> { |
| 67 | camp.setSorting(newCamp.getSorting()); | 70 | camp.setSorting(newCamp.getSorting()); |
| 68 | camp.setNew(newCamp.getIsNew()); | 71 | camp.setNew(newCamp.getIsNew()); |
| 69 | camp.setType(newCamp.getCampaignType()); | 72 | camp.setType(newCamp.getCampaignType()); |
| 70 | - camp.setBannerImage(newCamp.getBannerImage()); | ||
| 71 | - camp.setBannerTitle(newCamp.getBannerTitle()); | ||
| 72 | try { | 73 | try { |
| 73 | camp.setExtraFields(newCamp.getExtraFields().toString()); | 74 | camp.setExtraFields(newCamp.getExtraFields().toString()); |
| 75 | + if (!TextUtils.isEmpty(newCamp.getExtraFields().toString())) { | ||
| 76 | + JSONObject extraFieldsResp = WarpJSONParser.getJSONFromString(newCamp.getExtraFields().toString()); | ||
| 77 | + if (extraFieldsResp != null) { | ||
| 78 | + if (extraFieldsResp.has("Banner_title")) { | ||
| 79 | + camp.setBannerTitle(extraFieldsResp.optString("Banner_title", "")); | ||
| 80 | + } | ||
| 81 | + if (extraFieldsResp.has("Banner_img")) { | ||
| 82 | + camp.setBannerImage(extraFieldsResp.optString("Banner_img", "")); | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + } else { | ||
| 86 | + camp.setBannerImage(""); | ||
| 87 | + camp.setBannerTitle(""); | ||
| 88 | + } | ||
| 74 | } catch (NullPointerException e) { | 89 | } catch (NullPointerException e) { |
| 75 | camp.setExtraFields(""); | 90 | camp.setExtraFields(""); |
| 91 | + camp.setBannerImage(""); | ||
| 92 | + camp.setBannerTitle(""); | ||
| 76 | e.printStackTrace(); | 93 | e.printStackTrace(); |
| 77 | } | 94 | } |
| 78 | 95 | ... | ... |
| ... | @@ -27,6 +27,7 @@ package ly.warp.sdk.io.models; | ... | @@ -27,6 +27,7 @@ package ly.warp.sdk.io.models; |
| 27 | 27 | ||
| 28 | import android.os.Parcel; | 28 | import android.os.Parcel; |
| 29 | import android.os.Parcelable; | 29 | import android.os.Parcelable; |
| 30 | +import android.text.TextUtils; | ||
| 30 | 31 | ||
| 31 | import org.json.JSONArray; | 32 | import org.json.JSONArray; |
| 32 | import org.json.JSONException; | 33 | import org.json.JSONException; |
| ... | @@ -36,6 +37,7 @@ import java.io.Serializable; | ... | @@ -36,6 +37,7 @@ import java.io.Serializable; |
| 36 | import java.util.ArrayList; | 37 | import java.util.ArrayList; |
| 37 | 38 | ||
| 38 | import ly.warp.sdk.Warply; | 39 | import ly.warp.sdk.Warply; |
| 40 | +import ly.warp.sdk.utils.WarpJSONParser; | ||
| 39 | import ly.warp.sdk.utils.WarpUtils; | 41 | import ly.warp.sdk.utils.WarpUtils; |
| 40 | import ly.warp.sdk.utils.WarplyProperty; | 42 | import ly.warp.sdk.utils.WarplyProperty; |
| 41 | import ly.warp.sdk.utils.constants.WarpConstants; | 43 | import ly.warp.sdk.utils.constants.WarpConstants; |
| ... | @@ -170,6 +172,20 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -170,6 +172,20 @@ public class Campaign implements Parcelable, Serializable { |
| 170 | this.isNew = json.optBoolean(IS_NEW); | 172 | this.isNew = json.optBoolean(IS_NEW); |
| 171 | this.sorting = json.optInt(SORTING); | 173 | this.sorting = json.optInt(SORTING); |
| 172 | this.extraFields = json.optString(EXTRA_FIELDS); | 174 | this.extraFields = json.optString(EXTRA_FIELDS); |
| 175 | + if (!TextUtils.isEmpty(this.extraFields)) { | ||
| 176 | + JSONObject extraFieldsResp = WarpJSONParser.getJSONFromString(this.extraFields); | ||
| 177 | + if (extraFieldsResp != null) { | ||
| 178 | + if (extraFieldsResp.has("Banner_title")) { | ||
| 179 | + this.bannerTitle = extraFieldsResp.optString(BANNER_TITLE, ""); | ||
| 180 | + } | ||
| 181 | + if (extraFieldsResp.has("Banner_img")) { | ||
| 182 | + this.bannerImage = extraFieldsResp.optString(BANNER_IMAGE, ""); | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + } else { | ||
| 186 | + this.bannerImage = ""; | ||
| 187 | + this.bannerTitle = ""; | ||
| 188 | + } | ||
| 173 | this.type = json.optString(TYPE); | 189 | this.type = json.optString(TYPE); |
| 174 | this.expired = json.optBoolean(EXPIRED); | 190 | this.expired = json.optBoolean(EXPIRED); |
| 175 | this.show = json.optBoolean(SHOW); | 191 | this.show = json.optBoolean(SHOW); | ... | ... |
-
Please register or login to post a comment