Skip to content

Commit

Permalink
Merge pull request #8 from rees46/feat/stories-addTextBlocks
Browse files Browse the repository at this point in the history
feat: stories - add text blocks
  • Loading branch information
TorinAsakura authored May 30, 2024
2 parents dec9935 + cd7d1ce commit 57e1de7
Show file tree
Hide file tree
Showing 36 changed files with 1,714 additions and 870 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ REES46.subscribeForBackInStock("PRODUCT_ID", properties, "[email protected]", nul
Add code to your layout:

```xml
<com.personalizatio.stories.StoriesView
<com.personalizatio.stories.views.StoriesView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:code="STORY BLOCK CODE" />
Expand Down
135 changes: 84 additions & 51 deletions personalizatio-sdk/src/main/java/com/personalizatio/Product.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,95 @@
package com.personalizatio;

import org.json.JSONException;
import androidx.annotation.NonNull;

import org.json.JSONObject;

final public class Product {
public final String id;
public final String name;
public final String brand;
public final String image;
public final String oldprice;
public final String price;
public final String discount;
public final String url;
public final String deeplink;
public final String promocode;
public final String price_with_promocode;
public final String discount_percent;

public Product(JSONObject product) throws JSONException {
id = product.getString("id");
name = product.getString("name");
image = product.getString("image_url");
if( product.has("oldprice") && product.getDouble("oldprice") > 0 ) {
oldprice = product.getString("oldprice_formatted");
} else {
oldprice = null;
}
if( product.has("brand") ) {
brand = product.getString("brand");
} else {
brand = null;
}
if( product.has("promocode") ) {
promocode = product.getString("promocode");
} else {
promocode = null;
}
if( product.has("price_with_promocode") ) {
price_with_promocode = product.getString("price_with_promocode_formatted");
} else {
price_with_promocode = null;
private final String id;
private final String name;
private final String brand;
private final String image;
private final String oldPrice;
private final String price;
private final String discount;
private final String url;
private final String deeplink;
private final String promocode;
private final String priceWithPromocode;
private final String discountPercent;

public Product(@NonNull JSONObject json) {
id = json.optString("id", "");
name = json.optString("name", "");
image = json.optString("image_url", "");
var oldPriceValue = json.optDouble("oldprice", 0);
if (oldPriceValue > 0) {
oldPrice = json.optString("oldprice_formatted", "");
}
if( product.has("discount_percent") ) {
discount_percent = product.getString("discount_percent");
} else {
discount_percent = null;
else {
oldPrice = "";
}
price = product.getString("price_formatted");
url = product.getString("url");
if( product.has("deeplink_android") ) {
deeplink = product.getString("deeplink_android");
} else {
deeplink = null;
brand = json.optString("brand", "");
promocode = json.optString("promocode", "");
priceWithPromocode = json.optString("price_with_promocode_formatted", "");
discountPercent = json.optString("discount_percent", "");
price = json.optString("price_formatted", "");
url = json.optString("url", "");
deeplink = json.optString("deeplink_android", "");
var priceValue = json.optDouble("price", 0);
if (oldPriceValue > 0 && oldPriceValue > priceValue) {
discount = json.optString("discount", "");
}
if( product.has("discount") && product.getDouble("oldprice") > 0 && product.getDouble("oldprice") > product.getDouble("price") ) {
discount = product.getString("discount");
} else {
discount = null;
else {
discount = "";
}
}

public String getId() {
return id;
}

public String getName() {
return name;
}

public String getBrand() {
return brand;
}

public String getImage() {
return image;
}

public String getOldPrice() {
return oldPrice;
}

public String getPrice() {
return price;
}

public String getDiscount() {
return discount;
}

public String getUrl() {
return url;
}

public String getDeeplink() {
return deeplink;
}

public String getPromocode() {
return promocode;
}

public String getPriceWithPromocode() {
return priceWithPromocode;
}

public String getDiscountPercent() {
return discountPercent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import java.io.File;

@UnstableApi
final class Player {
final public class Player {

static ExoPlayer player;
static SimpleCache cache;
private static ExoPlayer player;
private static SimpleCache cache;

public Player(Context context) {
if( player == null ) {
Expand All @@ -36,6 +36,10 @@ public Player(Context context) {
}
}

public ExoPlayer getPlayer() {
return player;
}

public void prepare(String url) {
ProgressiveMediaSource mediaSource = new ProgressiveMediaSource.Factory(
new CacheDataSource.Factory()
Expand Down
121 changes: 0 additions & 121 deletions personalizatio-sdk/src/main/java/com/personalizatio/stories/Story.java

This file was deleted.

Loading

0 comments on commit 57e1de7

Please sign in to comment.