index int64 | repo_id string | file_path string | content string |
|---|---|---|---|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data/bid/Bid.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.data.bid;
import android.text.TextUtils;
import android.util.Base64;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.http.HTTPGet;
import org.prebid.mobile.http.HTTPResponse;
import org.prebid.mobile.rendering.models.internal.MacrosModel;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.MobileSdkPassThrough;
import org.prebid.mobile.rendering.utils.helpers.MacrosResolutionHelper;
import java.util.HashMap;
import java.util.Map;
public class Bid {
private static final String TAG = "NBAds";
// Bidder generated bid ID to assist with logging/tracking.
private String id;
// ID of the bid request to which this is a response.
private String requestId;
// ID of the Imp object in the related bid request.
private String impId;
// Bid price expressed as CPM although the actual transaction is
// for a unit impression only.
private double price;
private String cur; // populated from Bid response
// Optional means of conveying ad markup in case the bid wins;
// supersedes the win notice if markup is included in both.
// Substitution macros (Section 4.4) may be included.
private String adm;
// Creative ID to assist with ad quality checking.
private String crid;
// Width of the creative in device independent pixels (DIPS)
private int width;
// Height of the creative in device independent pixels (DIPS).
private int height;
// "prebid" object from "ext"
private Prebid prebid;
// Win notice URL called by the exchange if the bid wins (not necessarily indicative of a delivered, viewed, or billable ad);
// optional means of serving ad markup
private String nurl;
// Billing notice URL called by the exchange when a winning bid
// becomes billable based on exchange-specific business policy
private String burl;
// Loss notice URL called by the exchange when a bid is known to
// have been lost
private String lurl;
// ID of a preloaded ad to be served if the bid wins
private String adid;
// Advertiser domain for block list checking
private String[] adomain;
// A platform-specific application identifier intended to be unique to the app and independent of the exchange.
private String bundle;
// URL without cache-busting to an image that is representative
// of the content of the campaign for ad quality/safety checking
private String iurl;
// Campaign ID to assist with ad quality checking; the collection
// of creatives for which iurl should be representative
private String cid;
// Bid json string. Used only for CacheManager.
private String jsonString;
// Tactic ID to enable buyers to label bids for reporting to the
// exchange the tactic through which their bid was submitted
private String tactic;
// IAB content categories of the creative
private String[] cat;
// Set of attributes describing the creative
private int[] attr;
// API required by the markup if applicable
private int api;
// Video response protocol of the markup if applicable.
private int protocol;
// Creative media rating per IQG guidelines
private int qagmediarating;
// Language of the creative using ISO-639-1-alpha-2
private String language;
// Reference to the deal.id from the bid request if this bid
// pertains to a private marketplace direct deal
private String dealId;
// Relative width of the creative when expressing size as a ratio.
// Required for Flex Ads
private int WRatio;
// Relative height of the creative when expressing size as a ratio.
// Required for Flex Ads
private int HRatio;
// Advisory as to the number of seconds the bidder is willing to
// wait between the auction and the actual impression
private int exp;
private MobileSdkPassThrough mobileSdkPassThrough;
protected Bid() {
}
public String getRequestId() {
return requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public String getId() {
return id;
}
public String getImpId() {
return impId;
}
public double getPrice() {
return price;
}
public String getCur() {
return cur;
}
public String getAdm() {
return adm;
}
public String getCrid() {
return crid;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public Prebid getPrebid() {
if (prebid == null) {
prebid = new Prebid();
}
return prebid;
}
public String getNurl() {
return nurl;
}
public String getBurl() {
return burl;
}
public String getLurl() {
return lurl;
}
public String getAdid() {
return adid;
}
public String[] getAdomain() {
return adomain;
}
public String getBundle() {
return bundle;
}
public String getIurl() {
return iurl;
}
public String getCid() {
return cid;
}
public String getTactic() {
return tactic;
}
public String[] getCat() {
return cat;
}
public int[] getAttr() {
return attr;
}
public int getApi() {
return api;
}
public int getProtocol() {
return protocol;
}
public int getQagmediarating() {
return qagmediarating;
}
public String getLanguage() {
return language;
}
public String getDealId() {
return dealId;
}
public int getWRatio() {
return WRatio;
}
public int getHRatio() {
return HRatio;
}
public int getExp() {
return exp;
}
public String getJsonString() {
return jsonString;
}
public MobileSdkPassThrough getMobileSdkPassThrough() {
return mobileSdkPassThrough;
}
public static final int LOST_TO_HIGHER_BID = 102;
public static final int BID_WAS_BELOW_AUCTION_FLOOR = 100;
public void notifyAuctionLoss(int lossReason) {
// OpenRTB 2.5: https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf
if (!TextUtils.isEmpty(lurl)) {
lurl = lurl.replace("${AUCTION_LOSS}", String.valueOf(lossReason));
lurl = lurl.replace("${AUCTION_PRICE}", String.valueOf(price));
HTTPGet fire = new HTTPGet() {
@Override
protected void onPostExecute(HTTPResponse response) {}
@Override
protected String getUrl() {
LogUtil.debug(TAG, "notifyAuctionLoss. lurl: " + lurl);
return lurl;
}
};
fire.execute();
}
}
public void notifyAuctionWin() {
if (!TextUtils.isEmpty(nurl)) {
nurl = nurl.replace("${AUCTION_PRICE}", String.valueOf(price));
HTTPGet fire = new HTTPGet() {
@Override
protected void onPostExecute(HTTPResponse response) {}
@Override
protected String getUrl() {
LogUtil.debug(TAG, "notifyAuctionWin. nurl: " + nurl);
return nurl;
}
};
fire.execute();
}
}
public static Bid fromJSONObject(JSONObject jsonObject) {
return fromJSONObject(jsonObject, null);
}
public static Bid fromJSONObject(JSONObject jsonObject, String cur) {
Bid bid = new Bid();
if (jsonObject == null) {
return bid;
}
try {
if (jsonObject != null && !TextUtils.isEmpty(cur)) {
jsonObject.put("cur", cur);
}
} catch (JSONException e){}
bid.jsonString = jsonObject.toString();
bid.cur = jsonObject.optString("cur", null);
bid.id = jsonObject.optString("id", null);
bid.impId = jsonObject.optString("impid", null);
bid.price = jsonObject.optDouble("price", 0);
bid.adm = jsonObject.optString("adm", null);
bid.crid = jsonObject.optString("crid", null);
bid.width = jsonObject.optInt("w");
bid.height = jsonObject.optInt("h");
bid.nurl = jsonObject.optString("nurl", null);
bid.burl = jsonObject.optString("burl", null);
bid.lurl = jsonObject.optString("lurl", null);
bid.adid = jsonObject.optString("adid", null);
bid.adomain = getStringArrayFromJson(jsonObject, "adomain");
bid.bundle = jsonObject.optString("bundle", null);
bid.iurl = jsonObject.optString("iurl", null);
bid.cid = jsonObject.optString("cid", null);
bid.tactic = jsonObject.optString("tactic", null);
bid.cat = getStringArrayFromJson(jsonObject, "cat");
bid.attr = getIntArrayFromJson(jsonObject, "attr");
bid.api = jsonObject.optInt("api", -1);
bid.protocol = jsonObject.optInt("protocol", -1);
bid.qagmediarating = jsonObject.optInt("qagmediarating", -1);
bid.language = jsonObject.optString("language", null);
bid.dealId = jsonObject.optString("dealid", null);
bid.WRatio = jsonObject.optInt("wratio");
bid.HRatio = jsonObject.optInt("hratio");
bid.exp = jsonObject.optInt("exp", -1);
JSONObject ext = jsonObject.optJSONObject("ext");
if (ext != null) {
bid.prebid = Prebid.fromJSONObject(ext.optJSONObject("prebid"));
bid.mobileSdkPassThrough = MobileSdkPassThrough.create(ext);
}
substituteMacros(bid);
return bid;
}
public void setAdm(String adm) {
this.adm = adm;
}
private static String[] getStringArrayFromJson(JSONObject jsonObject, String key) {
if (jsonObject.has(key)) {
JSONArray jsonArray = jsonObject.optJSONArray(key);
if (jsonArray != null && jsonArray.length() > 0) {
int length = jsonArray.length();
String[] stringArray = new String[length];
for (int i = 0; i < length; i++) {
stringArray[i] = jsonArray.optString(i);
}
return stringArray;
}
}
return new String[0];
}
private static int[] getIntArrayFromJson(JSONObject jsonObject, String key) {
if (jsonObject.has(key)) {
JSONArray jsonArray = jsonObject.optJSONArray(key);
if (jsonArray != null && jsonArray.length() > 0) {
int length = jsonArray.length();
int[] intArray = new int[length];
for (int i = 0; i < length; i++) {
intArray[i] = jsonArray.optInt(i);
}
return intArray;
}
}
return new int[0];
}
private static void substituteMacros(Bid bid) {
Map<String, MacrosModel> macrosModelMap = new HashMap<>();
String priceText = String.valueOf(bid.getPrice());
String base64PriceText = Base64.encodeToString(priceText.getBytes(), Base64.NO_WRAP);
macrosModelMap.put(MacrosModel.MACROS_AUCTION_PRICE, new MacrosModel(priceText));
macrosModelMap.put(MacrosModel.MACROS_AUCTION_PRICE_BASE_64, new MacrosModel(base64PriceText));
bid.adm = MacrosResolutionHelper.resolveAuctionMacros(bid.adm, macrosModelMap);
bid.nurl = MacrosResolutionHelper.resolveAuctionMacros(bid.nurl, macrosModelMap);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data/bid/BidResponse.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.data.bid;
import android.content.Context;
import android.text.TextUtils;
import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.MobileSdkPassThrough;
import org.prebid.mobile.rendering.utils.helpers.Dips;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class BidResponse {
private final static String TAG = BidResponse.class.getSimpleName();
public static final String KEY_CACHE_ID = "hb_cache_id_local";
// ID of the bid request to which this is a response
private String id;
// Bid currency using ISO-4217 alpha codes.
private String cur;
//Bidder generated response ID to assist with logging/tracking.
private String bidId;
//Optional feature to allow a bidder to set data in the exchange’s cookie
private String customData;
// Reason for not bidding
private int nbr;
// Array of seatbid objects; 1+ required if a bid is to be made.
private List<Seatbid> seatbids;
private Ext ext;
private boolean hasParseError = false;
private boolean isOriginalAdUnit;
private String parseError;
private String winningBidJson;
private long creationTime;
private MobileSdkPassThrough mobileSdkPassThrough;
public BidResponse(
String json,
AdUnitConfiguration adUnitConfiguration
) {
seatbids = new ArrayList<>();
isOriginalAdUnit = adUnitConfiguration.isOriginalAdUnit();
parseJson(json);
}
public String getId() {
return id;
}
public List<Seatbid> getSeatbids() {
return seatbids;
}
public String getCur() {
return cur;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
public boolean hasParseError() {
return hasParseError;
}
public String getParseError() {
return parseError;
}
public String getBidId() {
return bidId;
}
public String getCustomData() {
return customData;
}
public int getNbr() {
return nbr;
}
public String getWinningBidJson() {
return winningBidJson;
}
private void parseJson(String json) {
winningBidJson = json;
try {
JSONObject responseJson = new JSONObject(json);
id = responseJson.optString("id");
cur = responseJson.optString("cur");
bidId = responseJson.optString("bidid");
customData = responseJson.optString("customdata");
nbr = responseJson.optInt("nbr", -1);
MobileSdkPassThrough rootMobilePassThrough = null;
if (responseJson.has("ext")) {
ext = new Ext();
JSONObject extJsonObject = responseJson.optJSONObject("ext");
ext.put(extJsonObject);
if (extJsonObject != null) {
rootMobilePassThrough = MobileSdkPassThrough.create(extJsonObject);
}
}
JSONArray jsonSeatbids = responseJson.optJSONArray("seatbid");
if (jsonSeatbids != null) {
for (int i = 0; i < jsonSeatbids.length(); i++) {
Seatbid seatbid = Seatbid.fromJSONObject(jsonSeatbids.optJSONObject(i), cur, id);
seatbids.add(seatbid);
}
}
MobileSdkPassThrough bidMobilePassThrough = null;
Bid winningBid = getWinningBid();
if (winningBid == null) {
hasParseError = true;
parseError = "Failed to parse bids. No winning bids were found.";
LogUtil.info(TAG, parseError);
} else {
bidMobilePassThrough = winningBid.getMobileSdkPassThrough();
}
mobileSdkPassThrough = MobileSdkPassThrough.combine(bidMobilePassThrough, rootMobilePassThrough);
creationTime = System.currentTimeMillis();
}
catch (JSONException e) {
hasParseError = true;
parseError = "Failed to parse JSON String: " + e.getMessage();
LogUtil.error(TAG, parseError);
}
}
public long getCreationTime() {
return creationTime;
}
@Nullable
public Bid getWinningBid() {
if (seatbids == null) {
return null;
}
for (Seatbid seatbid : seatbids) {
for (Bid bid : seatbid.getBids()) {
if (hasWinningKeywords(bid.getPrebid())) {
winningBidJson = bid.getJsonString();
return bid;
}
}
}
return null;
}
@NonNull
public HashMap<String, String> getTargeting() {
HashMap<String, String> keywords = new HashMap<>();
for (Seatbid seatbid : seatbids) {
for (Bid bid : seatbid.getBids()) {
if (bid.getPrebid() != null) {
keywords.putAll(bid.getPrebid().getTargeting());
}
}
}
return keywords;
}
@NonNull
public HashMap<String, String> getTargetingWithCacheId() {
// required for future BidResponseCache access
final HashMap<String, String> targeting = getTargeting();
targeting.put(KEY_CACHE_ID, id);
return targeting;
}
public boolean isVideo() {
Bid bid = getWinningBid();
if (bid != null) {
return Utils.isVast(bid.getAdm());
}
return false;
}
private boolean hasWinningKeywords(Prebid prebid) {
if (prebid == null || prebid.getTargeting().isEmpty()) {
return false;
}
HashMap<String, String> targeting = prebid.getTargeting();
return targeting.containsKey("hb_pb") && targeting.containsKey("hb_bidder");
}
@NonNull
public Pair<Integer, Integer> getWinningBidWidthHeightPairDips(Context context) {
final Bid winningBid = getWinningBid();
if (winningBid == null) {
return new Pair<>(0, 0);
}
final int width = Dips.dipsToIntPixels(winningBid.getWidth(), context);
final int height = Dips.dipsToIntPixels(winningBid.getHeight(), context);
return new Pair<>(width, height);
}
@Nullable
public MobileSdkPassThrough getMobileSdkPassThrough() {
return mobileSdkPassThrough;
}
public void setMobileSdkPassThrough(@Nullable MobileSdkPassThrough mobileSdkPassThrough) {
this.mobileSdkPassThrough = mobileSdkPassThrough;
}
@Nullable
public String getImpressionEventUrl() {
Bid winningBid = getWinningBid();
if (winningBid != null) {
Prebid prebid = winningBid.getPrebid();
return prebid.getImpEventUrl();
}
return null;
}
@Nullable
public Integer getExpirationTimeSeconds() {
Bid winningBid = getWinningBid();
if (winningBid == null) return null;
int expirationTime = winningBid.getExp();
if (expirationTime <= 0) {
return null;
}
return expirationTime;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data/bid/Bids.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.data.bid;
import org.json.JSONObject;
public class Bids {
private String url;
private String cacheId;
protected Bids() {
}
public String getUrl() {
return url;
}
public String getCacheId() {
return cacheId;
}
public static Bids fromJSONObject(JSONObject jsonObject) {
Bids bids = new Bids();
if (jsonObject == null) {
return bids;
}
bids.url = jsonObject.optString("url");
bids.cacheId = jsonObject.optString("cacheId");
return bids;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data/bid/Cache.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.data.bid;
import org.json.JSONObject;
public class Cache {
private String key;
private String url;
private Bids bids;
protected Cache() {
}
public String getKey() {
return key;
}
public String getUrl() {
return url;
}
public Bids getBids() {
if (bids == null) {
bids = new Bids();
}
return bids;
}
public static Cache fromJSONObject(JSONObject jsonObject) {
Cache cache = new Cache();
if (jsonObject == null) {
return cache;
}
cache.key = jsonObject.optString("key");
cache.url = jsonObject.optString("url");
cache.bids = Bids.fromJSONObject(jsonObject.optJSONObject("bids"));
return cache;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data/bid/Prebid.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.data.bid;
import static org.prebid.mobile.rendering.utils.helpers.Utils.addValue;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.AdSize;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.TargetingParams;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class Prebid {
private Cache cache;
private HashMap<String, String> targeting = new HashMap<>();
private final Map<String, Set<String>> customTargeting = new HashMap<>();
private String type;
private String winEventUrl;
private String impEventUrl;
protected Prebid() {
}
public Cache getCache() {
if (cache == null) {
cache = new Cache();
}
return cache;
}
public HashMap<String, String> getTargeting() {
return targeting;
}
public Map<String, Set<String>> getCustomTargeting() {
return customTargeting;
}
public String getType() {
return type;
}
public static Prebid fromJSONObject(JSONObject jsonObject) {
Prebid prebid = new Prebid();
if (jsonObject == null) {
return prebid;
}
prebid.cache = Cache.fromJSONObject(jsonObject.optJSONObject("cache"));
prebid.type = jsonObject.optString("type");
parseEvents(prebid, jsonObject.optJSONObject("events"));
toHashMap(prebid.targeting, jsonObject.optJSONObject("targeting"));
parseCustomTargeting(prebid.customTargeting, jsonObject.optJSONObject("custom_targeting"));
return prebid;
}
public String getWinEventUrl() {
return winEventUrl;
}
public String getImpEventUrl() {
return impEventUrl;
}
public static JSONObject getJsonObjectForImp(AdUnitConfiguration adUnitConfiguration) {
final JSONObject prebidObject = getPrebidObject(adUnitConfiguration.getConfigId());
if (adUnitConfiguration.isRewarded()) {
Utils.addValue(prebidObject, "is_rewarded_inventory", 1);
}
return prebidObject;
}
public static JSONObject getJsonObjectForApp(
String sdkName,
String sdkVersion
) {
JSONObject prebid = new JSONObject();
Utils.addValue(prebid, "source", sdkName);
Utils.addValue(prebid, "version", sdkVersion);
return prebid;
}
public static JSONObject getJsonObjectForBidRequest(
String accountId,
boolean isVideo,
AdUnitConfiguration config
) {
JSONObject prebid = getPrebidObject(accountId);
JSONObject targeting = new JSONObject();
if (config.isOriginalAdUnit() && config.getAdFormats().size() > 1) {
Utils.addValue(targeting, "includeformat", "true");
}
Utils.addValue(prebid, "targeting", targeting);
if (!TargetingParams.getAccessControlList().isEmpty()) {
JSONObject data = new JSONObject();
Utils.addValue(data, "bidders", new JSONArray(TargetingParams.getAccessControlList()));
Utils.addValue(prebid, "data", data);
}
return prebid;
}
public static JSONObject getJsonObjectForDeviceMinSizePerc(AdSize minSizePercentage) {
JSONObject prebid = new JSONObject();
JSONObject interstitial = new JSONObject();
Utils.addValue(interstitial, "minwidthperc", minSizePercentage.getWidth());
Utils.addValue(interstitial, "minheightperc", minSizePercentage.getHeight());
Utils.addValue(prebid, "interstitial", interstitial);
return prebid;
}
private static void parseEvents(
@NonNull Prebid prebid,
@Nullable JSONObject eventsJson
) {
if (eventsJson == null) return;
try {
prebid.winEventUrl = eventsJson.getString("win");
prebid.impEventUrl = eventsJson.getString("imp");
} catch (JSONException ignored) {}
}
private static JSONObject getPrebidObject(String configId) {
JSONObject prebid = new JSONObject();
StoredRequest storedRequest = new StoredRequest(configId);
addValue(prebid, "storedrequest", storedRequest.toJSONObject());
addStoredAuctionResponse(prebid);
addStoredBidResponse(prebid);
return prebid;
}
private static void addStoredAuctionResponse(JSONObject prebid) {
final String storedAuctionResponse = PrebidMobile.getStoredAuctionResponse();
if (!TextUtils.isEmpty(storedAuctionResponse)) {
JSONObject storedAuctionResponseJson = new JSONObject();
Utils.addValue(storedAuctionResponseJson, "id", storedAuctionResponse);
Utils.addValue(prebid, "storedauctionresponse", storedAuctionResponseJson);
}
}
private static void addStoredBidResponse(JSONObject prebid) {
final Map<String, String> storedBidResponseMap = PrebidMobile.getStoredBidResponses();
if (!storedBidResponseMap.isEmpty()) {
JSONArray bidResponseArray = new JSONArray();
for (Map.Entry<String, String> entry : storedBidResponseMap.entrySet()) {
final String bidder = entry.getKey();
final String bidId = entry.getValue();
if (!TextUtils.isEmpty(bidder) && !TextUtils.isEmpty(bidId)) {
JSONObject storedBid = new JSONObject();
Utils.addValue(storedBid, "bidder", bidder);
Utils.addValue(storedBid, "id", bidId);
}
}
Utils.addValue(prebid, "storedbidresponse", bidResponseArray);
}
}
private static void toHashMap(HashMap<String, String> hashMap, JSONObject jsonObject) {
if (jsonObject == null || hashMap == null) {
return;
}
Iterator<String> jsonIterator = jsonObject.keys();
while (jsonIterator.hasNext()) {
String key = jsonIterator.next();
hashMap.put(key, jsonObject.optString(key));
}
}
private static void parseCustomTargeting(Map<String, Set<String>> map, JSONObject jsonObject) {
if (jsonObject == null || map == null) {
return;
}
Iterator<String> jsonIterator = jsonObject.keys();
while (jsonIterator.hasNext()) {
String key = jsonIterator.next();
Set<String> keywordSet = new HashSet<>();
JSONArray keywords = jsonObject.optJSONArray(key);
if (keywords != null) {
for (int i = 0; i < keywords.length(); i++) {
String keyword = keywords.optString(i);
if (!TextUtils.isEmpty(keyword)) {
keywordSet.add(keyword);
}
}
}
map.put(key, keywordSet);
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data/bid/Seatbid.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.data.bid;
import org.json.JSONArray;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext;
import java.util.ArrayList;
import java.util.List;
public class Seatbid {
// Array of 1+ Bid objects each related to an impression.
private List<Bid> bids = new ArrayList<>();
// ID of the buyer seat (e.g., advertiser, agency) on whose behalf
// this bid is made
private String seat;
// 0 = impressions can be won individually; 1 = impressions must
// be won or lost as a group.
private int group;
// Placeholder for bidder-specific extensions to OpenRTB.
private Ext ext;
protected Seatbid() {
}
public List<Bid> getBids() {
return bids;
}
public String getSeat() {
return seat;
}
public int getGroup() {
return group;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
public static Seatbid fromJSONObject(JSONObject jsonObject, String cur, String requestId) {
Seatbid seatbid = new Seatbid();
if (jsonObject == null) {
return seatbid;
}
if (jsonObject.has("bid")) {
JSONArray jsonArray = jsonObject.optJSONArray("bid");
for (int i = 0; i < jsonArray.length(); i++) {
Bid bid = Bid.fromJSONObject(jsonArray.optJSONObject(i), cur);
if (bid != null) {
bid.setRequestId(requestId);
seatbid.bids.add(bid);
}
}
}
seatbid.seat = jsonObject.optString("seat");
seatbid.group = jsonObject.optInt("group", -1);
seatbid.ext = new Ext();
if (jsonObject.has("ext")) {
seatbid.ext.put(jsonObject.optJSONObject("ext"));
}
return seatbid;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/data/bid/StoredRequest.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.data.bid;
import org.json.JSONException;
import org.json.JSONObject;
public class StoredRequest {
private String id;
public StoredRequest(String id) {
this.id = id;
}
public JSONObject toJSONObject() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("id", id);
}
catch (JSONException e) {
e.printStackTrace();
}
return jsonObject;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/display/BidResponseCache.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.display;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Holds BidResponses in memory until they are used
*/
public class BidResponseCache {
private static final String TAG = BidResponseCache.class.getSimpleName();
/**
* Maximum number of responses that are cached. This limit is intended to be very
* conservative; it is not recommended to cache more than a few BidResponses.
*/
@VisibleForTesting
static final int MAX_SIZE = 20;
private static final long BID_RESPONSE_LIFE_TIME_IN_CACHE = 60 * 1000;//1 minute
@NonNull
private static Map<String, BidResponse> sCachedBidResponses =
Collections.synchronizedMap(new HashMap<>());
private static BidResponseCache sInstance;
private BidResponseCache() {
}
public static synchronized BidResponseCache getInstance() {
if (sInstance == null) {
sInstance = new BidResponseCache();
}
return sInstance;
}
/**
* Stores the { BidResponse} in the cache. This BidResponse will live until it is retrieved via
* { #popBidResponse(String)}
*
* @param response Parsed bid response
*/
public void putBidResponse(
final BidResponse response) {
putBidResponse(response.getId(), response);
}
/**
* Stores the { BidResponse} in the cache. This BidResponse will live until it is retrieved via
* { #popBidResponse(String)}
*
* @param key Custom key to store response
* @param response Parsed bid response
*/
public void putBidResponse(
String key,
BidResponse response
) {
trimCache();
// Ignore request when max size is reached.
if (sCachedBidResponses.size() >= MAX_SIZE) {
LogUtil.error(
TAG,
"Unable to cache BidResponse. Please destroy some via #destroy() and try again."
);
return;
}
if (TextUtils.isEmpty(key)) {
LogUtil.error(
TAG,
"Unable to cache BidResponse. Key is empty or null."
);
return;
}
sCachedBidResponses.put(key, response);
LogUtil.debug(TAG, "Cached ad count after storing: " + getCachedResponsesCount());
}
@Nullable
public BidResponse popBidResponse(
@Nullable
final String responseId) {
LogUtil.debug(TAG, "POPPING the response");
BidResponse bidResponse = null;
if (sCachedBidResponses.containsKey(responseId)) {
//check if the available BidResponse is not stale
bidResponse = sCachedBidResponses.remove(responseId);
} else {
LogUtil.warning(TAG, "No cached ad to retrieve in the final map");
}
LogUtil.debug(TAG, "Cached ad count after popping: " + getCachedResponsesCount());
return bidResponse;
}
@Nullable
public HashMap<String, String> getKeywords(String responseId) {
if (sCachedBidResponses.containsKey(responseId)) {
BidResponse bidResponse = sCachedBidResponses.get(responseId);
if (bidResponse != null) {
return bidResponse.getTargeting();
}
}
return null;
}
@VisibleForTesting
static synchronized void trimCache() {
final Iterator<Map.Entry<String, BidResponse>> iterator = sCachedBidResponses.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<String, BidResponse> entry = iterator.next();
// If the response was removed from memory,
// discard the entire associated Config.
if (entry.getValue() == null) {
iterator.remove();
}
}
if (!sCachedBidResponses.isEmpty()) {
removeStaleBidResponses(sCachedBidResponses);
}
}
private static void removeStaleBidResponses(Map<String, BidResponse> bidResponseMap) {
final Iterator<Map.Entry<String, BidResponse>> iterator = bidResponseMap.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<String, BidResponse> entry = iterator.next();
// If the response was removed from memory,
// discard the entire associated Config.
if (entry.getValue() != null) {
long saveTimeInMillis = entry.getValue().getCreationTime();
// Checking if the current time is past the expiration time
if (System.currentTimeMillis() > (saveTimeInMillis + BID_RESPONSE_LIFE_TIME_IN_CACHE)) {
iterator.remove();
}
}
}
}
private static int getCachedResponsesCount() {
return sCachedBidResponses.size();
}
@VisibleForTesting
static void clearAll() {
sCachedBidResponses.clear();
}
@VisibleForTesting
static Map<String, BidResponse> getCachedBidResponses() {
return sCachedBidResponses;
}
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/display/InterstitialController.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.display;
import android.content.Context;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.api.rendering.InterstitialView;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
import org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener;
import org.prebid.mobile.rendering.bidding.interfaces.InterstitialViewListener;
import org.prebid.mobile.rendering.models.AdDetails;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.MobileSdkPassThrough;
import org.prebid.mobile.rendering.networking.WinNotifier;
public class InterstitialController {
private static final String TAG = InterstitialController.class.getSimpleName();
private String impressionEventUrl;
private final InterstitialView bidInterstitialView;
private final InterstitialControllerListener listener;
private AdFormat adUnitIdentifierType;
private final InterstitialViewListener interstitialViewListener = new InterstitialViewListener() {
@Override
public void onAdLoaded(
InterstitialView interstitialView,
AdDetails adDetails
) {
LogUtil.debug(TAG, "onAdLoaded");
if (listener != null) {
listener.onInterstitialReadyForDisplay();
}
}
@Override
public void onAdFailed(
InterstitialView interstitialView,
AdException error
) {
LogUtil.debug(TAG, "onAdFailed");
if (listener != null) {
listener.onInterstitialFailedToLoad(error);
}
}
@Override
public void onAdDisplayed(InterstitialView interstitialView) {
LogUtil.debug(TAG, "onAdDisplayed");
if (listener != null) {
listener.onInterstitialDisplayed();
}
}
@Override
public void onAdCompleted(InterstitialView interstitialView) {
}
@Override
public void onAdClicked(InterstitialView interstitialView) {
LogUtil.debug(TAG, "onAdClicked");
if (listener != null) {
listener.onInterstitialClicked();
}
}
@Override
public void onAdClickThroughClosed(InterstitialView interstitialView) {
}
@Override
public void onAdClosed(InterstitialView interstitialView) {
LogUtil.debug(TAG, "onAdClosed");
if (listener != null) {
listener.onInterstitialClosed();
}
}
};
public InterstitialController(Context context, InterstitialControllerListener listener)
throws AdException {
this.listener = listener;
bidInterstitialView = new InterstitialView(context);
bidInterstitialView.setInterstitialViewListener(interstitialViewListener);
bidInterstitialView.setPubBackGroundOpacity(1.0f);
}
public void loadAd(AdUnitConfiguration adUnitConfiguration, BidResponse bidResponse) {
adUnitConfiguration.modifyUsingBidResponse(bidResponse);
setRenderingControlSettings(adUnitConfiguration, bidResponse);
WinNotifier winNotifier = new WinNotifier();
winNotifier.notifyWin(bidResponse, () -> {
impressionEventUrl = bidResponse.getImpressionEventUrl();
adUnitIdentifierType = bidResponse.isVideo() ? AdFormat.VAST : AdFormat.INTERSTITIAL;
adUnitConfiguration.setAdFormat(adUnitIdentifierType);
bidInterstitialView.loadAd(adUnitConfiguration, bidResponse);
});
}
public void loadAd(String responseId, boolean isRewarded) {
BidResponse bidResponse = BidResponseCache.getInstance().popBidResponse(responseId);
if (bidResponse == null) {
if (listener != null) {
listener.onInterstitialFailedToLoad(new AdException(
AdException.INTERNAL_ERROR,
"No bid response found in the cache"
));
}
return;
}
AdUnitConfiguration adUnitConfiguration = new AdUnitConfiguration();
adUnitConfiguration.setRewarded(isRewarded);
loadAd(adUnitConfiguration, bidResponse);
}
public void show() {
if (adUnitIdentifierType == null) {
LogUtil.error(TAG, "show: Failed. AdUnitIdentifierType is not defined!");
return;
}
switch (adUnitIdentifierType) {
case INTERSTITIAL:
bidInterstitialView.showAsInterstitialFromRoot();
break;
case VAST:
bidInterstitialView.showVideoAsInterstitial();
break;
default:
LogUtil.error(TAG, "show: Failed. Did you specify correct AdUnitConfigurationType? "
+ "Supported types: VAST, INTERSTITIAL. "
+ "Provided type: " + adUnitIdentifierType
);
}
}
public void destroy() {
bidInterstitialView.destroy();
}
public InterstitialView getBidInterstitialView() {
return bidInterstitialView;
}
private void setRenderingControlSettings(
AdUnitConfiguration adUnitConfiguration,
BidResponse bidResponse
) {
MobileSdkPassThrough renderingControlSettings = bidResponse.getMobileSdkPassThrough();
if (renderingControlSettings != null) {
renderingControlSettings.modifyAdUnitConfiguration(adUnitConfiguration);
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/display/PrebidMediationDelegate.java | package org.prebid.mobile.rendering.bidding.display;
import androidx.annotation.Nullable;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
import java.util.HashMap;
/**
* PrebidMediationDelegate is a delegate of custom mediation platform.
*/
public interface PrebidMediationDelegate {
/**
* Sets keywords into a given mediation ad object
*/
public void handleKeywordsUpdate(@Nullable HashMap<String, String> keywords);
/**
* Sets response into a given mediation ad object
*/
public void setResponseToLocalExtras(@Nullable BidResponse response);
/**
* Checks if banner view is visible, and it is possible to make refresh.
*/
public boolean canPerformRefresh();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/events/EventsNotifier.java | package org.prebid.mobile.rendering.bidding.events;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.bidding.data.bid.Bid;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
import org.prebid.mobile.rendering.bidding.data.bid.Prebid;
import org.prebid.mobile.rendering.networking.tracking.ServerConnection;
/**
* Class for sending events from bids (seatbid.bid.ext.prebid.events.*)
*/
public class EventsNotifier {
private static final String TAG = EventsNotifier.class.getSimpleName();
public static void notify(@Nullable String url) {
if (url != null) {
LogUtil.verbose(TAG, "Notify event: " + url);
ServerConnection.fireAndForget(url);
}
}
/**
* Parses events in bid.
*
* @param bidJson - bid field from seatbid.bid
*/
@Nullable
public static String parseEvent(
@NonNull String eventKey,
@Nullable JSONObject bidJson
) {
if (bidJson == null) return null;
JSONObject extJson = bidJson.optJSONObject("ext");
if (extJson != null) {
JSONObject prebidJson = extJson.optJSONObject("prebid");
if (prebidJson != null) {
JSONObject eventsJson = prebidJson.optJSONObject("events");
if (eventsJson != null) {
String result = eventsJson.optString(eventKey, "");
if (!result.isEmpty()) {
return result;
}
}
}
}
return null;
}
@Nullable
private static String getImpressionEventUrl(@Nullable BidResponse bidResponse) {
if (bidResponse == null) return null;
Bid winningBid = bidResponse.getWinningBid();
if (winningBid != null) {
Prebid prebid = winningBid.getPrebid();
return prebid.getImpEventUrl();
}
return null;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/interfaces/BannerEventHandler.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.interfaces;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.prebid.mobile.AdSize;
import org.prebid.mobile.rendering.bidding.data.bid.Bid;
import org.prebid.mobile.rendering.bidding.listeners.BannerEventListener;
public interface BannerEventHandler {
AdSize[] getAdSizeArray();
void setBannerEventListener(@NonNull
BannerEventListener bannerViewListener);
void requestAdWithBid(@Nullable Bid bid);
void trackImpression();
void destroy();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/interfaces/InterstitialControllerListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.interfaces;
import org.prebid.mobile.api.exceptions.AdException;
public interface InterstitialControllerListener {
void onInterstitialReadyForDisplay();
void onInterstitialClicked();
void onInterstitialFailedToLoad(AdException exception);
void onInterstitialDisplayed();
void onInterstitialClosed();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/interfaces/InterstitialEventHandler.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.interfaces;
import androidx.annotation.Nullable;
import org.prebid.mobile.rendering.bidding.data.bid.Bid;
import org.prebid.mobile.rendering.bidding.listeners.InterstitialEventListener;
public interface InterstitialEventHandler {
void setInterstitialEventListener(InterstitialEventListener interstitialEventListener);
void requestAdWithBid(@Nullable Bid bid);
void show();
void trackImpression();
void destroy();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/interfaces/InterstitialViewListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.interfaces;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.api.rendering.InterstitialView;
import org.prebid.mobile.rendering.models.AdDetails;
public interface InterstitialViewListener {
/**
* This is triggered whenever the AD is rendered on the screen.
*/
void onAdLoaded(InterstitialView interstitialView, AdDetails adDetails);
/**
* When AdModel fails to load for whatever reason
*
* @param error The AdException received when trying to load the Ad
*/
void onAdFailed(InterstitialView interstitialView, AdException error);
/**
* When a loaded ad is displayed
*/
void onAdDisplayed(InterstitialView interstitialView);
/**
* When an ad has finished refreshing.
*/
void onAdCompleted(InterstitialView interstitialView);
/**
* When an ad was clicked
*/
void onAdClicked(InterstitialView interstitialView);
/**
* When an expanded banner ad was closed
*/
void onAdClickThroughClosed(InterstitialView interstitialView);
void onAdClosed(InterstitialView interstitialView);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/interfaces/RewardedEventHandler.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.interfaces;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.prebid.mobile.rendering.bidding.data.bid.Bid;
import org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener;
public interface RewardedEventHandler {
void setRewardedEventListener(
@NonNull
RewardedVideoEventListener listener);
void requestAdWithBid(@Nullable
Bid bid);
void show();
void trackImpression();
void destroy();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/interfaces/StandaloneBannerEventHandler.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.interfaces;
import org.prebid.mobile.AdSize;
import org.prebid.mobile.rendering.bidding.data.bid.Bid;
import org.prebid.mobile.rendering.bidding.listeners.BannerEventListener;
public class StandaloneBannerEventHandler implements BannerEventHandler {
private BannerEventListener bannerViewListener;
@Override
public AdSize[] getAdSizeArray() {
return new AdSize[0];
}
@Override
public void setBannerEventListener(BannerEventListener bannerViewListener) {
this.bannerViewListener = bannerViewListener;
}
@Override
public void requestAdWithBid(Bid bid) {
bannerViewListener.onPrebidSdkWin();
}
@Override
public void trackImpression() {
}
@Override
public void destroy() {
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/interfaces/StandaloneInterstitialEventHandler.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.interfaces;
import androidx.annotation.Nullable;
import org.prebid.mobile.rendering.bidding.data.bid.Bid;
import org.prebid.mobile.rendering.bidding.listeners.InterstitialEventListener;
public class StandaloneInterstitialEventHandler implements InterstitialEventHandler {
private InterstitialEventListener interstitialEventListener;
@Override
public void setInterstitialEventListener(InterstitialEventListener interstitialEventListener) {
this.interstitialEventListener = interstitialEventListener;
}
@Override
public void requestAdWithBid(
@Nullable Bid bid
) {
interstitialEventListener.onPrebidSdkWin();
}
@Override
public void show() {
}
@Override
public void trackImpression() {
}
@Override
public void destroy() {
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/interfaces/StandaloneRewardedVideoEventHandler.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.interfaces;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.prebid.mobile.rendering.bidding.data.bid.Bid;
import org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener;
public class StandaloneRewardedVideoEventHandler implements RewardedEventHandler {
private RewardedVideoEventListener listener;
@Override
public void setRewardedEventListener(
@NonNull
RewardedVideoEventListener listener) {
this.listener = listener;
}
@Override
public void requestAdWithBid(
@Nullable
Bid bid) {
listener.onPrebidSdkWin();
}
@Override
public void show() {
}
@Override
public void trackImpression() {
}
@Override
public void destroy() {
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/listeners/BannerEventListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.listeners;
import android.view.View;
import org.prebid.mobile.api.exceptions.AdException;
public interface BannerEventListener {
void onPrebidSdkWin();
void onAdServerWin(View view);
void onAdFailed(AdException exception);
void onAdClicked();
void onAdClosed();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/listeners/BidRequesterListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.listeners;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
public interface BidRequesterListener {
void onFetchCompleted(BidResponse response);
void onError(AdException exception);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/listeners/DisplayViewListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.listeners;
import org.prebid.mobile.api.exceptions.AdException;
public interface DisplayViewListener {
// Called every time an ad had loaded and is ready for display
void onAdLoaded();
// Called every time the ad is displayed on the screen
void onAdDisplayed();
// Called whenever the load process fails to produce a viable ad
void onAdFailed(AdException exception);
// Called when the banner view will launch a dialog on top of the current view
void onAdClicked();
// Called when the banner view has dismissed the modal on top of the current view
void onAdClosed();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/listeners/InterstitialEventListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.listeners;
import org.prebid.mobile.api.exceptions.AdException;
public interface InterstitialEventListener {
void onPrebidSdkWin();
void onAdServerWin();
void onAdFailed(AdException exception);
void onAdClosed();
void onAdDisplayed();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/listeners/RewardedVideoEventListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.listeners;
import org.prebid.mobile.api.exceptions.AdException;
public interface RewardedVideoEventListener {
void onPrebidSdkWin();
void onAdServerWin(Object userReward);
void onAdFailed(AdException exception);
void onAdClicked();
void onAdClosed();
void onAdDisplayed();
void onUserEarnedReward();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/bidding/loader/BidLoader.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.bidding.loader;
import android.content.Context;
import androidx.annotation.NonNull;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
import org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.MobileSdkPassThrough;
import org.prebid.mobile.rendering.networking.BaseNetworkTask;
import org.prebid.mobile.rendering.networking.ResponseHandler;
import org.prebid.mobile.rendering.networking.modelcontrollers.BidRequester;
import org.prebid.mobile.rendering.networking.parameters.AdRequestInput;
import org.prebid.mobile.rendering.utils.helpers.RefreshTimerTask;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import static java.lang.Math.max;
public class BidLoader {
private final static String TAG = BidLoader.class.getSimpleName();
private final static String TMAX_REQUEST_KEY = "tmaxrequest";
private static boolean sTimeoutHasChanged = false;
private WeakReference<Context> contextReference;
private AdUnitConfiguration adConfiguration;
private BidRequester bidRequester;
private AtomicBoolean currentlyLoading;
private BidRequesterListener requestListener;
private BidRefreshListener bidRefreshListener;
private final ResponseHandler responseHandler = new ResponseHandler() {
@Override
public void onResponse(BaseNetworkTask.GetUrlResult response) {
currentlyLoading.set(false);
BidResponse bidResponse = new BidResponse(response.responseString, adConfiguration);
if (bidResponse.hasParseError()) {
failedToLoadBid(bidResponse.getParseError());
return;
}
checkTmax(response, bidResponse);
updateAdUnitConfiguration(bidResponse);
if (requestListener != null) {
setupRefreshTimer();
requestListener.onFetchCompleted(bidResponse);
} else {
cancelRefresh();
}
}
@Override
public void onError(
String msg,
long responseTime
) {
failedToLoadBid(msg);
}
@Override
public void onErrorWithException(
Exception e,
long responseTime
) {
failedToLoadBid(e.getMessage());
}
};
private final RefreshTimerTask refreshTimerTask = new RefreshTimerTask(() -> {
if (adConfiguration == null) {
LogUtil.error(TAG, "handleRefresh(): Failure. AdConfiguration is null");
return;
}
if (bidRefreshListener == null) {
LogUtil.error(TAG, "RefreshListener is null. No refresh or load will be performed.");
return;
}
if (!bidRefreshListener.canPerformRefresh()) {
LogUtil.debug(TAG, "handleRefresh(): Loading skipped, rescheduling timer. View is not visible.");
setupRefreshTimer();
return;
}
LogUtil.debug(TAG, "refresh triggered: load() being called ");
load();
});
public BidLoader(Context context, AdUnitConfiguration adConfiguration, BidRequesterListener requestListener) {
contextReference = new WeakReference<>(context);
this.adConfiguration = adConfiguration;
this.requestListener = requestListener;
currentlyLoading = new AtomicBoolean();
}
public void setBidRefreshListener(BidRefreshListener bidRefreshListener) {
this.bidRefreshListener = bidRefreshListener;
}
public void load() {
if (requestListener == null) {
LogUtil.warning(TAG, "Listener is null");
return;
}
if (adConfiguration == null) {
LogUtil.warning(TAG, "No ad request configuration to load");
return;
}
if (contextReference.get() == null) {
LogUtil.warning(TAG, "Context is null");
return;
}
// If currentlyLoading == false, set it to true and return true; else return false
// If compareAndSet returns false, it means currentlyLoading was already true and therefore we should skip loading
if (!currentlyLoading.compareAndSet(false, true)) {
LogUtil.warning(TAG, "Previous load is in progress. Load() ignored.");
return;
}
sendBidRequest(contextReference.get(), adConfiguration);
}
public void setupRefreshTimer() {
LogUtil.debug(TAG, "Schedule refresh timer");
boolean isRefreshAvailable = adConfiguration != null && adConfiguration.isAdType(AdFormat.BANNER);
if (!isRefreshAvailable) {
LogUtil.debug(TAG, "setupRefreshTimer: Canceled. AdConfiguration is null or AdType is not Banner");
return;
}
int refreshTimeMillis = adConfiguration.getAutoRefreshDelay();
//for user or server values <= 0, no refreshtask should be created.
//for such invalid values, refreshTimeMillis has been set to Integer.MAX_VALUE already.
//So, check it against it to stop it from creating a refreshtask
if (refreshTimeMillis == Integer.MAX_VALUE || refreshTimeMillis <= 0) {
LogUtil.debug(TAG, "setupRefreshTimer(): refreshTimeMillis is: "
+ refreshTimeMillis + ". Skipping refresh timer initialization");
return;
}
int reloadTime = max(refreshTimeMillis, 1000);
refreshTimerTask.scheduleRefreshTask(reloadTime);
}
public void cancelRefresh() {
LogUtil.debug(TAG, "Cancel refresh timer");
refreshTimerTask.cancelRefreshTimer();
}
public void destroy() {
cancelRefresh();
refreshTimerTask.destroy();
if (bidRequester != null) {
bidRequester.destroy();
}
requestListener = null;
bidRefreshListener = null;
}
private void sendBidRequest(Context context, AdUnitConfiguration config) {
currentlyLoading.set(true);
if (bidRequester == null) {
bidRequester = new BidRequester(context, config, new AdRequestInput(), responseHandler);
}
bidRequester.startAdRequest();
}
private void failedToLoadBid(String msg) {
LogUtil.error(TAG, "Invalid bid response: " + msg);
currentlyLoading.set(false);
if (requestListener == null) {
LogUtil.warning(TAG, "onFailedToLoad: Listener is null.");
cancelRefresh();
return;
}
setupRefreshTimer();
requestListener.onError(new AdException(AdException.INTERNAL_ERROR, "Invalid bid response: " + msg));
}
private void checkTmax(
BaseNetworkTask.GetUrlResult response,
BidResponse parsedResponse
) {
Map<String, Object> extMap = parsedResponse.getExt().getMap();
if (!sTimeoutHasChanged && extMap.containsKey(TMAX_REQUEST_KEY)) {
int tmaxRequest = (int) extMap.get(TMAX_REQUEST_KEY);
// adding 200ms as safe time
int timeout = (int) Math.min(response.responseTime + tmaxRequest + 200, BaseNetworkTask.TIMEOUT_DEFAULT);
PrebidMobile.setTimeoutMillis(timeout);
sTimeoutHasChanged = true;
}
}
/**
* Gets mobile sdk pass through object, combines it with user's ad unit
* rendering controls settings in configuration, modifies ad unit
* configuration, sets combined parameters to bid response.
*/
private void updateAdUnitConfiguration(@NonNull BidResponse bidResponse) {
MobileSdkPassThrough serverParameters = bidResponse.getMobileSdkPassThrough();
MobileSdkPassThrough combinedParameters = MobileSdkPassThrough.combine(serverParameters, adConfiguration);
combinedParameters.modifyAdUnitConfiguration(adConfiguration);
bidResponse.setMobileSdkPassThrough(combinedParameters);
}
public interface BidRefreshListener {
boolean canPerformRefresh();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/errors/ServerWrongStatusCode.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.errors;
import org.prebid.mobile.api.exceptions.AdException;
/**
* Error will be thrown when server has responded with error status code.
*/
public class ServerWrongStatusCode extends AdException {
public ServerWrongStatusCode(int code) {
super(SERVER_ERROR, "Server returned " + code + " status code");
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/errors/VastParseError.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.errors;
import org.prebid.mobile.api.exceptions.AdException;
/**
* Error will be thrown when unknown problem has appeared.
*/
public class VastParseError extends AdException {
public VastParseError(String err) {
super(INTERNAL_ERROR, "Failed to parse VAST. " + err);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/AdBaseDialog.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.ActivityInfo;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.core.R;
import org.prebid.mobile.rendering.models.InterstitialDisplayPropertiesInternal;
import org.prebid.mobile.rendering.models.internal.MraidVariableContainer;
import org.prebid.mobile.rendering.mraid.handler.FetchPropertiesHandler;
import org.prebid.mobile.rendering.mraid.methods.others.OrientationManager;
import org.prebid.mobile.rendering.sdk.ManagersResolver;
import org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager;
import org.prebid.mobile.rendering.utils.broadcast.OrientationBroadcastReceiver;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import org.prebid.mobile.rendering.views.interstitial.InterstitialVideo;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
import org.prebid.mobile.rendering.views.webview.mraid.JsExecutor;
import org.prebid.mobile.rendering.views.webview.mraid.Views;
import java.lang.ref.WeakReference;
//Class to show ad as an interstitial i.e, a fullscreen ad
public abstract class AdBaseDialog extends Dialog {
private static final String TAG = AdBaseDialog.class.getSimpleName();
private final WeakReference<Context> contextReference;
private final OrientationBroadcastReceiver orientationBroadcastReceiver = new OrientationBroadcastReceiver();
protected JsExecutor jsExecutor;
protected InterstitialManager interstitialManager;
protected WebViewBase webViewBase;
protected FrameLayout adViewContainer;
protected View displayView;
protected View soundView;
protected View skipView;
private View closeView;
// IMP: shud be always none. cos this val is used when expand is called with an url.
protected OrientationManager.ForcedOrientation forceOrientation = OrientationManager.ForcedOrientation.none;
@Nullable private Integer originalActivityOrientation;
/**
* Is used when deciding to handle orientation changes. Orientation changes allowed (true) by default.
*/
protected boolean allowOrientationChange = true;
protected boolean hasExpandProperties;
protected int initialOrientation;
private int screenVisibility;
private int closeViewVisibility = View.GONE;
private final FetchPropertiesHandler.FetchPropertyCallback expandPropertiesCallback = new FetchPropertiesHandler.FetchPropertyCallback() {
@Override
public void onResult(String propertyJson) {
handleExpandPropertiesResult(propertyJson);
}
@Override
public void onError(Throwable throwable) {
LogUtil.error(TAG, "ExpandProperties failed: " + Log.getStackTraceString(throwable));
}
};
private DialogEventListener listener;
public AdBaseDialog(
Context context,
InterstitialManager interstitialManager
) {
super(context, R.style.FullScreenDialogTheme);
contextReference = new WeakReference<>(context);
this.interstitialManager = interstitialManager;
setOnShowListener(new OnDialogShowListener(this));
}
public AdBaseDialog(
Context context,
WebViewBase webViewBaseLocal,
InterstitialManager interstitialManager
) {
super(context, R.style.FullScreenDialogTheme);
contextReference = new WeakReference<>(context);
webViewBase = webViewBaseLocal;
this.interstitialManager = interstitialManager;
jsExecutor = webViewBaseLocal.getMRAIDInterface().getJsExecutor();
setOnShowListener(new OnDialogShowListener(this));
setOnKeyListener((dialog, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (webViewBase.isMRAID()) {
handleCloseClick();
}
return true;
}
return false;
});
}
public void setDialogListener(DialogEventListener listener) {
this.listener = listener;
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
int visibility = (!hasWindowFocus ? View.INVISIBLE : View.VISIBLE);
if (Utils.hasScreenVisibilityChanged(screenVisibility, visibility)) {
//visibility has changed. Send the changed value for mraid update for interstitials
screenVisibility = visibility;
if (jsExecutor != null) {
jsExecutor.executeOnViewableChange(Utils.isScreenVisible(screenVisibility));
}
}
}
@Override
public void cancel() {
super.cancel();
if (listener != null) {
listener.onEvent(DialogEventListener.EventType.CLOSED);
}
}
@VisibleForTesting
void setCloseView(View closeView) {
this.closeView = closeView;
}
public View getDisplayView() {
return displayView;
}
public void setDisplayView(View displayView) {
this.displayView = displayView;
}
/**
* Changes {@link #closeView} visibility. if {@link #closeView} is not defined - visibility is remembered
* and applied when closeView is added to container
*/
public void changeCloseViewVisibility(int visibility) {
if (closeView != null) {
closeView.setVisibility(visibility);
return;
}
closeViewVisibility = visibility;
}
public void handleSetOrientationProperties() throws AdException {
initOrientationProperties();
applyOrientation();
if (webViewBase.isMRAID()) {
webViewBase.getMRAIDInterface().updateScreenMetricsAsync(null);
}
}
public void cleanup() {
try {
orientationBroadcastReceiver.unregister();
}
catch (IllegalArgumentException e) {
LogUtil.error(TAG, Log.getStackTraceString(e));
}
cancel();
}
/**
* Is executed when the close button is clicked. It is child job to handle the click
*/
protected abstract void handleCloseClick();
protected abstract void handleDialogShow();
protected void preInit() {
Activity activity = getActivity();
if (activity != null) {
initialOrientation = getActivity().getRequestedOrientation();
}
RelativeLayout.LayoutParams params =
new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
webViewBase.setLayoutParams(params);
if (webViewBase.isMRAID()) {
MraidContinue();
} else {
init();
}
//Remove the current parent of webViewBase(that's a default container, in all cases)
//java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.??
Views.removeFromParent(webViewBase);
if (adViewContainer == null) {
adViewContainer = new FrameLayout(getContext());
adViewContainer.setLayoutParams(new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
));
}
adViewContainer.addView(webViewBase, adViewContainer.getChildCount());
}
protected void init() {
if (webViewBase.isMRAID()) {
try {
applyOrientation();
} catch (AdException e) {
LogUtil.error(TAG, Log.getStackTraceString(e));
}
//Register orientation change listener for MRAID ads only
if (contextReference.get() != null) {
orientationBroadcastReceiver.register(contextReference.get());
}
}
webViewBase.setVisibility(View.VISIBLE);
// render default close btn
//good only if it is from expanded ad. Interstitial crash with null displayproperties. check.
changeCloseViewVisibility(View.VISIBLE);
webViewBase.requestLayout();
if (jsExecutor != null) {
jsExecutor.executeOnViewableChange(true);
}
}
protected void MraidContinue() {
if (!hasExpandProperties) {
//1st always false. so this always happens 1st.
loadExpandProperties();
} else {
init();
}
}
@VisibleForTesting
void loadExpandProperties() {
/*
* If it's MRAID, we have to check the Ad designer's request to launch
* the ad in a particular expanded size by checking the ad's
* ExpandProperties per the MRAID spec. So we go to the js and extract these
* properties and then the layout gets built based on these things.
*/
if (jsExecutor != null) {
jsExecutor.executeGetExpandProperties(new FetchPropertiesHandler(expandPropertiesCallback));
}
}
protected void lockOrientation() {
Activity activity = getActivity();
if (activity == null) {
LogUtil.error(TAG, "lockOrientation failure. Activity is null");
return;
}
Display getOrient = activity.getWindowManager().getDefaultDisplay();
if (getOrient.getWidth() <= getOrient.getHeight()) {
lockOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
}
else {
lockOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
}
protected void lockOrientation(final int screenOrientation) {
Activity activity = getActivity();
if (activity == null) {
LogUtil.error(TAG, "lockOrientation failure. Activity is null");
return;
}
if (originalActivityOrientation == null) {
originalActivityOrientation = activity.getRequestedOrientation();
}
activity.setRequestedOrientation(screenOrientation);
}
protected void unApplyOrientation() {
if (getActivity() != null && originalActivityOrientation != null) {
getActivity().setRequestedOrientation(originalActivityOrientation);
}
originalActivityOrientation = null;
}
protected Activity getActivity() {
try {
return (Activity) contextReference.get();
}
catch (Exception e) {
LogUtil.error(TAG, "Context is not an activity");
return null;
}
}
protected void addCloseView() {
if (adViewContainer == null || interstitialManager == null) {
LogUtil.error(TAG, "Unable to add close button. Container is null");
return;
}
InterstitialDisplayPropertiesInternal properties = interstitialManager.getInterstitialDisplayProperties();
closeView = Utils.createCloseView(contextReference.get(), properties);
if (closeView == null) {
LogUtil.error(TAG, "Unable to add close button. Close view is null");
return;
}
closeView.setVisibility(closeViewVisibility);
Views.removeFromParent(closeView);
adViewContainer.addView(closeView);
closeView.setOnClickListener(v -> handleCloseClick());
}
protected void addSkipView() {
if (adViewContainer == null) {
LogUtil.error(TAG, "Unable to add close button. Container is null");
return;
}
InterstitialDisplayPropertiesInternal properties = interstitialManager.getInterstitialDisplayProperties();
skipView = Utils.createSkipView(contextReference.get(), properties);
if (skipView == null) {
LogUtil.error(TAG, "Unable to add skip button. Skip view is null");
return;
}
skipView.setVisibility(View.GONE);
Views.removeFromParent(skipView);
adViewContainer.addView(skipView);
skipView.setOnClickListener(v -> handleCloseClick());
}
protected void addSoundView(boolean isMutedOnStart) {
if (adViewContainer == null) {
LogUtil.error(TAG, "Unable to add sound button. Container is null");
return;
}
soundView = createSoundView(contextReference.get());
if (soundView == null || !(soundView instanceof ImageView)) {
LogUtil.error(TAG, "Unable to add sound button. Sound view is null");
return;
}
soundView.setVisibility(View.VISIBLE);
if (isMutedOnStart) {
ImageView img = (ImageView) soundView;
img.setImageResource(R.drawable.ic_volume_on);
img.setTag("on");
}
Views.removeFromParent(soundView);
adViewContainer.addView(soundView);
soundView.setOnClickListener(view -> {
if (listener != null) {
ImageView img = (ImageView) view;
String tag = (String) img.getTag();
if (tag.equals("off")) {
listener.onEvent(DialogEventListener.EventType.MUTE);
img.setImageResource(R.drawable.ic_volume_on);
img.setTag("on");
} else {
listener.onEvent(DialogEventListener.EventType.UNMUTE);
img.setImageResource(R.drawable.ic_volume_off);
img.setTag("off");
}
}
});
}
protected View createSoundView(Context context) {
return Utils.createSoundView(context);
}
private void applyOrientation() throws AdException {
DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
if (forceOrientation == OrientationManager.ForcedOrientation.none) {
if (allowOrientationChange) {
// If screen orientation can be changed, an orientation of NONE means that any
// orientation lock should be removed
unApplyOrientation();
} else {
if (getActivity() == null) {
throw new AdException(
AdException.INTERNAL_ERROR,
"Unable to set MRAID expand orientation to " + "'none'; expected passed in Activity Context."
);
}
// If screen orientation cannot be changed and we can obtain the current
// screen orientation, locking it to the current orientation is a best effort
int orientation = deviceManager.getDeviceOrientation();
lockOrientation(orientation);
}
}
else {
// Otherwise, we have a valid, non-NONE orientation. Lock the screen based on this value
lockOrientation(forceOrientation.getActivityInfoOrientation());
}
}
private void handleExpandPropertiesResult(String expandProperties) {
if (webViewBase == null || webViewBase.getMRAIDInterface() == null) {
LogUtil.debug(TAG, "handleExpandPropertiesResult: WebViewBase or MraidInterface is null. Skipping.");
return;
}
final MraidVariableContainer mraidVariableContainer = webViewBase.getMRAIDInterface()
.getMraidVariableContainer();
mraidVariableContainer.setExpandProperties(expandProperties);
// Fill interstitial manager with expand properties.
displayView = webViewBase;
hasExpandProperties = true;
MraidContinue();
}
private void initOrientationProperties() {
final MraidVariableContainer mraidVariableContainer = webViewBase.getMRAIDInterface()
.getMraidVariableContainer();
JSONObject orientationProperties;
//IMP : must be true by default cos this is used if expand(url) is called as at line#if (!webViewBase.getMRAIDInterface().isLaunchWithURL()) check
boolean allowOrientationChange = true;
String forceOrientation = "none";
try {
orientationProperties = new JSONObject(mraidVariableContainer.getOrientationProperties());
allowOrientationChange = orientationProperties.optBoolean("allowOrientationChange", true);
forceOrientation = orientationProperties.optString("forceOrientation", "none");
}
catch (Exception e) {
LogUtil.error(TAG, "Failed to get the orientation details from JSON for MRAID: " + Log.getStackTraceString(e));
}
if (!mraidVariableContainer.isLaunchedWithUrl()) {
this.allowOrientationChange = allowOrientationChange;
this.forceOrientation = OrientationManager.ForcedOrientation.valueOf(forceOrientation);
}
}
private static class OnDialogShowListener implements OnShowListener {
private final WeakReference<AdBaseDialog> weakAdBaseDialog;
OnDialogShowListener(AdBaseDialog adBaseDialog) {
weakAdBaseDialog = new WeakReference<>(adBaseDialog);
}
@Override
public void onShow(DialogInterface dialog) {
AdBaseDialog adBaseDialog = weakAdBaseDialog.get();
if (adBaseDialog == null) {
LogUtil.debug(TAG, "onShown(): Error notifying show listeners. AdBaseDialog is null.");
return;
}
adBaseDialog.handleDialogShow();
adBaseDialog.addCloseView();
InterstitialDisplayPropertiesInternal properties = adBaseDialog.interstitialManager.getInterstitialDisplayProperties();
if (properties.isSoundButtonVisible && (adBaseDialog instanceof InterstitialVideo)) {
adBaseDialog.addSoundView(properties.isMuted);
}
if (adBaseDialog instanceof InterstitialVideo) {
adBaseDialog.addSkipView();
}
adBaseDialog.interstitialManager.interstitialDialogShown(adBaseDialog.adViewContainer);
final DialogEventListener listener = adBaseDialog.listener;
if (listener != null) {
listener.onEvent(DialogEventListener.EventType.SHOWN);
}
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/AdExpandedDialog.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewBase;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
import org.prebid.mobile.rendering.views.webview.mraid.JSInterface;
import org.prebid.mobile.rendering.views.webview.mraid.Views;
//Used for MRAID ad expansion
public class AdExpandedDialog extends AdBaseDialog {
private static final String TAG = AdExpandedDialog.class.getSimpleName();
public AdExpandedDialog(final Context context, final WebViewBase webViewBaseLocal, InterstitialManager interstitialManager) {
super(context, webViewBaseLocal, interstitialManager);
//On MRAID expand we should not remove the old adview such that when the user closes the expanded ad
//they see the old ad.
preInit();
if (webViewBase != null && webViewBase.isMRAID()) {
webViewBase.getMRAIDInterface().onStateChange(JSInterface.STATE_EXPANDED);
}
setOnCancelListener(dialog -> {
try {
if (webViewBase != null) {
//detach from closecontainer
webViewBase.detachFromParent();
//add it back to WebView.
PrebidWebViewBase defaultContainer = (PrebidWebViewBase) webViewBase.getPreloadedListener();
//use getPreloadedListener() to get defaultContainer, as defaultContainer is not initiated for non-mraid cases(such as interstitials)
defaultContainer.addView(webViewBase);
////IMP - get the default state
defaultContainer.setVisibility(View.VISIBLE);
//do not ever call prebidWebView.visible. It makes the default adview on click of expand to be blank.
if (context instanceof Activity) {
((Activity) context).setRequestedOrientation(initialOrientation);
} else {
LogUtil.error(TAG, "Context is not Activity, can not set orientation");
}
webViewBase.getMRAIDInterface().onStateChange(JSInterface.STATE_DEFAULT);
}
}
catch (Exception e) {
LogUtil.error(TAG, "Expanded ad closed but post-close events failed: " + Log.getStackTraceString(e));
}
});
webViewBase.setDialog(this);
}
@Override
protected void handleCloseClick() {
interstitialManager.interstitialClosed(webViewBase);
}
@Override
protected void handleDialogShow() {
Views.removeFromParent(adViewContainer);
addContentView(adViewContainer,
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT
)
);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/AdInterstitialDialog.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
import org.prebid.mobile.rendering.views.webview.mraid.JSInterface;
import org.prebid.mobile.rendering.views.webview.mraid.Views;
@SuppressLint("NewApi")
public class AdInterstitialDialog extends AdBaseDialog {
private static final String TAG = AdInterstitialDialog.class.getSimpleName();
/**
* @param context activity context.
* @param webViewBaseLocal webview with ad.
* @param adViewContainer container for ad.
*/
public AdInterstitialDialog(Context context, WebViewBase webViewBaseLocal,
FrameLayout adViewContainer,
InterstitialManager interstitialManager) {
super(context, webViewBaseLocal, interstitialManager);
this.adViewContainer = adViewContainer;
preInit();
if (this.interstitialManager.getInterstitialDisplayProperties() != null) {
this.adViewContainer.setBackgroundColor(this.interstitialManager.getInterstitialDisplayProperties()
.getPubBackGroundOpacity());
}
setListeners();
webViewBase.setDialog(this);
}
private void setListeners() {
setOnCancelListener(dialog -> {
try {
if (webViewBase.isMRAID() && jsExecutor != null) {
webViewBase.getMRAIDInterface().onStateChange(JSInterface.STATE_DEFAULT);
webViewBase.detachFromParent();
}
}
catch (Exception e) {
LogUtil.error(TAG, "Interstitial ad closed but post-close events failed: " + Log.getStackTraceString(e));
}
});
}
@Override
protected void handleCloseClick() {
interstitialManager.interstitialClosed(webViewBase);
}
@Override
protected void handleDialogShow() {
Views.removeFromParent(adViewContainer);
addContentView(adViewContainer,
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT
)
);
}
public void nullifyDialog() {
cancel();
cleanup();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/DialogEventListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
public interface DialogEventListener {
void onEvent(EventType eventType);
enum EventType {
CLOSED,
SHOWN,
MUTE,
UNMUTE
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/InterstitialLayoutConfigurator.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
import android.text.TextUtils;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.models.InterstitialDisplayPropertiesInternal;
import org.prebid.mobile.rendering.models.InterstitialLayout;
/**
* Util class to configure InterstitialDisplayProperties based on adConfiguration
*/
public class InterstitialLayoutConfigurator {
public static void configureDisplayProperties(AdUnitConfiguration adConfiguration, InterstitialDisplayPropertiesInternal displayProperties) {
String size = adConfiguration.getInterstitialSize();
if (TextUtils.isEmpty(size) || InterstitialSizes.isPortrait(size)) {
displayProperties.isRotationEnabled = false;
displayProperties.orientation = InterstitialLayout.PORTRAIT.getOrientation();
} else if (InterstitialSizes.isLandscape(size)) {
displayProperties.isRotationEnabled = false;
displayProperties.orientation = InterstitialLayout.LANDSCAPE.getOrientation();
} else {
displayProperties.isRotationEnabled = true;
}
displayProperties.isSoundButtonVisible = adConfiguration.isSoundButtonVisible();
displayProperties.isMuted = adConfiguration.isMuted();
displayProperties.closeButtonArea = adConfiguration.getCloseButtonArea();
displayProperties.closeButtonPosition = adConfiguration.getCloseButtonPosition();
displayProperties.skipDelay = adConfiguration.getSkipDelay();
displayProperties.skipButtonArea = adConfiguration.getSkipButtonArea();
displayProperties.skipButtonPosition = adConfiguration.getSkipButtonPosition();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/InterstitialManagerDisplayDelegate.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
import android.view.ViewGroup;
public interface InterstitialManagerDisplayDelegate {
/**
* Close of an interstitial ad
*/
void interstitialAdClosed();
void interstitialDialogShown(ViewGroup rootViewGroup);
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/InterstitialManagerInterface.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
import android.view.View;
import android.view.ViewGroup;
public interface InterstitialManagerInterface {
void interstitialAdClosed();
void interstitialClosed(View view);
void interstitialDialogShown(ViewGroup rootViewGroup);
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/InterstitialManagerVideoDelegate.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
public interface InterstitialManagerVideoDelegate {
void onVideoInterstitialClosed();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/interstitial/InterstitialSizes.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.interstitial;
import android.text.TextUtils;
import java.util.HashSet;
/**
* Contains enums for InterstitialVideo sizes and methods to determine if video should be portrait,
* landscape or aspect ratio
*/
public class InterstitialSizes {
public enum InterstitialSize {
LANDSCAPE_480x320("480x320"),
LANDSCAPE_480x360("480x360"),
LANDSCAPE_768x1024("768x1024"),
LANDSCAPE_1024x768("1024x768"),
VERTICAL_270x480("270x480"),
VERTICAL_300x1050("300x1050"),
VERTICAL_320x480("320x480"),
VERTICAL_360x480("360x480"),
VERTICAL_360x540("360x540"),
VERTICAL_480x640("480x640"),
VERTICAL_576x1024("576x1024"),
VERTICAL_720x1280("720x1280"),
VERTICAL_768x1024("768x1024"),
VERTICAL_960x1280("960x1280"),
VERTICAL_1080x1920("1080x1920"),
VERTICAL_1440x1920("1440x1920"),
ASPECT_RATIO_300x200("300x200"),
ASPECT_RATIO_320x240("320x240"),
ASPECT_RATIO_400x225("400x225"),
ASPECT_RATIO_400x300("400x300"),
ASPECT_RATIO_480x270("480x270"),
ASPECT_RATIO_480x320("480x320"),
ASPECT_RATIO_640x360("640x360"),
ASPECT_RATIO_640x480("640x480"),
ASPECT_RATIO_1024x576("1024x576"),
ASPECT_RATIO_1280x720("1280x720"),
ASPECT_RATIO_1280x960("1280x960"),
ASPECT_RATIO_1920x800("1920x800"),
ASPECT_RATIO_1920x1080("1920x1080"),
ASPECT_RATIO_1920x1440("1920x1440");
private String size;
InterstitialSize(String size) {
this.size = size;
}
public String getSize() {
return size;
}
}
/**
* @param size - String with video resolution
* @return true if the given size is defined in Vertical enums
*/
public static boolean isPortrait(String size) {
if (TextUtils.isEmpty(size)) {
return false;
}
HashSet<String> sizes = new HashSet<>();
for (InterstitialSize enumSize : InterstitialSize.values()) {
if (enumSize.name().contains("VERTICAL")) {
sizes.add(enumSize.getSize());
}
}
return sizes.contains(size);
}
/**
*
* @param size - String with video resolution
* @return true if the given size is defined in Landscape enums
*/
public static boolean isLandscape(String size) {
if (TextUtils.isEmpty(size)) {
return false;
}
HashSet<String> sizes = new HashSet<>();
for (InterstitialSize enumSize : InterstitialSize.values()) {
if (enumSize.name().contains("LANDSCAPE")) {
sizes.add(enumSize.getSize());
}
}
return sizes.contains(size);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/listeners/AdIdFetchListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.listeners;
public interface AdIdFetchListener {
void adIdFetchCompletion();
void adIdFetchFailure();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/listeners/CreativeResolutionListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.listeners;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.models.AbstractCreative;
public interface CreativeResolutionListener {
void creativeReady(AbstractCreative creative);
void creativeFailed(AdException error);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/listeners/CreativeViewListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.listeners;
import android.view.ViewGroup;
import org.prebid.mobile.rendering.models.AbstractCreative;
public interface CreativeViewListener {
/**
* Is called when creative finish its lifecycle.
*
* @param creative
*/
void creativeDidComplete(AbstractCreative creative);
/**
* Is called when ad's content is rendered in the displayed view.
* @param creative
* @param url
*/
void creativeWasClicked(AbstractCreative creative, String url);
/**
* Is called when user closes the creatives clickthrough.
* @param creative
*/
void creativeInterstitialDidClose(AbstractCreative creative);
void creativeDidExpand(AbstractCreative creative); // MRAID banner only
void creativeDidCollapse(AbstractCreative creative); // MRAID banner only
void creativeInterstitialDialogShown(ViewGroup rootViewGroup);
void creativeMuted(AbstractCreative creative);
void creativeUnMuted(AbstractCreative creative);
void creativePaused(AbstractCreative creative);
void creativeResumed(AbstractCreative creative);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/listeners/OnBrowserActionResultListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.listeners;
public interface OnBrowserActionResultListener {
void onSuccess(BrowserActionResult browserActionResult);
enum BrowserActionResult {
INTERNAL_BROWSER, EXTERNAL_BROWSER
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/listeners/SdkInitializationListener.java | package org.prebid.mobile.rendering.listeners;
import org.prebid.mobile.api.exceptions.InitError;
public interface SdkInitializationListener {
void onSdkInit();
void onSdkFailedToInit(InitError error);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/listeners/VideoCreativeViewListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.listeners;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.models.internal.InternalPlayerState;
import org.prebid.mobile.rendering.video.VideoAdEvent;
public interface VideoCreativeViewListener {
//error
void onFailure(AdException error);
void onReadyForDisplay();
//complete
void onDisplayCompleted();
//start...thirdquartile
void onEvent(VideoAdEvent.Event trackingEvent);
void onVolumeChanged(float volume);
void onPlayerStateChanged(InternalPlayerState state);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/listeners/VideoDialogListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.listeners;
public interface VideoDialogListener {
void onVideoDialogClosed();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/listeners/WebViewDelegate.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.listeners;
import org.prebid.mobile.api.exceptions.AdException;
public interface WebViewDelegate {
void webViewReadyToDisplay();
void webViewFailedToLoad(AdException error);
void webViewShouldOpenExternalLink(String url);
void webViewShouldOpenMRAIDLink(String url);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/loading/AdLoadListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.loading;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.models.CreativeModelsMaker;
public interface AdLoadListener {
void onCreativeModelReady(CreativeModelsMaker.Result result);
void onFailedToLoadAd(AdException e, String vastLoaderIdentifier);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/loading/CreativeFactory.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.loading;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.listeners.CreativeResolutionListener;
import org.prebid.mobile.rendering.models.AbstractCreative;
import org.prebid.mobile.rendering.models.CreativeModel;
import org.prebid.mobile.rendering.models.HTMLCreative;
import org.prebid.mobile.rendering.models.TrackingEvent;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.video.RewardedVideoCreative;
import org.prebid.mobile.rendering.video.VideoAdEvent;
import org.prebid.mobile.rendering.video.VideoCreative;
import org.prebid.mobile.rendering.video.VideoCreativeModel;
import org.prebid.mobile.rendering.video.vast.VASTErrorCodes;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
public class CreativeFactory {
private static final String TAG = CreativeFactory.class.getSimpleName();
private static final long BANNER_TIMEOUT = 6 * 1000;
private static final long VAST_TIMEOUT = 30 * 1000;
private static final long INTERSTITIAL_TIMEOUT = 30 * 1000;
private AbstractCreative creative;
private CreativeModel creativeModel;
private WeakReference<Context> contextReference;
private Listener listener;
private OmAdSessionManager omAdSessionManager;
private final InterstitialManager interstitialManager;
private TimeoutState timeoutState = TimeoutState.PENDING;
private Handler timeoutHandler = new Handler(Looper.getMainLooper());
public CreativeFactory(
Context context,
CreativeModel creativeModel,
Listener listener,
OmAdSessionManager omAdSessionManager,
InterstitialManager interstitialManager
) throws AdException {
if (context == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Context is null");
}
if (creativeModel == null) {
throw new AdException(AdException.INTERNAL_ERROR, "CreativeModel is null");
}
if (listener == null) {
throw new AdException(AdException.INTERNAL_ERROR, "CreativeFactory listener is null");
}
this.listener = listener;
contextReference = new WeakReference<>(context);
this.creativeModel = creativeModel;
this.omAdSessionManager = omAdSessionManager;
this.interstitialManager = interstitialManager;
}
public void start() {
try {
AdUnitConfiguration configuration = creativeModel.getAdConfiguration();
if (configuration.isAdType(AdFormat.BANNER) || configuration.isAdType(AdFormat.INTERSTITIAL)) {
attemptAuidCreative();
} else if (configuration.isAdType(AdFormat.VAST)) {
attemptVastCreative();
} else {
String msg = "Unable to start creativeFactory. adConfig.adUnitIdentifierType doesn't match supported types adConfig.adFormat: " + configuration.getAdFormats();
LogUtil.error(TAG, msg);
AdException adException = new AdException(AdException.INTERNAL_ERROR, msg);
listener.onFailure(adException);
}
} catch (Exception exception) {
String message = "Creative Factory failed: " + exception.getMessage();
LogUtil.error(TAG, message + Log.getStackTraceString(exception));
AdException adException = new AdException(AdException.INTERNAL_ERROR, message);
listener.onFailure(adException);
}
}
public void destroy() {
if (creative != null) {
creative.destroy();
}
timeoutHandler.removeCallbacks(null);
}
public AbstractCreative getCreative() {
return creative;
}
private void attemptAuidCreative() throws Exception {
creative = new HTMLCreative(contextReference.get(), creativeModel, omAdSessionManager, interstitialManager);
creative.setResolutionListener(new CreativeFactoryCreativeResolutionListener(this));
ArrayList<String> riUrls = new ArrayList<>();
ArrayList<String> rcUrls = new ArrayList<>();
//get the tracking url & do the registration here. add in the tracking stuff here
//This needs to be more generalized and allow for multiple click urls
if (!creativeModel.isRequireImpressionUrl() || Utils.isNotBlank(creativeModel.getImpressionUrl())) {
if (!TextUtils.isEmpty(creativeModel.getImpressionUrl())) {
riUrls.add(creativeModel.getImpressionUrl());
creativeModel.registerTrackingEvent(TrackingEvent.Events.IMPRESSION, riUrls);
}
//
if (!TextUtils.isEmpty(creativeModel.getClickUrl())) {
rcUrls.add(creativeModel.getClickUrl());
creativeModel.registerTrackingEvent(TrackingEvent.Events.CLICK, rcUrls);
}
} else {
listener.onFailure(new AdException(AdException.INTERNAL_ERROR, "Tracking info not found"));
}
long creativeDownloadTimeout = BANNER_TIMEOUT;
Map<String, Set<String>> context = creativeModel.getAdConfiguration().getContextDataDictionary();
if (context.containsKey("creative_load_timeout")) {
Set<String> timeoutSet = context.get("creative_load_timeout");
if (timeoutSet != null && !timeoutSet.isEmpty()) {
try {
creativeDownloadTimeout = Long.parseLong((String) (timeoutSet.toArray())[0]);
} catch (NumberFormatException ignored){}
}
}
if (creativeModel.getAdConfiguration().isAdType(AdFormat.INTERSTITIAL)) {
creativeDownloadTimeout = INTERSTITIAL_TIMEOUT;
}
markWorkStart(creativeDownloadTimeout);
creative.load();
}
private void attemptVastCreative() {
VideoCreativeModel videoCreativeModel = (VideoCreativeModel) creativeModel;
String mediaUrl = videoCreativeModel.getMediaUrl();
if (Utils.isBlank(mediaUrl) || mediaUrl.equals("invalid media file")) {
listener.onFailure(new AdException(
AdException.INTERNAL_ERROR,
VASTErrorCodes.NO_SUPPORTED_MEDIA_ERROR.toString()
));
return;
}
//get the tracking url for all event types & do the registration here.
for (VideoAdEvent.Event videoEvent : VideoAdEvent.Event.values()) {
videoCreativeModel.registerVideoEvent(videoEvent, videoCreativeModel.getVideoEventUrls().get(videoEvent));
}
ArrayList<String> impressions = new ArrayList<>(1);
impressions.add(creativeModel.getImpressionUrl());
videoCreativeModel.registerTrackingEvent(
TrackingEvent.Events.IMPRESSION,
impressions
);
VideoCreative newCreative;
try {
if (creativeModel.getAdConfiguration().isRewarded()) {
newCreative = new RewardedVideoCreative(
contextReference.get(),
videoCreativeModel,
omAdSessionManager,
interstitialManager
);
} else {
newCreative = new VideoCreative(contextReference.get(),
videoCreativeModel,
omAdSessionManager,
interstitialManager
);
}
newCreative.setResolutionListener(new CreativeFactoryCreativeResolutionListener(this));
creative = newCreative;
markWorkStart(VAST_TIMEOUT);
newCreative.load();
} catch (Exception exception) {
LogUtil.error(TAG, "VideoCreative creation failed: " + Log.getStackTraceString(exception));
listener.onFailure(new AdException(
AdException.INTERNAL_ERROR,
"VideoCreative creation failed: " + exception.getMessage()
));
}
}
private void markWorkStart(long timeout) {
timeoutState = TimeoutState.RUNNING;
timeoutHandler.postDelayed(() -> {
if (timeoutState != TimeoutState.FINISHED) {
timeoutState = TimeoutState.EXPIRED;
listener.onFailure((new AdException(AdException.INTERNAL_ERROR, "Creative factory Timeout")));
}
}, timeout);
}
/**
* Listens for when Creatives are made
* Relays that back to CreativeFactory's listener
*/
public interface Listener {
void onSuccess();
void onFailure(AdException exception);
}
public enum TimeoutState {
PENDING,
RUNNING,
FINISHED,
EXPIRED
}
static class CreativeFactoryCreativeResolutionListener implements CreativeResolutionListener {
private WeakReference<CreativeFactory> weakCreativeFactory;
CreativeFactoryCreativeResolutionListener(CreativeFactory creativeFactory) {
weakCreativeFactory = new WeakReference<>(creativeFactory);
}
@Override
public void creativeReady(AbstractCreative creative) {
CreativeFactory creativeFactory = weakCreativeFactory.get();
if (creativeFactory == null) {
LogUtil.warning(TAG, "CreativeFactory is null");
return;
}
if (creativeFactory.timeoutState == TimeoutState.EXPIRED) {
creativeFactory.listener.onFailure(new AdException(AdException.INTERNAL_ERROR, "Creative Timeout"));
LogUtil.warning(TAG, "Creative timed out, backing out");
return;
}
creativeFactory.timeoutState = TimeoutState.FINISHED;
creativeFactory.listener.onSuccess();
}
@Override
public void creativeFailed(AdException error) {
CreativeFactory creativeFactory = weakCreativeFactory.get();
if (creativeFactory == null) {
LogUtil.warning(TAG, "CreativeFactory is null");
return;
}
creativeFactory.timeoutHandler.removeCallbacks(null);
creativeFactory.listener.onFailure(error);
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/loading/FileDownloadListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.loading;
import org.prebid.mobile.rendering.networking.BaseResponseHandler;
public interface FileDownloadListener extends BaseResponseHandler {
void onFileDownloaded(String path);
void onFileDownloadError(String error);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/loading/FileDownloadTask.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.loading;
import android.util.Log;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.errors.ServerWrongStatusCode;
import org.prebid.mobile.rendering.networking.BaseNetworkTask;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URLConnection;
/**
* More of a general task for downloading files w/o feedback on progress
*/
public class FileDownloadTask extends BaseNetworkTask {
private static final String TAG = "LibraryDownloadTask";
protected FileDownloadListener listener;
protected File file;
/**
* Creates a network object
*
* @param handler instance of a class handling ad server responses (like , InterstitialSwitchActivity)
*/
public FileDownloadTask(
FileDownloadListener handler,
File file
) {
super(handler);
if (file == null) {
String nullFileMessage = "File is null";
if (handler != null) {
handler.onFileDownloadError(nullFileMessage);
}
throw new NullPointerException(nullFileMessage);
}
this.file = file;
if (!this.file.exists()) {
try {
this.file.createNewFile();
} catch (IOException e) {
String errorCreatingFile = "Error creating file";
handler.onFileDownloadError(errorCreatingFile);
throw new IllegalStateException(errorCreatingFile);
}
}
listener = handler;
}
protected long getMaxFileSize() {
return 25 * 1024 * 1024; // 25 MiB
}
@Override
public GetUrlResult customParser(int code, URLConnection urlConnection) {
GetUrlResult result = new GetUrlResult();
if (code != HttpURLConnection.HTTP_OK) {
ServerWrongStatusCode wrongCode = new ServerWrongStatusCode(code);
result.setException(wrongCode);
return result;
}
try {
int contentLength = urlConnection.getContentLength();
if (contentLength > getMaxFileSize()) {
result.setException(new Exception("FileDownloader encountered a file larger than SDK cap of " + getMaxFileSize()));
return result;
}
if (contentLength <= 0) {
result.setException(new Exception("FileDownloader encountered file with " + contentLength + " content length"));
return result;
}
processData(urlConnection, result);
}
catch (IOException e) {
LogUtil.error(TAG, "download of media failed: " + Log.getStackTraceString(e));
result.setException(new Exception("download of media failed " + e.getMessage()));
}
finally {
if (urlConnection instanceof HttpURLConnection) {
((HttpURLConnection) urlConnection).disconnect();
}
}
return result;
}
protected void processData(URLConnection connection, GetUrlResult result) throws IOException {
FileOutputStream outputStream = null;
InputStream inputStream = null;
try {
outputStream = new FileOutputStream(file);
inputStream = connection.getInputStream();
byte[] data = new byte[16384];
int count;
while ((count = inputStream.read(data)) != -1) {
outputStream.write(data, 0, count);
}
}
catch (IOException e) {
throw e;
}
finally {
if (outputStream != null) {
outputStream.close();
}
if (inputStream != null) {
inputStream.close();
}
}
}
@Override
protected void onPostExecute(GetUrlResult urlResult) {
if (urlResult.getException() != null) {
LogUtil.debug(TAG, "download of media failed" + urlResult.getException());
if (listener != null) {
listener.onFileDownloadError((urlResult.getException().getMessage()));
}
return;
}
if (listener != null) {
String path = file.getPath();
int beginIndex = path.lastIndexOf("/");
listener.onFileDownloaded(beginIndex != -1 ? path.substring(beginIndex) : path);
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/loading/Transaction.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.loading;
import android.content.Context;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.models.CreativeModel;
import org.prebid.mobile.rendering.models.CreativeModelsMaker;
import org.prebid.mobile.rendering.sdk.JSLibraryManager;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Transaction {
public static final String TAG = Transaction.class.getSimpleName();
private List<CreativeFactory> creativeFactories;
private Iterator<CreativeFactory> creativeFactoryIterator;
private List<CreativeModel> creativeModels;
private WeakReference<Context> contextReference;
private Listener listener;
private OmAdSessionManager omAdSessionManager;
private final InterstitialManager interstitialManager;
private String transactionState;
private String loaderIdentifier;
private long transactionCreateTime;
public interface Listener {
void onTransactionSuccess(Transaction transaction);
void onTransactionFailure(
AdException e,
String identifier
);
}
private Transaction(Context context, List<CreativeModel> creativeModels,
String transactionState,
InterstitialManager interstitialManager,
Listener listener)
throws AdException {
if (context == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Transaction - Context is null");
}
if (creativeModels == null || creativeModels.isEmpty()) {
throw new AdException(AdException.INTERNAL_ERROR, "Transaction - Creative models is empty");
}
if (listener == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Transaction - Listener is null");
}
contextReference = new WeakReference<>(context);
this.creativeModels = creativeModels;
checkForBuiltInVideo();
this.transactionState = transactionState;
this.listener = listener;
this.interstitialManager = interstitialManager;
omAdSessionManager = OmAdSessionManager.createNewInstance(JSLibraryManager.getInstance(context));
creativeFactories = new ArrayList<>();
}
public static Transaction createTransaction(Context context, CreativeModelsMaker.Result result,
InterstitialManager interstitialManager, Listener listener)
throws AdException {
Transaction transaction = new Transaction(
context,
result.creativeModels,
result.transactionState,
interstitialManager,
listener);
transaction.setTransactionCreateTime(System.currentTimeMillis());
transaction.setLoaderIdentifier(result.loaderIdentifier);
return transaction;
}
private void checkForBuiltInVideo() {
try {
if (creativeModels != null && creativeModels.size() > 1) {
CreativeModel creativeModel = creativeModels.get(0);
boolean isBannerVideo = creativeModel.getAdConfiguration().isBuiltInVideo();
if (isBannerVideo) {
CreativeModel possibleEndCard = creativeModels.get(1);
possibleEndCard.getAdConfiguration().setBuiltInVideo(true);
}
}
}
catch (Exception e) {
LogUtil.error(TAG, "Failed to check for built in video override");
}
}
public String getTransactionState() {
return transactionState;
}
public void startCreativeFactories() {
try {
// Initialize list of CreativeFactories
creativeFactories.clear();
for (CreativeModel creativeModel : creativeModels) {
CreativeFactory creativeFactory = new CreativeFactory(contextReference.get(),
creativeModel,
new CreativeFactoryListener(this),
omAdSessionManager,
interstitialManager
);
creativeFactories.add(creativeFactory);
}
// Start first CreativeFactory, if any
// On success, the CreativeFactoryListener will start the next CreativeFactory
creativeFactoryIterator = creativeFactories.iterator();
startNextCreativeFactory();
}
catch (AdException e) {
listener.onTransactionFailure(e, loaderIdentifier);
}
}
public void destroy() {
stopOmAdSession();
for (CreativeFactory creativeFactory : creativeFactories) {
creativeFactory.destroy();
}
}
private boolean startNextCreativeFactory() {
// No CreativeFactory to start
if (creativeFactoryIterator == null || !creativeFactoryIterator.hasNext()) {
return false;
}
CreativeFactory creativeFactory = creativeFactoryIterator.next();
creativeFactory.start();
return true;
}
private void stopOmAdSession() {
if (omAdSessionManager == null) {
LogUtil.error(TAG, "Failed to stopOmAdSession. OmAdSessionManager is null");
return;
}
omAdSessionManager.stopAdSession();
omAdSessionManager = null;
}
public List<CreativeFactory> getCreativeFactories() {
return creativeFactories;
}
public String getLoaderIdentifier() {
return loaderIdentifier;
}
public void setLoaderIdentifier(String loaderIdentifier) {
this.loaderIdentifier = loaderIdentifier;
}
public long getTransactionCreateTime() {
return transactionCreateTime;
}
public void setTransactionCreateTime(long transactionCreateTime) {
this.transactionCreateTime = transactionCreateTime;
}
/**
* Listens for when CreativeFactory is done making a creative
* When all CreativeFactory's are done, relays that back to Transaction's Listener
*/
public static class CreativeFactoryListener implements CreativeFactory.Listener {
private WeakReference<Transaction> weakTransaction;
CreativeFactoryListener(Transaction transaction) {
weakTransaction = new WeakReference<>(transaction);
}
@Override
public void onSuccess() {
Transaction transaction = weakTransaction.get();
if (transaction == null) {
LogUtil.warning(TAG, "CreativeMaker is null");
return;
}
// Start next CreativeFactory, if any
if (transaction.startNextCreativeFactory()) {
return;
}
// If all CreativeFactories succeeded, return success
transaction.listener.onTransactionSuccess(transaction);
}
@Override
public void onFailure(AdException e) {
Transaction transaction = weakTransaction.get();
if (transaction == null) {
LogUtil.warning(TAG, "CreativeMaker is null");
return;
}
transaction.listener.onTransactionFailure(e, transaction.getLoaderIdentifier());
transaction.destroy();
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/loading/TransactionManager.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.loading;
import android.content.Context;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
import org.prebid.mobile.rendering.models.AbstractCreative;
import org.prebid.mobile.rendering.models.CreativeModelMakerBids;
import org.prebid.mobile.rendering.models.CreativeModelsMaker;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
public class TransactionManager implements AdLoadListener, Transaction.Listener {
private static final String TAG = "TransactionManager";
private final WeakReference<Context> weakContextReference;
private final List<Transaction> transactions = new ArrayList<>();
private final InterstitialManager interstitialManager;
private final CreativeModelMakerBids creativeModelMakerBids = new CreativeModelMakerBids(this);
private Transaction latestTransaction;
private int currentTransactionCreativeIndex;
private TransactionManagerListener listener;
public TransactionManager(
Context context,
TransactionManagerListener listener,
InterstitialManager interstitialManager
) {
weakContextReference = new WeakReference<>(context);
this.listener = listener;
this.interstitialManager = interstitialManager;
}
//// AdLoadManager.Listener implementation
@Override
public void onCreativeModelReady(CreativeModelsMaker.Result result) {
try {
// Assign transaction to a field to prevent from being destroyed
latestTransaction = Transaction.createTransaction(weakContextReference.get(),
result,
interstitialManager,
this
);
latestTransaction.startCreativeFactories();
}
catch (AdException e) {
notifyListenerError(e);
}
}
@Override
public void onFailedToLoadAd(AdException e, String vastLoaderIdentifier) {
notifyListenerError(e);
}
//// Transaction.Listener implementation
@Override
public void onTransactionSuccess(Transaction transaction) {
latestTransaction = null;
if (listener == null) {
LogUtil.warning(TAG, "Unable to notify listener. Listener is null");
return;
}
transactions.add(transaction);
listener.onFetchingCompleted(transaction);
}
@Override
public void onTransactionFailure(AdException e, String identifier) {
notifyListenerError(e);
}
/**
* Initiates the process of creating creative model and transaction from parsed bid response
*
* @param adConfiguration - AdConfiguration
* @param bidResponse - parsed bid response
*/
public void fetchBidTransaction(AdUnitConfiguration adConfiguration, BidResponse bidResponse) {
creativeModelMakerBids.makeModels(adConfiguration, bidResponse);
}
public void fetchVideoTransaction(AdUnitConfiguration adConfiguration, String vastXml) {
creativeModelMakerBids.makeVideoModels(adConfiguration, vastXml);
}
/**
* Returns the transaction that should be displayed right now.
*
* @return first transaction
*/
public Transaction getCurrentTransaction() {
if (hasTransaction()) {
return transactions.get(0);
}
return null;
}
/**
* Removes the current transaction from internal cache
*
* @return the next transactions in the list
*/
public Transaction dismissCurrentTransaction() {
if (hasTransaction()) {
transactions.remove(0);
}
return getCurrentTransaction();
}
public AbstractCreative getCurrentCreative() {
Transaction transaction = getCurrentTransaction();
if (transaction == null) {
LogUtil.error(TAG, "Get Current creative called with no ad");
return null;
}
return transaction.getCreativeFactories().get(currentTransactionCreativeIndex).getCreative();
}
public boolean hasNextCreative() {
Transaction currentTransaction = getCurrentTransaction();
if (currentTransaction == null) {
return false;
}
int creativeFactoriesSize = currentTransaction.getCreativeFactories().size();
return currentTransactionCreativeIndex < creativeFactoriesSize - 1;
}
public void resetState() {
Transaction transaction = getCurrentTransaction();
if (transaction != null) {
transaction.destroy();
transactions.remove(0);
}
currentTransactionCreativeIndex = 0;
cancelBidModelMaker();
}
public boolean hasTransaction() {
return !transactions.isEmpty();
}
public void destroy() {
for (Transaction transaction : transactions) {
transaction.destroy();
}
if (latestTransaction != null) {
latestTransaction.destroy();
latestTransaction = null;
}
cancelBidModelMaker();
listener = null;
}
public void incrementCreativesCounter() {
currentTransactionCreativeIndex++;
}
private void cancelBidModelMaker() {
if (creativeModelMakerBids != null) {
creativeModelMakerBids.cancel();
}
}
private void notifyListenerError(AdException e) {
if (listener == null) {
LogUtil.warning(TAG, "Unable to notify listener. Listener is null");
return;
}
listener.onFetchingFailed(e);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/loading/TransactionManagerListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.loading;
import org.prebid.mobile.api.exceptions.AdException;
public interface TransactionManagerListener {
/**
* Is called when TransactionManager has finished the fetching process.
* In case of success, the transaction represents the loaded transaction.
*
* @param transaction successful transaction
*/
void onFetchingCompleted(Transaction transaction);
/**
* In case of failure, the error should be not null and contains the description of the issue
*
* @param exception used to inform the listener in case something is wrong
*/
void onFetchingFailed(AdException exception);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/loading/VastParserExtractor.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.loading;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.errors.VastParseError;
import org.prebid.mobile.rendering.models.internal.VastExtractorResult;
import org.prebid.mobile.rendering.networking.BaseNetworkTask;
import org.prebid.mobile.rendering.networking.ResponseHandler;
import org.prebid.mobile.rendering.networking.modelcontrollers.AsyncVastLoader;
import org.prebid.mobile.rendering.parser.AdResponseParserBase;
import org.prebid.mobile.rendering.parser.AdResponseParserVast;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.video.vast.VASTErrorCodes;
public class VastParserExtractor {
private static final String TAG = VastParserExtractor.class.getSimpleName();
public static final int WRAPPER_NESTING_LIMIT = 5;
private final AsyncVastLoader asyncVastLoader = new AsyncVastLoader();
@NonNull private final VastParserExtractor.Listener listener;
private AdResponseParserVast rootVastParser;
private AdResponseParserVast latestVastWrapperParser;
private int vastWrapperCount;
private final ResponseHandler responseHandler = new ResponseHandler() {
@Override
public void onResponse(BaseNetworkTask.GetUrlResult response) {
performVastUnwrap(response.responseString);
}
@Override
public void onError(
String msg,
long responseTime
) {
failedToLoadAd(msg);
}
@Override
public void onErrorWithException(Exception e, long responseTime) {
failedToLoadAd(e.getMessage());
}
};
public VastParserExtractor(
@NonNull
Listener listener) {
this.listener = listener;
}
public void cancel() {
if (asyncVastLoader != null) {
asyncVastLoader.cancelTask();
}
}
public void extract(String vast) {
performVastUnwrap(vast);
}
private void performVastUnwrap(String vast) {
if (!Utils.isVast(vast)) {
final AdException adException = new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.VAST_SCHEMA_ERROR.toString());
listener.onResult(createExtractorFailureResult(adException));
return;
}
vastWrapperCount++;
// A new response has come back, either from the initial VAST request or a wrapper request.
// Parse the response.
AdResponseParserVast adResponseParserVast;
try {
adResponseParserVast = new AdResponseParserVast(vast);
} catch (VastParseError e) {
LogUtil.error(TAG, "AdResponseParserVast creation failed: " + Log.getStackTraceString(e));
final AdException adException = new AdException(AdException.INTERNAL_ERROR, e.getMessage());
listener.onResult(createExtractorFailureResult(adException));
return;
}
// Check if this is the response from the initial request or from unwrapping a wrapper
if (rootVastParser == null) {
// If rootVastParser doesn't exist then it is the initial VAST request
LogUtil.debug(TAG, "Initial VAST Request");
rootVastParser = adResponseParserVast;
} else {
// Otherwise, this is the result of unwrapping a Wrapper.
LogUtil.debug(TAG, "Unwrapping VAST Wrapper");
latestVastWrapperParser.setWrapper(adResponseParserVast);
}
latestVastWrapperParser = adResponseParserVast;
// Check if this response is a wrapper
String vastUrl = latestVastWrapperParser.getVastUrl();
if (!TextUtils.isEmpty(vastUrl)) {
if (vastWrapperCount >= WRAPPER_NESTING_LIMIT) {
final AdException adException = new AdException(
AdException.INTERNAL_ERROR,
VASTErrorCodes.WRAPPER_LIMIT_REACH_ERROR.toString()
);
final VastExtractorResult extractorFailureResult = createExtractorFailureResult(adException);
listener.onResult(extractorFailureResult);
vastWrapperCount = 0;
return;
}
asyncVastLoader.loadVast(vastUrl, responseHandler);
}
else {
final AdResponseParserBase[] parserArray = {rootVastParser, latestVastWrapperParser};
listener.onResult(new VastExtractorResult(parserArray));
}
}
private void failedToLoadAd(String msg) {
LogUtil.error(TAG, "Invalid ad response: " + msg);
final AdException adException = new AdException(AdException.INTERNAL_ERROR, "Invalid ad response: " + msg);
listener.onResult(createExtractorFailureResult(adException));
}
@VisibleForTesting
VastExtractorResult createExtractorFailureResult(AdException adException) {
return new VastExtractorResult(adException);
}
public interface Listener {
void onResult(VastExtractorResult result);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/AbstractCreative.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import android.content.Context;
import android.view.View;
import androidx.annotation.NonNull;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.listeners.CreativeResolutionListener;
import org.prebid.mobile.rendering.listeners.CreativeViewListener;
import org.prebid.mobile.rendering.models.internal.InternalFriendlyObstruction;
import org.prebid.mobile.rendering.models.internal.InternalPlayerState;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import org.prebid.mobile.rendering.video.VideoAdEvent;
import org.prebid.mobile.rendering.views.AdViewManager;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import java.lang.ref.WeakReference;
public abstract class AbstractCreative {
private static final String TAG = AbstractCreative.class.getSimpleName();
protected WeakReference<Context> contextReference;
private CreativeModel model;
private CreativeViewListener creativeViewListener;
private CreativeResolutionListener resolutionListener;
protected WeakReference<OmAdSessionManager> weakOmAdSessionManager;
protected InterstitialManager interstitialManager;
private View creativeView;
protected CreativeVisibilityTracker creativeVisibilityTracker;
public AbstractCreative(
Context context,
CreativeModel model,
OmAdSessionManager omAdSessionManager,
InterstitialManager interstitialManager
)
throws AdException {
if (context == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Context is null");
}
if (model == null) {
throw new AdException(AdException.INTERNAL_ERROR, "CreativeModel is null");
}
contextReference = new WeakReference<>(context);
this.model = model;
weakOmAdSessionManager = new WeakReference<>(omAdSessionManager);
this.interstitialManager = interstitialManager;
this.model.registerActiveOmAdSession(omAdSessionManager);
}
public abstract boolean isDisplay();
public abstract boolean isVideo();
public abstract boolean isResolved();
public abstract boolean isEndCard();
/**
* Subclasses should provide their implementation, default is printing a log statement
*/
/**
* Pause creative execution
*/
public void pause() {
LogUtil.debug(TAG, "pause(): Base method implementation: ignoring");
}
/**
* Resume creative execution
*/
public void resume() {
LogUtil.debug(TAG, "resume(): Base method implementation: ignoring");
}
/**
* UnMute creative
*/
public void unmute() {
LogUtil.debug(TAG, "unMute(): Base method implementation: ignoring");
}
/**
* Mute creative
*/
public void mute() {
LogUtil.debug(TAG, "mute(): Base method implementation: ignoring");
}
/**
* @return Whether the creative is playing
*/
public boolean isPlaying() {
LogUtil.debug(TAG, "isPlaying(): Returning default value: false");
return false;
}
/**
* Track video state change to OmEventTracker
*
* @param state to track
*/
public void trackVideoStateChange(InternalPlayerState state) {
LogUtil.debug(TAG, "trackVideoStateChange: Base method implementation: ignoring");
}
/**
* @return if current creative is serving as interstitial that was closed
*/
public boolean isInterstitialClosed() {
LogUtil.debug(TAG, "isInterstitialClosed(): Returning default value: false");
return false;
}
/**
* @return media duration in ms
*/
public long getMediaDuration() {
LogUtil.debug(TAG, "getMediaDuration(): Returning default value: 0");
return 0;
}
/**
* @return video skip offset in ms
*/
public long getVideoSkipOffset() {
LogUtil.debug(TAG, "getVideoSkipOffset(): Returning default value: -1");
return AdUnitConfiguration.SKIP_OFFSET_NOT_ASSIGNED;
}
/**
* VideoAdEvent.Event to track
*/
public void trackVideoEvent(VideoAdEvent.Event event) {
LogUtil.debug(TAG, "trackVideoEvent(): Base method implementation: ignoring");
}
/**
* @return if the current ad config suggests that this is a video
*/
public boolean isBuiltInVideo() {
return model.getAdConfiguration().isBuiltInVideo();
}
/**
* Specific creative load.
*/
public abstract void load() throws AdException;
/**
* Executed after processing transaction and creating OmAdSession in {@link AdViewManager}
*/
public abstract void trackAdLoaded();
/**
* Specific creative display.
*/
public abstract void display();
/**
* Create OM session for specific creative. Each creative must create appropriate OM AdSession (e.g. for HTML and Native)
*/
public abstract void createOmAdSession();
public abstract void startViewabilityTracker();
/**
* Specific creative cleanup. Creative must cleanup it's internal state.
*/
public void destroy() {
if (creativeVisibilityTracker != null) {
creativeVisibilityTracker.stopVisibilityCheck();
creativeVisibilityTracker = null;
}
}
/**
* Executed when window gains focus (e.g. when app is resumed from background)
* Used by {@link AdViewManager} to handle refresh on view visibility change
*/
public abstract void handleAdWindowFocus();
/**
* Executed when window loses focus (e.g. when app is going in background).
* Used by {@link AdViewManager} to handle refresh on view visibility change
*/
public abstract void handleAdWindowNoFocus();
/**
* Changes the {@link #creativeVisibilityTracker} state based on ad webView window focus.
* If ad webView has no window focus - {@link #creativeVisibilityTracker} execution will be stopped.
* If ad webView has window focus - {@link #creativeVisibilityTracker} execution will be restarted.
*
* @param adWebViewWindowFocus adWebView focus state
*/
public void changeVisibilityTrackerState(boolean adWebViewWindowFocus) {
if (creativeVisibilityTracker == null) {
LogUtil.debug(TAG, "handleAdWebViewWindowFocusChange(): Failed. CreativeVisibilityTracker is null.");
return;
}
if (!adWebViewWindowFocus) {
creativeVisibilityTracker.stopVisibilityCheck();
}
else {
creativeVisibilityTracker.stopVisibilityCheck();
creativeVisibilityTracker.startVisibilityCheck(contextReference.get());
}
}
public void setResolutionListener(CreativeResolutionListener resolutionListener) {
this.resolutionListener = resolutionListener;
}
public boolean isInterstitial() {
return false;
}
public CreativeResolutionListener getResolutionListener() {
return resolutionListener;
}
public void setCreativeViewListener(CreativeViewListener creativeViewListener) {
this.creativeViewListener = creativeViewListener;
}
/**
* Sets currently used creative view for specific creative.
*
* @param creativeView individual creative view. E.g. webView for HTMLCreative.
*/
public void setCreativeView(View creativeView) {
this.creativeView = creativeView;
}
/**
* @return individual creative view. E.g. webView for HTMLCreative.
*/
public View getCreativeView() {
return creativeView;
}
/**
* @return {@link CreativeModel} which can be used to track events or to access specific creative ad configuration.
*/
@NonNull
public CreativeModel getCreativeModel() {
return model;
}
public void updateAdView(View view) {
OmAdSessionManager omAdSessionManager = weakOmAdSessionManager.get();
if (omAdSessionManager == null) {
LogUtil.error(TAG, "Unable to updateAdView. OmAdSessionManager is null");
return;
}
omAdSessionManager.registerAdView(view);
}
public CreativeViewListener getCreativeViewListener() {
return creativeViewListener;
}
public void addOmFriendlyObstruction(InternalFriendlyObstruction friendlyObstruction) {
if (friendlyObstruction == null) {
LogUtil.debug(TAG, "addOmFriendlyObstruction: Obstruction view is null. Skip adding as friendlyObstruction");
return;
}
OmAdSessionManager omAdSessionManager = weakOmAdSessionManager.get();
if (omAdSessionManager == null) {
LogUtil.error(TAG, "Unable to addOmFriendlyObstruction. OmAdSessionManager is null");
return;
}
omAdSessionManager.addObstruction(friendlyObstruction);
}
protected void startOmSession(OmAdSessionManager omAdSessionManager, View view) {
omAdSessionManager.registerAdView(view);
omAdSessionManager.startAdSession();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/AdDetails.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
/**
* A wrapper to get all ad related details like transaction state, price(in future), etc
*/
public class AdDetails {
private String transactionId;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/AdPosition.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
public enum AdPosition {
UNDEFINED(-1),
UNKNOWN(0),
HEADER(4),
FOOTER(5),
SIDEBAR(6),
FULLSCREEN(7);
private final int value;
AdPosition(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/CreativeModel.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import androidx.annotation.Nullable;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.networking.tracking.TrackingManager;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import org.prebid.mobile.rendering.video.OmEventTracker;
import org.prebid.mobile.rendering.video.VideoAdEvent;
import java.util.ArrayList;
import java.util.HashMap;
// CreativeModel is visible to the publisher, and defines:
// --- displayDurationInSeconds indicates the time the creative will display for
// -------- A negative value indicates that this field has not been set
// -------- A value of 0 indicates an indefinite time
// -------- A positive value indicates that this creative will be displayed for that many seconds
// --- width is the width of the creative, in pixels
// --- height is the height of the creative, in pixels
// --- trackDisplayAdEvent functions take an enum or string, and cause the tracking URLs associated with those events to be fired
// --- registerTrackingEvent takes a key and list of urls, and adds those urls, associated with the key, as a tracking event to the model
public class CreativeModel {
private static String TAG = CreativeModel.class.getSimpleName();
//internal data
private AdUnitConfiguration adConfiguration;
//helper to get the right creative class
private String name;
private int displayDurationInSeconds = 0;
//all - creative width
private int width = 0;
//all - creative height
private int height = 0;
//all - creative html
private String html;
private JSONObject logData;
@Nullable private Integer refreshMax;
HashMap<TrackingEvent.Events, ArrayList<String>> trackingURLs = new HashMap<>();
protected TrackingManager trackingManager;
protected OmEventTracker omEventTracker;
//all - a unique transaction state of the ad
private String transactionState;
//all - resolved ri url of an ad
private String impressionUrl;
// Determines whether an impression is needed
// For end cards, an impression is not necessary
private boolean requireImpressionUrl = true;
//all - resolved rc url of an ad
private String clickUrl;
private String tracking;
private String targetUrl;
// Flags that the creative is part of a transaction with an end card
// This is important for the display layer to perform end card functions
private boolean hasEndCard = false;
public CreativeModel(
TrackingManager trackingManager,
OmEventTracker omEventTracker,
AdUnitConfiguration adConfiguration
) {
this.trackingManager = trackingManager;
this.adConfiguration = adConfiguration;
this.omEventTracker = omEventTracker;
if (adConfiguration != null) {
setImpressionUrl(adConfiguration.getImpressionUrl());
}
}
//tracking firing here from Model always
public void registerTrackingEvent(TrackingEvent.Events event, ArrayList<String> urls) {
trackingURLs.put(event, urls);
}
//Tracking an event
public void trackDisplayAdEvent(TrackingEvent.Events event) {
handleOmTracking(event);
trackEventNamed(event);
}
public void trackEventNamed(TrackingEvent.Events event) {
ArrayList<String> trackingUrls = trackingURLs.get(event);
if (trackingUrls == null || trackingUrls.isEmpty()) {
LogUtil.debug(TAG, "Event" + event + ": url not found for tracking");
return;
}
//Impression tracker changes
if (event.equals(TrackingEvent.Events.IMPRESSION)) {
trackingManager.fireEventTrackingImpressionURLs(trackingUrls);
}
else {
//for everything else, use standard logic with no redirection check
//clicks(rc), would go through GetOriginalUrlTask path, for any redirection related task
//TODO: Check if we can merge redirection check into our standard BaseNetwork class,
//for all requests(adrequest & recordEvents)
trackingManager.fireEventTrackingURLs(trackingUrls);
}
}
public void registerActiveOmAdSession(OmAdSessionManager omAdSessionManager) {
omEventTracker.registerActiveAdSession(omAdSessionManager);
}
private void handleOmTracking(TrackingEvent.Events event) {
//checking if this click is made on the end card so that we could track it in the scope
//of OM video session
if (hasEndCard && event == TrackingEvent.Events.CLICK) {
omEventTracker.trackOmVideoAdEvent(VideoAdEvent.Event.AD_CLICK);
} else {
omEventTracker.trackOmHtmlAdEvent(event);
}
}
public AdUnitConfiguration getAdConfiguration() {
return adConfiguration;
}
public void setAdConfiguration(AdUnitConfiguration adConfiguration) {
this.adConfiguration = adConfiguration;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getDisplayDurationInSeconds() {
return displayDurationInSeconds;
}
public void setDisplayDurationInSeconds(int displayDurationInSeconds) {
this.displayDurationInSeconds = displayDurationInSeconds;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public String getHtml() {
return html;
}
public void setHtml(String html) {
this.html = html;
}
public void setLogData(JSONObject logData) {
this.logData = logData;
}
public JSONObject getLogData() {
return logData;
}
@Nullable
public Integer getRefreshMax() {
return refreshMax;
}
public void setRefreshMax(
@Nullable
Integer refreshMax) {
this.refreshMax = refreshMax;
}
public String getTransactionState() {
return transactionState;
}
public void setTransactionState(String transactionState) {
this.transactionState = transactionState;
}
public String getImpressionUrl() {
return impressionUrl;
}
public void setImpressionUrl(String impressionUrl) {
this.impressionUrl = impressionUrl;
}
public boolean isRequireImpressionUrl() {
return requireImpressionUrl;
}
public void setRequireImpressionUrl(boolean requireImpressionUrl) {
this.requireImpressionUrl = requireImpressionUrl;
}
public String getClickUrl() {
return clickUrl;
}
public void setClickUrl(String clickUrl) {
this.clickUrl = clickUrl;
}
public String getTracking() {
return tracking;
}
public void setTracking(String tracking) {
this.tracking = tracking;
}
public boolean hasEndCard() {
return hasEndCard;
}
public void setHasEndCard(boolean hasEndCard) {
this.hasEndCard = hasEndCard;
}
public void setTargetUrl(String targetUrl) {
this.targetUrl = targetUrl;
}
public String getTargetUrl() {
return targetUrl;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/CreativeModelMakerBids.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.bidding.data.bid.Bid;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
import org.prebid.mobile.rendering.loading.AdLoadListener;
import org.prebid.mobile.rendering.loading.VastParserExtractor;
import org.prebid.mobile.rendering.models.internal.VastExtractorResult;
import org.prebid.mobile.rendering.networking.tracking.TrackingManager;
import org.prebid.mobile.rendering.video.OmEventTracker;
import java.util.ArrayList;
public class CreativeModelMakerBids {
private static final String TAG = CreativeModelMakerBids.class.getSimpleName();
@NonNull private final AdLoadListener listener;
private final VastParserExtractor parserExtractor = new VastParserExtractor(this::handleExtractorResult);
private AdUnitConfiguration adConfiguration;
public CreativeModelMakerBids(
@NonNull AdLoadListener listener
) {
this.listener = listener;
}
public void makeModels(
AdUnitConfiguration adConfiguration,
BidResponse bidResponse
) {
if (adConfiguration == null) {
notifyErrorListener("Successful ad response but has a null config to continue");
return;
}
if (bidResponse == null || bidResponse.hasParseError()) {
notifyErrorListener("Bid response is null or has an error.");
return;
}
final Bid winningBid = bidResponse.getWinningBid();
if (winningBid == null || TextUtils.isEmpty(winningBid.getAdm())) {
notifyErrorListener("No ad was found.");
return;
}
if (bidResponse.isVideo()) {
makeVideoModels(adConfiguration, winningBid.getAdm());
} else {
parseAcj(adConfiguration, bidResponse);
}
}
public void makeVideoModels(AdUnitConfiguration adConfiguration, String vast) {
this.adConfiguration = adConfiguration;
this.adConfiguration.setAdFormat(AdFormat.VAST);
parserExtractor.extract(vast);
}
public void cancel() {
if (parserExtractor != null) {
parserExtractor.cancel();
}
}
private void notifyErrorListener(String msg) {
listener.onFailedToLoadAd(new AdException(AdException.INTERNAL_ERROR, msg), null);
}
private void parseAcj(AdUnitConfiguration adConfiguration, BidResponse bidResponse) {
CreativeModelsMaker.Result result = new CreativeModelsMaker.Result();
result.creativeModels = new ArrayList<>();
Bid bid = bidResponse.getWinningBid();
String adHtml = getAdHtml(adConfiguration, bid);
CreativeModel model = new CreativeModel(TrackingManager.getInstance(), new OmEventTracker(), adConfiguration);
model.setName("HTML");
model.setHtml(adHtml);
model.setWidth(bid != null ? bid.getWidth() : 0);
model.setHeight(bid != null ? bid.getHeight() : 0);
model.setRequireImpressionUrl(false);
model.setLogData(getLogData(bid));
adConfiguration.setInterstitialSize(model.getWidth(), model.getHeight());
result.creativeModels.add(model);
result.transactionState = "bid";
listener.onCreativeModelReady(result);
}
private JSONObject getLogData(Bid winningBid) {
JSONObject ctxJson = new JSONObject();
try {
if (winningBid != null) {
ctxJson.put("seat", getPrebidBidder(winningBid));
ctxJson.put("domain", getPrebidDomain(winningBid));
ctxJson.put("crid", winningBid.getCrid());
ctxJson.put("dsp_id", getDspId(winningBid));
ctxJson.put("adm", winningBid.getAdm());
ctxJson.put("prebid_ad", true);
}
} catch (JSONException ignored){}
return ctxJson;
}
private static String getPrebidDomain(Bid bid) {
String[] domains = bid.getAdomain();
if (domains != null && domains.length > 0) {
return domains[0];
}
return "";
}
private static String getPrebidBidder(Bid bid) {
String bidder = "";
try {
JSONObject bidJSON = new JSONObject(bid.getJsonString());
bidder = bidJSON.getJSONObject("ext").getJSONObject("prebid").getJSONObject("meta").getString("adaptercode");
} catch (JSONException ignored){}
return bidder;
}
public static int getDspId(Bid bid) {
int dspId = -1;
try {
JSONObject bidJSON = new JSONObject(bid.getJsonString());
dspId = bidJSON.getJSONObject("ext").getInt("dspid");
} catch (JSONException ignored){}
return dspId;
}
private String getAdHtml(AdUnitConfiguration adConfiguration, Bid bid) {
String html = "";
if (bid == null) {
LogUtil.error(TAG, "getAdHtml: Failed. Bid is null. Returning empty string.");
return html;
}
html = bid.getAdm();
return html;
}
private void handleExtractorResult(VastExtractorResult result) {
final String loadIdentifier = result.getLoadIdentifier();
if (result.hasException()) {
listener.onFailedToLoadAd(result.getAdException(), loadIdentifier);
return;
}
CreativeModelsMaker modelsMaker = new CreativeModelsMakerVast(loadIdentifier, listener);
modelsMaker.makeModels(adConfiguration, result.getVastResponseParserArray());
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/CreativeModelsMaker.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.parser.AdResponseParserBase;
import java.util.List;
public abstract class CreativeModelsMaker {
public abstract void makeModels(AdUnitConfiguration adConfiguration, AdResponseParserBase... parsers);
public static class Result {
public String transactionState;
public List<CreativeModel> creativeModels;
public String loaderIdentifier;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/CreativeModelsMakerVast.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import androidx.annotation.NonNull;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.errors.VastParseError;
import org.prebid.mobile.rendering.loading.AdLoadListener;
import org.prebid.mobile.rendering.networking.tracking.TrackingManager;
import org.prebid.mobile.rendering.parser.AdResponseParserBase;
import org.prebid.mobile.rendering.parser.AdResponseParserVast;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.video.OmEventTracker;
import org.prebid.mobile.rendering.video.VideoAdEvent;
import org.prebid.mobile.rendering.video.VideoCreativeModel;
import org.prebid.mobile.rendering.video.vast.Tracking;
import org.prebid.mobile.rendering.video.vast.*;
import java.util.ArrayList;
import static org.prebid.mobile.rendering.parser.AdResponseParserVast.*;
public class CreativeModelsMakerVast extends CreativeModelsMaker {
private static final String TAG = CreativeModelsMakerVast.class.getSimpleName();
public static final String HTML_CREATIVE_TAG = "HTML";
static final String VIDEO_CREATIVE_TAG = "Video";
@NonNull private final AdLoadListener listener;
private AdUnitConfiguration adConfiguration;
private AdResponseParserVast rootVastParser;
private AdResponseParserVast latestVastWrapperParser;
private String adLoaderIdentifier;
public CreativeModelsMakerVast(
String adLoaderIdentifier,
@NonNull AdLoadListener listener
) {
this.listener = listener;
this.adLoaderIdentifier = adLoaderIdentifier;
}
@Override
public void makeModels(AdUnitConfiguration adConfiguration, AdResponseParserBase... parsers) {
if (adConfiguration == null) {
notifyErrorListener("Successful ad response but has a null config to continue ");
return;
}
this.adConfiguration = adConfiguration;
if (parsers == null) {
notifyErrorListener("Parsers results are null.");
return;
}
if (parsers.length != 2) {
notifyErrorListener("2 VAST result parsers are required");
return;
}
rootVastParser = (AdResponseParserVast) parsers[0];
latestVastWrapperParser = (AdResponseParserVast) parsers[1];
if (rootVastParser == null || latestVastWrapperParser == null) {
notifyErrorListener("One of parsers is null.");
return;
}
makeModelsContinued();
}
private void makeModelsContinued() {
try {
// TODO: If we want to support a VAST Buffet, we'll need to put the following in a
// TODO: loop and make a model for each Ad object in the Buffet
// TODO: Until then, we'll only make one model
/***
* We pre parse the impressions and trackings for faster reading at
* video time. DO NOT REMOVE THESE LINES
*/
rootVastParser.getAllTrackings(rootVastParser, 0);
rootVastParser.getImpressions(rootVastParser, 0);
rootVastParser.getClickTrackings(rootVastParser, 0);
final String videoErrorUrl = rootVastParser.getError(rootVastParser, 0);
final String vastClickThroughUrl = rootVastParser.getClickThroughUrl(rootVastParser, 0);
final String videoDuration = latestVastWrapperParser.getVideoDuration(latestVastWrapperParser, 0);
final String skipOffset = latestVastWrapperParser.getSkipOffset(latestVastWrapperParser, 0);
final AdVerifications adVerifications = rootVastParser.getAdVerification(latestVastWrapperParser, 0);
checkVideoDuration(Utils.getMsFrom(videoDuration));
Result result = new Result();
result.loaderIdentifier = adLoaderIdentifier;
TrackingManager trackingManager = TrackingManager.getInstance();
OmEventTracker omEventTracker = new OmEventTracker();
VideoCreativeModel videoModel = new VideoCreativeModel(trackingManager, omEventTracker, adConfiguration);
videoModel.setName(VIDEO_CREATIVE_TAG);
videoModel.setMediaUrl(latestVastWrapperParser.getMediaFileUrl(latestVastWrapperParser, 0));
videoModel.setMediaDuration(Utils.getMsFrom(videoDuration));
videoModel.setSkipOffset(Utils.getMsFrom(skipOffset));
videoModel.setAdVerifications(adVerifications);
videoModel.setAuid(rootVastParser.getVast().getAds().get(0).getId());
videoModel.setWidth(latestVastWrapperParser.getWidth());
videoModel.setHeight(latestVastWrapperParser.getHeight());
//put tracking urls into element.
for (VideoAdEvent.Event videoEvent : VideoAdEvent.Event.values()) {
videoModel.getVideoEventUrls().put(videoEvent, rootVastParser.getTrackingByType(videoEvent));
}
//put impression urls into element
ArrayList<String> impUrls = new ArrayList<>();
for (Impression impression : rootVastParser.getImpressions()) {
impUrls.add(impression.getValue());
}
videoModel.getVideoEventUrls().put(VideoAdEvent.Event.AD_IMPRESSION, impUrls);
//put click urls into element
ArrayList<String> clickTrackingUrls = new ArrayList<>();
for (ClickTracking clickTracking : rootVastParser.getClickTrackings()) {
clickTrackingUrls.add(clickTracking.getValue());
}
videoModel.getVideoEventUrls().put(VideoAdEvent.Event.AD_CLICK, clickTrackingUrls);
//put error vastURL into element
ArrayList<String> errorUrls = new ArrayList<>();
errorUrls.add(videoErrorUrl);
videoModel.getVideoEventUrls().put(VideoAdEvent.Event.AD_ERROR, errorUrls);
//put click through url into element
videoModel.setVastClickthroughUrl(vastClickThroughUrl);
result.creativeModels = new ArrayList<>();
result.creativeModels.add(videoModel);
CreativeModel endCardModel = new CreativeModel(trackingManager, omEventTracker, adConfiguration);
endCardModel.setName(HTML_CREATIVE_TAG);
endCardModel.setHasEndCard(true);
// Create CompanionAd object
Companion companionAd = AdResponseParserVast.getCompanionAd(latestVastWrapperParser.getVast()
.getAds()
.get(0)
.getInline());
if (companionAd != null) {
switch (AdResponseParserVast.getCompanionResourceFormat(companionAd)) {
case RESOURCE_FORMAT_HTML:
endCardModel.setHtml(companionAd.getHtmlResource().getValue());
break;
case RESOURCE_FORMAT_IFRAME:
endCardModel.setHtml(companionAd.getIFrameResource().getValue());
break;
case RESOURCE_FORMAT_STATIC:
endCardModel.setHtml(String.format("<div id=\"ad\" align=\"center\">\n"
+ "<a href=\"%s\">\n"
+ "<img src=\"%s\"></a>\n"
+ "</div>",
companionAd.getCompanionClickThrough().getValue(),
companionAd.getStaticResource().getValue()));
break;
}
if (companionAd.getCompanionClickThrough() != null) {
endCardModel.setClickUrl(companionAd.getCompanionClickThrough().getValue());
}
if (companionAd.getCompanionClickTracking() != null) {
clickTrackingUrls = new ArrayList<>();
clickTrackingUrls.add(companionAd.getCompanionClickTracking().getValue());
endCardModel.registerTrackingEvent(TrackingEvent.Events.CLICK, clickTrackingUrls);
}
Tracking creativeViewTracking = AdResponseParserVast.findTracking(companionAd.getTrackingEvents());
if (creativeViewTracking != null && Utils.isNotBlank(creativeViewTracking.getValue())) {
ArrayList<String> creativeViewTrackingUrls = new ArrayList<>();
creativeViewTrackingUrls.add(creativeViewTracking.getValue());
endCardModel.registerTrackingEvent(TrackingEvent.Events.IMPRESSION, creativeViewTrackingUrls);
}
endCardModel.setWidth(Integer.parseInt(companionAd.getWidth()));
endCardModel.setHeight(Integer.parseInt(companionAd.getHeight()));
endCardModel.setAdConfiguration(new AdUnitConfiguration());
endCardModel.getAdConfiguration().setAdFormat(AdFormat.INTERSTITIAL);
endCardModel.setRequireImpressionUrl(false);
result.creativeModels.add(endCardModel);
// Flag that video creative has a corresponding end card
videoModel.setHasEndCard(true);
}
adConfiguration.setInterstitialSize(videoModel.getWidth() + "x" + videoModel.getHeight());
listener.onCreativeModelReady(result);
} catch (Exception e) {
LogUtil.error(TAG, "Video failed with: " + e.getMessage());
notifyErrorListener("Video failed: " + e.getMessage());
}
}
private void notifyErrorListener(String msg) {
listener.onFailedToLoadAd(new AdException(AdException.INTERNAL_ERROR, msg), adLoaderIdentifier);
}
private void checkVideoDuration(long currentDuration) throws VastParseError {
if (adConfiguration != null && adConfiguration.getMaxVideoDuration() != null) {
long maxDuration = adConfiguration.getMaxVideoDuration() * 1000;
if (currentDuration > maxDuration) {
throw new VastParseError("Video duration can't be more then ad unit max video duration: " + maxDuration + " (current duration: " + currentDuration + ")");
}
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/CreativeVisibilityTracker.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.ViewTreeObserver;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption;
import org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult;
import org.prebid.mobile.rendering.utils.exposure.ViewExposure;
import org.prebid.mobile.rendering.utils.exposure.ViewExposureChecker;
import org.prebid.mobile.rendering.utils.helpers.VisibilityChecker;
import org.prebid.mobile.rendering.views.webview.mraid.Views;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
public class CreativeVisibilityTracker {
private static final String TAG = CreativeVisibilityTracker.class.getSimpleName();
// Time interval to use for throttling visibility checks.
private static final int VISIBILITY_THROTTLE_MILLIS = 200;
public interface VisibilityTrackerListener {
void onVisibilityChanged(VisibilityTrackerResult result);
}
private ViewTreeObserver.OnPreDrawListener onPreDrawListener;
private WeakReference<ViewTreeObserver> weakViewTreeObserver;
private WeakReference<View> trackedView;
private final List<VisibilityChecker> visibilityCheckerList = new ArrayList<>();
@VisibleForTesting protected Runnable visibilityRunnable;
private Handler visibilityHandler;
private VisibilityTrackerListener visibilityTrackerListener;
private boolean proceedAfterImpTracking;
private boolean isVisibilityScheduled;
public CreativeVisibilityTracker(
@NonNull final View trackedView,
final Set<VisibilityTrackerOption> visibilityTrackerOptionSet
) {
if (trackedView == null) {
LogUtil.debug(TAG, "Tracked view can't be null");
return;
}
this.trackedView = new WeakReference<>(trackedView);
final ViewExposureChecker viewExposureChecker = new ViewExposureChecker();
for (VisibilityTrackerOption trackingOption : visibilityTrackerOptionSet) {
visibilityCheckerList.add(new VisibilityChecker(trackingOption, viewExposureChecker));
}
visibilityHandler = new Handler(Looper.getMainLooper());
visibilityRunnable = createVisibilityRunnable();
onPreDrawListener = () -> {
scheduleVisibilityCheck();
return true;
};
weakViewTreeObserver = new WeakReference<>(null);
}
public CreativeVisibilityTracker(
@NonNull
final View trackedView,
final Set<VisibilityTrackerOption> visibilityTrackerOptionSet,
boolean proceedAfterImpTracking) {
this(trackedView, visibilityTrackerOptionSet);
this.proceedAfterImpTracking = proceedAfterImpTracking;
}
public CreativeVisibilityTracker(
@NonNull
final View trackedView,
final VisibilityTrackerOption visibilityTrackerOption) {
this(trackedView, Collections.singleton(visibilityTrackerOption));
}
public CreativeVisibilityTracker(
@NonNull
final View trackedView,
final VisibilityTrackerOption visibilityTrackerOption,
boolean proceedAfterImpTracking) {
this(trackedView, Collections.singleton(visibilityTrackerOption), proceedAfterImpTracking);
}
private void setViewTreeObserver(
@Nullable
final Context context,
@Nullable
final View view) {
final ViewTreeObserver originalViewTreeObserver = weakViewTreeObserver.get();
if (originalViewTreeObserver != null && originalViewTreeObserver.isAlive()) {
LogUtil.debug(TAG, "Original ViewTreeObserver is still alive.");
return;
}
final View rootView = Views.getTopmostView(context, view);
if (rootView == null) {
LogUtil.debug(TAG, "Unable to set Visibility Tracker due to no available root view.");
return;
}
final ViewTreeObserver viewTreeObserver = rootView.getViewTreeObserver();
if (!viewTreeObserver.isAlive()) {
LogUtil.debug(
TAG,
"Visibility Tracker was unable to track views because the" + " root view tree observer was not alive"
);
return;
}
weakViewTreeObserver = new WeakReference<>(viewTreeObserver);
viewTreeObserver.addOnPreDrawListener(onPreDrawListener);
}
public void setVisibilityTrackerListener(
@Nullable
final VisibilityTrackerListener visibilityTrackerListener) {
this.visibilityTrackerListener = visibilityTrackerListener;
}
public void startVisibilityCheck(Context context) {
if (trackedView == null || trackedView.get() == null) {
LogUtil.error(TAG, "Couldn't start visibility check. Target view is null");
return;
}
setViewTreeObserver(context, trackedView.get());
}
public void stopVisibilityCheck() {
visibilityHandler.removeCallbacksAndMessages(null);
isVisibilityScheduled = false;
final ViewTreeObserver viewTreeObserver = weakViewTreeObserver.get();
if (viewTreeObserver != null && viewTreeObserver.isAlive()) {
viewTreeObserver.removeOnPreDrawListener(onPreDrawListener);
}
weakViewTreeObserver.clear();
}
void scheduleVisibilityCheck() {
// Tracking this directly instead of calling hasMessages directly because we measured that
// this led to slightly better performance.
if (isVisibilityScheduled) {
return;
}
isVisibilityScheduled = true;
visibilityHandler.postDelayed(visibilityRunnable, VISIBILITY_THROTTLE_MILLIS);
}
private Runnable createVisibilityRunnable() {
return () -> {
View trackedView = this.trackedView.get();
if (trackedView == null) {
stopVisibilityCheck();
return;
}
if (allImpressionsFired() && !proceedAfterImpTracking) {
return;
}
for (VisibilityChecker visibilityChecker : visibilityCheckerList) {
isVisibilityScheduled = false;
ViewExposure viewExposure = visibilityChecker.checkViewExposure(trackedView);
boolean shouldFireImpression = false;
boolean isVisible = visibilityChecker.isVisible(trackedView, viewExposure);
// If the view meets the dips count requirement for visibility, then also check the
// duration requirement for visibility.
VisibilityTrackerOption visibilityTrackerOption = visibilityChecker.getVisibilityTrackerOption();
if (isVisible) {
if (!visibilityChecker.hasBeenVisible()) {
visibilityChecker.setStartTimeMillis();
}
if (visibilityChecker.hasRequiredTimeElapsed()) {
shouldFireImpression = !visibilityTrackerOption.isImpressionTracked();
visibilityTrackerOption.setImpressionTracked(true);
}
}
VisibilityTrackerResult visibilityTrackerResult = new VisibilityTrackerResult(
visibilityTrackerOption.getEventType(),
viewExposure,
isVisible,
shouldFireImpression
);
notifyListener(visibilityTrackerResult);
}
// If visibility requirements are not met or the target is MRAID, check again later.
if (!allImpressionsFired() || proceedAfterImpTracking) {
scheduleVisibilityCheck();
}
};
}
private void notifyListener(VisibilityTrackerResult visibilityTrackerResult) {
if (visibilityTrackerListener != null) {
visibilityTrackerListener.onVisibilityChanged(visibilityTrackerResult);
}
}
private boolean allImpressionsFired() {
for (VisibilityChecker visibilityChecker : visibilityCheckerList) {
final VisibilityTrackerOption visibilityTrackerOption = visibilityChecker.getVisibilityTrackerOption();
if (!visibilityTrackerOption.isImpressionTracked()) {
return false;
}
}
return true;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/HTMLCreative.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.ContentObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.interstitial.InterstitialManagerDisplayDelegate;
import org.prebid.mobile.rendering.listeners.CreativeViewListener;
import org.prebid.mobile.rendering.listeners.WebViewDelegate;
import org.prebid.mobile.rendering.models.internal.MraidEvent;
import org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption;
import org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult;
import org.prebid.mobile.rendering.models.ntv.NativeEventTracker;
import org.prebid.mobile.rendering.mraid.methods.MraidController;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import org.prebid.mobile.rendering.utils.exposure.ViewExposure;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewBase;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
import java.util.EnumSet;
public class HTMLCreative extends AbstractCreative implements WebViewDelegate, InterstitialManagerDisplayDelegate, Comparable {
private static final String TAG = HTMLCreative.class.getSimpleName();
private MraidController mraidController;
private PrebidWebViewBase twoPartNewWebViewBase;
private boolean isEndCard = false;
private boolean resolved;
public HTMLCreative(
Context context,
CreativeModel model,
OmAdSessionManager omAdSessionManager,
InterstitialManager interstitialManager
) throws AdException {
super(context, model, omAdSessionManager, interstitialManager);
this.interstitialManager.setInterstitialDisplayDelegate(this);
mraidController = new MraidController(this.interstitialManager);
}
@Override
public boolean isDisplay() {
return true;
}
@Override
public boolean isVideo() {
return false;
}
@Override
public void load() throws AdException {
if (contextReference == null || contextReference.get() == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Context is null. Could not load adHtml");
}
CreativeModel model = getCreativeModel();
EnumSet<AdFormat> adFormats = model.getAdConfiguration().getAdFormats();
if (adFormats.isEmpty()) {
throw new AdException(AdException.INTERNAL_ERROR, "Can't create a WebView for a null adtype");
}
AdFormat adType = adFormats.iterator().next();
if (model.getAdConfiguration().isBuiltInVideo()) {
adType = AdFormat.BANNER;
}
PrebidWebViewBase prebidWebView = null;
if (adType == AdFormat.BANNER) {
//do all banner
prebidWebView = (PrebidWebViewBanner) ViewPool.getInstance()
.getUnoccupiedView(contextReference.get(),
null,
adType,
interstitialManager
);
} else if (adType == AdFormat.INTERSTITIAL) {
//do all interstitials
prebidWebView = (PrebidWebViewInterstitial) ViewPool.getInstance()
.getUnoccupiedView(contextReference.get(),
null,
adType,
interstitialManager
);
}
if (prebidWebView == null) {
throw new AdException(AdException.INTERNAL_ERROR, "PrebidWebView creation failed");
}
prebidWebView.setWebViewDelegate(this);
prebidWebView.setCreative(this);
String html = model.getHtml();
int width = model.getWidth();
int height = model.getHeight();
if (TextUtils.isEmpty(html)) {
String msg = "No HTML in creative data";
LogUtil.error(TAG, msg);
throw new AdException(AdException.SERVER_ERROR, msg);
}
else {
html = injectingScriptContent(html);
prebidWebView.loadHTML(html, width, height);
setCreativeView(prebidWebView);
}
isEndCard = model.hasEndCard();
}
@Override
public void display() {
if (!(getCreativeView() instanceof PrebidWebViewBase)) {
LogUtil.error(TAG, "Could not cast creativeView to a PrebidWebViewBase");
return;
}
PrebidWebViewBase creativeWebView = (PrebidWebViewBase) getCreativeView();
// Fire impression
if (!PrebidMobile.isViewabilityV3()) {
startViewabilityTracker();
}
}
@Override
public void createOmAdSession() {
if (getCreativeView() == null || getCreativeView().getWebView() == null) {
LogUtil.error(TAG, "initOmAdSession error. Opex webView is null");
return;
}
OmAdSessionManager omAdSessionManager = weakOmAdSessionManager.get();
if (omAdSessionManager == null) {
LogUtil.error(TAG, "Error creating adSession. OmAdSessionManager is null");
return;
}
WebViewBase webView = getCreativeView().getWebView();
AdUnitConfiguration adConfiguration = getCreativeModel().getAdConfiguration();
ContentObject contentObject = adConfiguration.getAppContent();
String contentUrl = null;
if (contentObject != null) contentUrl = contentObject.getUrl();
omAdSessionManager.initWebAdSessionManager(webView, contentUrl);
startOmSession(omAdSessionManager, webView);
}
@Override
public void trackAdLoaded() {
CreativeModel creativeModel = getCreativeModel();
creativeModel.trackDisplayAdEvent(TrackingEvent.Events.LOADED);
}
@Override
public void startViewabilityTracker() {
VisibilityTrackerOption visibilityTrackerOption = new VisibilityTrackerOption(NativeEventTracker.EventType.IMPRESSION);
creativeVisibilityTracker = new CreativeVisibilityTracker(getCreativeView().getWebView(),
visibilityTrackerOption,
((PrebidWebViewBase) getCreativeView()).getWebView().isMRAID()
);
creativeVisibilityTracker.setVisibilityTrackerListener(this::onVisibilityEvent);
creativeVisibilityTracker.startVisibilityCheck(contextReference.get());
}
public void startViewabilityTrackerV2() {
if (PrebidMobile.isViewabilityV3()) {
startViewabilityTracker();
PrebidWebViewBase webView = getCreativeView();
if (webView != null) {
webView.executeOnViewableChange();
}
}
}
@Override
public void handleAdWindowFocus() {
}
@Override
public void handleAdWindowNoFocus() {
}
@Override
public void webViewReadyToDisplay() {
if (resolved) {
return;
}
resolved = true;
getResolutionListener().creativeReady(this);
}
@Override
public void webViewFailedToLoad(AdException error) {
if (resolved) {
return;
}
resolved = true;
getResolutionListener().creativeFailed(error);
}
//Used by non-mraid banners
@Override
public void webViewShouldOpenExternalLink(String url) {
//open in the browser, send to pub & track click
if (getCreativeView() != null) {
getCreativeView().handleOpen(url);
}
}
@Override
public void webViewShouldOpenMRAIDLink(String url) {
//open happens directly from the basejsinterface
//send it to the pub
getCreativeViewListener().creativeWasClicked(this, url);
//track click of an ad. This has to happen for mraid.open() & mraid.expand() commands. MOBILE-3327
getCreativeView().post(() -> getCreativeModel().trackDisplayAdEvent(TrackingEvent.Events.CLICK));
}
@Override
public void interstitialAdClosed() {
LogUtil.debug(TAG, "MRAID Expand/Resize is closing.");
//For mraid banner, this is same as mraidAdCollapsed
//For mraid interstitials with custom
if (getCreativeViewListener() != null) {
getCreativeViewListener().creativeInterstitialDidClose(this);
}
}
@Override
public void interstitialDialogShown(ViewGroup rootViewGroup) {
CreativeViewListener creativeViewListener = getCreativeViewListener();
if (creativeViewListener == null) {
LogUtil.debug(TAG, "interstitialDialogShown(): Failed to notify creativeViewListener. creativeViewListener is null.");
return;
}
creativeViewListener.creativeInterstitialDialogShown(rootViewGroup);
}
@Override
public int compareTo(Object creative) {
if (creative.hashCode() > hashCode()) {
return 1;
}
return 0;
}
@Override
public PrebidWebViewBase getCreativeView() {
return (PrebidWebViewBase) super.getCreativeView();
}
public void mraidAdExpanded() {
LogUtil.debug(TAG, "MRAID ad expanded");
//send callback to pubs when an internal browser is closed
if (getCreativeViewListener() != null) {
getCreativeViewListener().creativeDidExpand(this);
}
}
@VisibleForTesting
void onVisibilityEvent(VisibilityTrackerResult result) {
boolean isViewable = result.isVisible();
boolean shouldFireImpression = result.shouldFireImpression();
ViewExposure viewExposure = result.getViewExposure();
if (shouldFireImpression && isViewable) {
LogUtil.debug(TAG, "Impression fired");
getCreativeModel().trackDisplayAdEvent(TrackingEvent.Events.IMPRESSION);
}
getCreativeView().onWindowFocusChanged(isViewable);
getCreativeView().onViewExposureChange(viewExposure);
}
/**
* @return true if WebView is resolved (loaded or failed to load callback triggered), false otherwise.
*/
public boolean isResolved() {
return resolved;
}
/**
* @return true if creative is an endcard, false otherwise.
*/
@Override
public boolean isEndCard() {
return isEndCard;
}
public void destroy() {
super.destroy();
if (getCreativeView() != null) {
getCreativeView().destroy();
}
if (mraidController != null) {
mraidController.destroy();
}
ViewPool.getInstance().clear();
}
public void mraidAdCollapsed() {
LogUtil.debug(TAG, "MRAID ad collapsed");
if (getCreativeViewListener() != null) {
getCreativeViewListener().creativeDidCollapse(this);
}
}
public void handleMRAIDEventsInCreative(final MraidEvent mraidEvent, final WebViewBase oldWebViewBase) {
if (mraidController == null) {
mraidController = new MraidController(interstitialManager);
}
mraidController.handleMraidEvent(mraidEvent, this, oldWebViewBase, twoPartNewWebViewBase);
}
/**
* Injects OM script content into HTML
*
* @param html creative html content
* @return html with injected OMSDK script or non modified creative html content if failure.
*/
private String injectingScriptContent(String html) {
try {
OmAdSessionManager omAdSessionManager = weakOmAdSessionManager.get();
if (omAdSessionManager == null) {
LogUtil.debug(TAG, "Unable to injectScriptContent. AdSessionManager is null.");
return html;
}
return omAdSessionManager.injectValidationScriptIntoHtml(html);
}
catch (IllegalArgumentException | IllegalStateException e) {
LogUtil.error(TAG, "Failed to inject script content into html " + Log.getStackTraceString(e));
return html;
}
}
public void setTwoPartNewWebViewBase(PrebidWebViewBase twoPartNewWebViewBase) {
this.twoPartNewWebViewBase = twoPartNewWebViewBase;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/InterstitialDisplayPropertiesInternal.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import android.content.pm.ActivityInfo;
import org.prebid.mobile.api.data.Position;
public class InterstitialDisplayPropertiesInternal extends InterstitialDisplayPropertiesPublic {
public int expandWidth;
public int expandHeight;
public int orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
public int skipDelay = 0;
public double closeButtonArea = 0;
public double skipButtonArea = 0;
public boolean isSoundButtonVisible = false;
public boolean isMuted = false;
public boolean isRotationEnabled = false;
public Position closeButtonPosition = Position.TOP_RIGHT;
public Position skipButtonPosition = Position.TOP_RIGHT;
public void resetExpandValues() {
expandHeight = 0;
expandWidth = 0;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/InterstitialDisplayPropertiesPublic.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import android.graphics.Color;
public class InterstitialDisplayPropertiesPublic {
// this is the default system dim for dialogs
private int dimColor = Color.argb(153, 0, 0, 0);
/**
* Returns the background opacity set for an interstitial ad
*
* @return
*/
public int getPubBackGroundOpacity() {
return dimColor;
}
/**
* Sets the background opacity for an interstitial ad
* Recommended is 1.0f
*
* @param dim
*/
public void setPubBackGroundOpacity(float dim) {
int alpha;
float dimAmount;
if (dim < 0.0f) {
dimAmount = 0.0f;
}
else if (dim > 1.0f) {
dimAmount = 1.0f;
}
else {
dimAmount = dim;
}
alpha = (int) (255 * dimAmount);
dimColor = Color.argb(alpha, 0, 0, 0);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/InterstitialLayout.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import android.content.pm.ActivityInfo;
public enum InterstitialLayout {
LANDSCAPE(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE),
PORTRAIT(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT),
ROTATABLE(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT),
UNDEFINED(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
private int orientation;
InterstitialLayout(int orientation) {
this.orientation = orientation;
}
public int getOrientation() {
return orientation;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/PlacementType.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
public enum PlacementType {
UNDEFINED(-1),
IN_BANNER(2),
IN_ARTICLE(3),
IN_FEED(4),
INTERSTITIAL(5);
private final int value;
PlacementType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/TrackingEvent.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
public class TrackingEvent {
public enum Events {
DEFAULT,
IMPRESSION,
CLICK,
LOADED
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/ViewPool.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.listeners.VideoCreativeViewListener;
import org.prebid.mobile.rendering.video.ExoPlayerView;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial;
import org.prebid.mobile.rendering.views.webview.mraid.Views;
import java.util.ArrayList;
public class ViewPool {
@SuppressLint("StaticFieldLeak") private static ViewPool sInstance = null;
private ArrayList<View> occupiedViews = new ArrayList<>();
private ArrayList<View> unoccupiedViews = new ArrayList<>();
private ViewPool() {
}
public static ViewPool getInstance() {
if (sInstance == null) {
sInstance = new ViewPool();
}
return sInstance;
}
protected int sizeOfOccupied() {
return occupiedViews.size();
}
protected int sizeOfUnoccupied() {
return unoccupiedViews.size();
}
//This will add views into occupied bucket
public void addToOccupied(View view) {
if (!occupiedViews.contains(view) && !unoccupiedViews.contains(view)) {
occupiedViews.add(view);
}
}
public void addToUnoccupied(View view) {
if (!unoccupiedViews.contains(view) && !occupiedViews.contains(view)) {
unoccupiedViews.add(view);
}
}
//This will swap from occupied to unoccupied(after windowclose) and removes it from occupied bucket
public void swapToUnoccupied(View view) {
if (!unoccupiedViews.contains(view)) {
unoccupiedViews.add(view);
Views.removeFromParent(view);
}
occupiedViews.remove(view);
}
//This will swap from unoccupied to occupied(after showing/displaying) and removes it from unoccupied bucket
private void swapToOccupied(View view) {
if (!occupiedViews.contains(view)) {
occupiedViews.add(view);
}
unoccupiedViews.remove(view);
}
//This only clears the bucketlist. It does not actually remove the lists. Means (size becomes 0 but list still exists)
public void clear() {
occupiedViews.clear();
unoccupiedViews.clear();
plugPlayView = null;
}
private View plugPlayView;
//Q: why are we keeping it in occupied? Should we not put/get from unoccupied directly?
//A: Because, when a videoCreativeView is created, we will have to, anyways, add the view to the occupied bucket as it is going to be given to adView.
//So, do that step here itself.(distribution of work!)
public View getUnoccupiedView(Context context, VideoCreativeViewListener videoCreativeViewListener, AdFormat adType, InterstitialManager interstitialManager)
throws AdException {
if (context == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Context is null");
}
if (unoccupiedViews != null && unoccupiedViews.size() > 0) {
View view = unoccupiedViews.get(0);
Views.removeFromParent(view);
//get item from unoccupied & add it to occupied
swapToOccupied(view);
return occupiedViews.get(occupiedViews.size() - 1);
}
//create a new one
//add it to occupied
switch (adType) {
case BANNER:
plugPlayView = new PrebidWebViewBanner(context, interstitialManager);
break;
case INTERSTITIAL:
plugPlayView = new PrebidWebViewInterstitial(context, interstitialManager);
//add it to occupied
break;
case VAST:
plugPlayView = new ExoPlayerView(context, videoCreativeViewListener);
break;
}
addToOccupied(plugPlayView);
return plugPlayView;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/internal/InternalFriendlyObstruction.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.internal;
import android.view.View;
import java.lang.ref.WeakReference;
public class InternalFriendlyObstruction {
private WeakReference<View> viewWeakReference;
private InternalFriendlyObstruction.Purpose friendlyObstructionPurpose;
private String detailedDescription;
public InternalFriendlyObstruction(
View view,
InternalFriendlyObstruction.Purpose friendlyObstructionPurpose,
String detailedDescription
) {
viewWeakReference = new WeakReference<>(view);
this.friendlyObstructionPurpose = friendlyObstructionPurpose;
this.detailedDescription = detailedDescription;
}
public View getView() {
return viewWeakReference.get();
}
public InternalFriendlyObstruction.Purpose getPurpose() {
return friendlyObstructionPurpose;
}
public String getDetailedDescription() {
return detailedDescription;
}
public enum Purpose {
CLOSE_AD,
OTHER,
VIDEO_CONTROLS
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/internal/InternalPlayerState.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.internal;
public enum InternalPlayerState {
NORMAL,
EXPANDED,
FULLSCREEN
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/internal/MacrosModel.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.internal;
import androidx.annotation.NonNull;
public class MacrosModel {
public static final String MACROS_AUCTION_PRICE = "\\$\\{AUCTION_PRICE\\}";
public static final String MACROS_AUCTION_PRICE_BASE_64 = "\\$\\{AUCTION_PRICE:B64\\}";
private static final String MACROS_DEFAULT_VALUE = "\\\\\"\\\\\""; //String representation of "\"\""
private final String replaceValue;
public MacrosModel(String replaceValue) {
this.replaceValue = replaceValue;
}
@NonNull
public String getReplaceValue() {
return replaceValue == null ? MACROS_DEFAULT_VALUE : replaceValue;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MacrosModel that = (MacrosModel) o;
return replaceValue != null ? replaceValue.equals(that.replaceValue) : that.replaceValue == null;
}
@Override
public int hashCode() {
return replaceValue != null ? replaceValue.hashCode() : 0;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/internal/MraidEvent.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.internal;
public class MraidEvent {
//name of the action(for debug only)
public String mraidAction;
//helper like url etc, to perform the action
public String mraidActionHelper;
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/internal/MraidVariableContainer.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.internal;
import android.text.TextUtils;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.utils.helpers.MraidUtils;
public class MraidVariableContainer {
private static final String TAG = MraidVariableContainer.class.getSimpleName();
private static final int SMS = 1;
private static final int TEL = 2;
private static final int CALENDAR = 4;
private static final int STORE_PICTURE = 8;
private static final int INLINE_VIDEO = 16;
private static final int LOCATION = 32;
private static final int VPAID = 64;
private static String sDisabledFlags = null;
private String urlForLaunching;
private String expandProperties;
private String orientationProperties;
private String currentState;
private String currentExposure;
private Boolean currentViewable = null;
public String getUrlForLaunching() {
return urlForLaunching == null ? "" : urlForLaunching;
}
public void setUrlForLaunching(String urlForLaunching) {
this.urlForLaunching = urlForLaunching;
}
public String getExpandProperties() {
return expandProperties;
}
public void setExpandProperties(String expandProperties) {
this.expandProperties = expandProperties;
}
public String getOrientationProperties() {
return orientationProperties;
}
public void setOrientationProperties(String orientationProperties) {
this.orientationProperties = orientationProperties;
}
public boolean isLaunchedWithUrl() {
return !TextUtils.isEmpty(urlForLaunching);
}
public static void setDisabledFlags(String disabledFlags) {
sDisabledFlags = disabledFlags;
}
public static String getDisabledFlags() {
return sDisabledFlags;
}
public String getCurrentState() {
return currentState;
}
public void setCurrentState(String currentState) {
this.currentState = currentState;
}
public String getCurrentExposure() {
return currentExposure;
}
public void setCurrentExposure(String currentExposure) {
this.currentExposure = currentExposure;
}
public Boolean getCurrentViewable() {
return currentViewable;
}
public void setCurrentViewable(Boolean currentViewable) {
this.currentViewable = currentViewable;
}
/**
* Internal SDK use only
*/
public static void setDisabledSupportFlags(int flags) {
String[] features = {
"sms",
"tel",
"calendar",
"storePicture",
"inlineVideo",
"location",
"vpaid"};
int[] vars = {SMS, TEL, CALENDAR, STORE_PICTURE, INLINE_VIDEO, LOCATION, VPAID};
StringBuilder disabledFlags = new StringBuilder();
disabledFlags.append("mraid.allSupports = {");
for (int i = 0; i < features.length; i++) {
disabledFlags.append(features[i]);
disabledFlags.append(":");
disabledFlags.append((flags & vars[i]) == vars[i]
? "false"
: MraidUtils.isFeatureSupported(features[i]));
if (i < features.length - 1) {
disabledFlags.append(",");
}
}
disabledFlags.append("};");
LogUtil.debug(TAG, "Supported features: " + disabledFlags.toString());
setDisabledFlags(disabledFlags.toString());
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/internal/VastExtractorResult.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.internal;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.parser.AdResponseParserBase;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import java.util.Arrays;
public class VastExtractorResult {
private final String loadIdentifier = String.valueOf(Utils.generateRandomInt());
private AdException adException;
private AdResponseParserBase[] vastResponseParserArray;
public VastExtractorResult(AdResponseParserBase[] vastResponseParserArray) {
this.vastResponseParserArray = vastResponseParserArray;
}
public VastExtractorResult(AdException adException) {
this.adException = adException;
}
public AdException getAdException() {
return adException;
}
public String getLoadIdentifier() {
return loadIdentifier;
}
public AdResponseParserBase[] getVastResponseParserArray() {
return vastResponseParserArray;
}
public boolean hasException() {
return adException != null;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
VastExtractorResult that = (VastExtractorResult) o;
return loadIdentifier != null ? loadIdentifier.equals(that.loadIdentifier) : that.loadIdentifier == null;
}
@Override
public int hashCode() {
int result = loadIdentifier != null ? loadIdentifier.hashCode() : 0;
result = 31 * result + (adException != null ? adException.hashCode() : 0);
result = 31 * result + Arrays.hashCode(vastResponseParserArray);
return result;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/internal/VisibilityTrackerOption.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.internal;
import org.prebid.mobile.rendering.models.ntv.NativeEventTracker;
public class VisibilityTrackerOption {
private NativeEventTracker.EventType eventType;
private int minimumVisibleMillis;
private int minVisibilityPercentage;
private boolean isImpressionTracked;
private long startTimeMillis = Long.MIN_VALUE;
public VisibilityTrackerOption(
NativeEventTracker.EventType eventType,
int minimumVisibleMillis,
int minVisibilityPercentage
) {
this.eventType = eventType;
this.minimumVisibleMillis = minimumVisibleMillis;
this.minVisibilityPercentage = minVisibilityPercentage;
}
public VisibilityTrackerOption(NativeEventTracker.EventType eventType) {
this.eventType = eventType;
minimumVisibleMillis = getMinimumVisibleMillis(eventType);
minVisibilityPercentage = getMinimumVisiblePercents(eventType);
}
public static int getMinimumVisibleMillis(NativeEventTracker.EventType eventType) {
switch (eventType) {
case IMPRESSION:
case OMID:
return 0;
case VIEWABLE_MRC50:
case VIEWABLE_MRC100:
return 1000;
case VIEWABLE_VIDEO50:
return 2000;
}
return 0;
}
public static int getMinimumVisiblePercents(NativeEventTracker.EventType eventType) {
switch (eventType) {
case IMPRESSION:
case OMID:
return 1;
case VIEWABLE_MRC50:
case VIEWABLE_VIDEO50:
return 50;
case VIEWABLE_MRC100:
return 100;
}
return 0;
}
public boolean isType(NativeEventTracker.EventType eventType) {
return this.eventType.equals(eventType);
}
public void setStartTimeMillis(long startTimeMillis) {
this.startTimeMillis = startTimeMillis;
}
public long getStartTimeMillis() {
return startTimeMillis;
}
public int getMinimumVisibleMillis() {
return minimumVisibleMillis;
}
public void setMinimumVisibleMillis(int minimumVisibleMillis) {
this.minimumVisibleMillis = minimumVisibleMillis;
}
public int getMinVisibilityPercentage() {
return minVisibilityPercentage;
}
public void setMinVisibilityPercentage(int minVisibilityPercentage) {
this.minVisibilityPercentage = minVisibilityPercentage;
}
public boolean isImpressionTracked() {
return isImpressionTracked;
}
public void setImpressionTracked(boolean impressionTracked) {
isImpressionTracked = impressionTracked;
}
public NativeEventTracker.EventType getEventType() {
return eventType;
}
public void setEventType(NativeEventTracker.EventType eventType) {
this.eventType = eventType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
VisibilityTrackerOption that = (VisibilityTrackerOption) o;
if (minimumVisibleMillis != that.minimumVisibleMillis) {
return false;
}
if (minVisibilityPercentage != that.minVisibilityPercentage) {
return false;
}
if (isImpressionTracked != that.isImpressionTracked) {
return false;
}
if (startTimeMillis != that.startTimeMillis) {
return false;
}
return eventType == that.eventType;
}
@Override
public int hashCode() {
int result = eventType != null ? eventType.hashCode() : 0;
result = 31 * result + minimumVisibleMillis;
result = 31 * result + minVisibilityPercentage;
result = 31 * result + (isImpressionTracked ? 1 : 0);
result = 31 * result + (int) (startTimeMillis ^ (startTimeMillis >>> 32));
return result;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/internal/VisibilityTrackerResult.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.internal;
import org.prebid.mobile.rendering.models.ntv.NativeEventTracker;
import org.prebid.mobile.rendering.utils.exposure.ViewExposure;
public class VisibilityTrackerResult {
private final NativeEventTracker.EventType eventType;
private final ViewExposure viewExposure;
private final boolean isVisible;
private final boolean shouldFireImpression;
public VisibilityTrackerResult(
NativeEventTracker.EventType eventType,
ViewExposure viewExposure,
boolean isVisible,
boolean shouldFireImpression
) {
this.eventType = eventType;
this.viewExposure = viewExposure;
this.isVisible = isVisible;
this.shouldFireImpression = shouldFireImpression;
}
public NativeEventTracker.EventType getEventType() {
return eventType;
}
public ViewExposure getViewExposure() {
return viewExposure;
}
public boolean isVisible() {
return isVisible;
}
public boolean shouldFireImpression() {
return shouldFireImpression;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
VisibilityTrackerResult result = (VisibilityTrackerResult) o;
if (isVisible != result.isVisible) {
return false;
}
if (shouldFireImpression != result.shouldFireImpression) {
return false;
}
if (eventType != result.eventType) {
return false;
}
return viewExposure != null ? viewExposure.equals(result.viewExposure) : result.viewExposure == null;
}
@Override
public int hashCode() {
int result = eventType != null ? eventType.hashCode() : 0;
result = 31 * result + (viewExposure != null ? viewExposure.hashCode() : 0);
result = 31 * result + (isVisible ? 1 : 0);
result = 31 * result + (shouldFireImpression ? 1 : 0);
return result;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/ntv/NativeEventTracker.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.ntv;
import androidx.annotation.Nullable;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext;
import java.util.ArrayList;
/**
* Specifies what type of event tracking is supported
*/
public class NativeEventTracker {
private final EventType eventType;
private final ArrayList<EventTrackingMethod> eventTrackingMethods;
private Ext ext;
public NativeEventTracker(
EventType eventType,
ArrayList<EventTrackingMethod> eventTrackingMethods
) {
this.eventType = eventType;
this.eventTrackingMethods = eventTrackingMethods;
}
public EventType getEventType() {
return eventType;
}
public ArrayList<EventTrackingMethod> getEventTrackingMethods() {
return eventTrackingMethods;
}
public Ext getExt() {
return ext;
}
public void setExt(Ext ext) {
this.ext = ext;
}
public enum EventType {
IMPRESSION(1),
VIEWABLE_MRC50(2),
VIEWABLE_MRC100(3),
VIEWABLE_VIDEO50(4),
CUSTOM(500),
OMID(555);
private int id;
EventType(final int id) {
this.id = id;
}
@Nullable
public static NativeEventTracker.EventType getType(Integer id) {
if (id == null || id < 0) {
return null;
}
NativeEventTracker.EventType[] eventTypes = NativeEventTracker.EventType.values();
for (NativeEventTracker.EventType eventType : eventTypes) {
if (eventType.getId() == id) {
return eventType;
}
}
NativeEventTracker.EventType custom = NativeEventTracker.EventType.CUSTOM;
custom.setId(id);
return custom;
}
public int getId() {
return id;
}
public void setId(int id) {
if (equals(CUSTOM) && !inExistingValue(id)) {
this.id = id;
}
}
private boolean inExistingValue(int id) {
EventType[] possibleValues = getDeclaringClass().getEnumConstants();
for (EventType value : possibleValues) {
if (!value.equals(EventType.CUSTOM) && value.getId() == id) {
return true;
}
}
return false;
}
}
public enum EventTrackingMethod {
IMAGE(1),
JS(2),
CUSTOM(500);
private int id;
EventTrackingMethod(final int id) {
this.id = id;
}
@Nullable
public static NativeEventTracker.EventTrackingMethod getType(Integer id) {
if (id == null || id < 0) {
return null;
}
NativeEventTracker.EventTrackingMethod[] imageTypes = NativeEventTracker.EventTrackingMethod.values();
for (NativeEventTracker.EventTrackingMethod imageType : imageTypes) {
if (imageType.getId() == id) {
return imageType;
}
}
NativeEventTracker.EventTrackingMethod custom = NativeEventTracker.EventTrackingMethod.CUSTOM;
custom.setId(id);
return custom;
}
public int getId() {
return id;
}
public void setId(int id) {
if (equals(CUSTOM) && !inExistingValue(id)) {
this.id = id;
}
}
private boolean inExistingValue(int id) {
EventTrackingMethod[] possibleValues = getDeclaringClass().getEnumConstants();
for (EventTrackingMethod value : possibleValues) {
if (!value.equals(EventTrackingMethod.CUSTOM) && value.getId() == id) {
return true;
}
}
return false;
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/BidRequest.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.*;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.source.Source;
import java.util.ArrayList;
public class BidRequest extends BaseBid {
private String id;
private App app = null;
private Device device = null;
private ArrayList<Imp> imps = new ArrayList<>();
private Regs regs = null;
private User user = null;
private Source source = null;
private Ext ext = null;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
if (imps != null && imps.size() > 0) {
JSONArray jsonArray = new JSONArray();
for (Imp i : imps) {
jsonArray.put(i.getJsonObject());
}
toJSON(jsonObject, "imp", jsonArray);
}
toJSON(jsonObject, "id", !TextUtils.isEmpty(id) ? id : null);
toJSON(jsonObject, "app", (app != null) ? app.getJsonObject() : null);
toJSON(jsonObject, "device", (device != null) ? device.getJsonObject() : null);
toJSON(jsonObject, "regs", (regs != null) ? regs.getJsonObject() : null);
toJSON(jsonObject, "user", (user != null) ? user.getJsonObject() : null);
toJSON(jsonObject, "source", source != null ? source.getJsonObject() : null);
toJSON(jsonObject, "ext", ext != null ? ext.getJsonObject() : null);
toJSON(jsonObject, "test", PrebidMobile.getPbsDebug() ? 1 : null);
return jsonObject;
}
// Accessors to prevent NPE while maintaining null if object is not set
// App
public App getApp() {
if (app == null) {
app = new App();
}
return app;
}
public void setApp(App app) {
this.app = app;
}
// Device
public Device getDevice() {
if (device == null) {
device = new Device();
}
return device;
}
public void setDevice(Device device) {
this.device = device;
}
// Imp
public ArrayList<Imp> getImp() {
return imps;
}
public void setImp(ArrayList<Imp> imp) {
imps = imp;
}
// Regs
public Regs getRegs() {
if (regs == null) {
regs = new Regs();
}
return regs;
}
public void setRegs(Regs regs) {
this.regs = regs;
}
// User
public User getUser() {
if (user == null) {
user = new User();
}
return user;
}
public void setUser(User user) {
this.user = user;
}
public void setSource(Source source) {
this.source = source;
}
public Source getSource() {
if (source == null) {
source = new Source();
}
return source;
}
public void setId(String id) {
this.id = id;
}
@VisibleForTesting
public String getId() {
return id;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/App.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.ContentObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.apps.Publisher;
public class App extends BaseBid {
public String id = null;
public String name = null;
public String bundle = null;
public String domain = null;
//TODO: ORTB2.5: remove this? After product's decision?
public String storeurl = null;
public String[] cat = null;
public String[] sectioncat = null;
public String[] pagecat = null;
public String ver = null;
public Integer privacypolicy = null;
public Integer paid = null;
public String keywords = null;
public ContentObject contentObject = null;
private Publisher publisher = null;
private Ext ext = null;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "id", id);
toJSON(jsonObject, "name", name);
toJSON(jsonObject, "bundle", bundle);
toJSON(jsonObject, "domain", domain);
toJSON(jsonObject, "storeurl", storeurl);
if (cat != null) {
JSONArray jsonArray = new JSONArray();
for (String cat : cat) {
jsonArray.put(cat);
}
toJSON(jsonObject, "cat", jsonArray);
}
if (sectioncat != null) {
JSONArray jsonArray = new JSONArray();
for (String sectionCat : sectioncat) {
jsonArray.put(sectionCat);
}
toJSON(jsonObject, "sectioncat", jsonArray);
}
if (pagecat != null) {
JSONArray jsonArray = new JSONArray();
for (String pageCat : pagecat) {
jsonArray.put(pageCat);
}
toJSON(jsonObject, "pagecat", jsonArray);
}
if (contentObject != null && contentObject.getJsonObject() != null) {
JSONObject contentJson = contentObject.getJsonObject();
toJSON(jsonObject, "content", contentJson);
}
toJSON(jsonObject, "ver", ver);
toJSON(jsonObject, "privacypolicy", privacypolicy);
toJSON(jsonObject, "paid", paid);
toJSON(jsonObject, "keywords", keywords);
toJSON(jsonObject, "publisher", (publisher != null) ? this.publisher.getJsonObject() : null);
toJSON(jsonObject, "ext", (ext != null) ? ext.getJsonObject() : null);
return jsonObject;
}
public Publisher getPublisher() {
if (publisher == null) {
publisher = new Publisher();
}
return publisher;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/BaseBid.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
/**
* Created by matthew.rolufs on 6/23/15.
*/
public class BaseBid implements Serializable
{
protected void toJSON(JSONObject jsonObject, String key, Object value) throws JSONException {
jsonObject.putOpt(key, value);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/Device.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo;
public class Device extends BaseBid {
// User Agent
public String ua = null;
private Integer dnt = null;
public Integer lmt = null;
public String ip = null;
private String ipv6 = null;
//TODO: ORTB2.5: auto detect this?
public Integer devicetype = null;
public String make = null;
public String model = null;
public String os = null;
public String osv = null;
//TODO: ORTB2.5: detect this? How?
//Hardware version of the device (e.g., “5S” for iPhone 5S).
public String hwv = null;
public String flashver = null;
public String language = null;
public String carrier = null;
public String mccmnc = null;
public String ifa = null;
public String didsha1 = null;
public String didmd5 = null;
public String dpidsha1 = null;
public String dpidmd5 = null;
//Physical height of the screen in pixels.
public Integer h = null;
//Physical width of the screen in pixels.
public Integer w = null;
//Screen size as pixels per linear inch.
//TODO: ORTB2.5: auto detect?
public Integer ppi = null;
public Integer js = null;
public Integer connectiontype = null;
//The ratio of physical pixels to device independent pixels.
public Float pxratio = null;
public Geo geo = null;
private Ext ext;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "ua", ua);
toJSON(jsonObject, "dnt", dnt);
toJSON(jsonObject, "lmt", lmt);
toJSON(jsonObject, "ip", ip);
toJSON(jsonObject, "ipv6", ipv6);
toJSON(jsonObject, "devicetype", devicetype);
toJSON(jsonObject, "make", make);
toJSON(jsonObject, "model", model);
toJSON(jsonObject, "os", os);
toJSON(jsonObject, "osv", osv);
toJSON(jsonObject, "hwv", hwv);
toJSON(jsonObject, "flashver", flashver);
toJSON(jsonObject, "language", language);
toJSON(jsonObject, "carrier", carrier);
toJSON(jsonObject, "mccmnc", mccmnc);
toJSON(jsonObject, "ifa", ifa);
toJSON(jsonObject, "didsha1", didsha1);
toJSON(jsonObject, "didmd5", didmd5);
toJSON(jsonObject, "dpidsha1", dpidsha1);
toJSON(jsonObject, "dpidmd5", dpidmd5);
toJSON(jsonObject, "h", h);
toJSON(jsonObject, "w", w);
toJSON(jsonObject, "ppi", ppi);
toJSON(jsonObject, "js", js);
toJSON(jsonObject, "connectiontype", connectiontype);
toJSON(jsonObject, "pxratio", pxratio);
toJSON(jsonObject, "ext", (ext != null) ? ext.getJsonObject() : null);
toJSON(jsonObject, "geo", (geo != null) ? geo.getJsonObject() : null);
return jsonObject;
}
// Accessors to prevent NPE while maintaining null if object is not set
// Geo
public Geo getGeo() {
if (geo == null) {
geo = new Geo();
}
return geo;
}
public void setGeo(Geo geo) {
this.geo = geo;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/Ext.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class Ext implements Serializable {
private Map<String, Object> extValuesHashMap = new HashMap<>();
public JSONObject getJsonObject() {
return new JSONObject(extValuesHashMap);
}
public void put(String key, String value) {
extValuesHashMap.put(key, value);
}
public void put(String key, Integer value) {
extValuesHashMap.put(key, value);
}
public void put(String key, JSONObject value) {
extValuesHashMap.put(key, value);
}
public void put(String key, JSONArray value) {
extValuesHashMap.put(key, value);
}
public void put(JSONObject jsonObject) {
if (jsonObject == null) {
return;
}
Iterator<String> jsonIterator = jsonObject.keys();
while (jsonIterator.hasNext()) {
String key = jsonIterator.next();
extValuesHashMap.put(key, jsonObject.opt(key));
}
}
public void remove(String key) {
extValuesHashMap.remove(key);
}
public Map<String, Object> getMap() {
return extValuesHashMap;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Ext ext = (Ext) o;
return extValuesHashMap != null ? extValuesHashMap.equals(ext.extValuesHashMap) : ext.extValuesHashMap == null;
}
@Override
public int hashCode() {
return extValuesHashMap != null ? extValuesHashMap.hashCode() : 0;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/Imp.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.Banner;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.Pmp;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.Video;
public class Imp extends BaseBid {
public String id = null;
public String displaymanager = null;
public String displaymanagerver = null;
public Integer instl = null;
public String tagid = null;
public Integer secure = null;
public Banner banner = null;
public Video video = null;
public Pmp pmp = null;
public Native nativeObj;
private Ext ext = null;
public Integer clickBrowser = null;
JSONObject jsonObject;
public JSONObject getJsonObject() throws JSONException {
this.jsonObject = new JSONObject();
toJSON(jsonObject, "id", id);
toJSON(jsonObject, "displaymanager", displaymanager);
toJSON(jsonObject, "displaymanagerver", displaymanagerver);
toJSON(jsonObject, "instl", instl);
toJSON(jsonObject, "tagid", tagid);
toJSON(jsonObject, "clickbrowser", clickBrowser);
toJSON(jsonObject, "secure", secure);
toJSON(jsonObject, "banner", (banner != null) ? banner.getJsonObject() : null);
toJSON(jsonObject, "video", (video != null) ? video.getJsonObject() : null);
toJSON(jsonObject, "native", (nativeObj != null) ? nativeObj.getJsonObject() : null);
toJSON(jsonObject, "pmp", (pmp != null) ? pmp.getJsonObject() : null);
toJSON(jsonObject, "ext", (ext != null) ? ext.getJsonObject() : null);
return jsonObject;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
public Banner getBanner() {
if (banner == null) {
banner = new Banner();
}
return banner;
}
public Video getVideo() {
if (video == null) {
video = new Video();
}
return video;
}
public Native getNative() {
if (nativeObj == null) {
nativeObj = new Native();
}
return nativeObj;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/MobileSdkPassThrough.java | package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.data.Position;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.core.BuildConfig;
/**
* A class responsible for parsing "prebidmobilesdk" pass through type from bid response.
* It contains interstitial control settings, like close button size or skip delay.
* It can be located in ext.prebid.passthrough[] or seatbid[].bid[].ext.prebid.passthrough[].
*/
public class MobileSdkPassThrough {
private static final String TAG = MobileSdkPassThrough.class.getSimpleName();
@Nullable
public static MobileSdkPassThrough create(JSONObject extJson) {
try {
JSONObject rootJsonObject;
if (!BuildConfig.DEBUG) {
if (extJson.has("prebid")) {
rootJsonObject = extJson.getJSONObject("prebid");
} else return null;
} else {
rootJsonObject = extJson;
}
if (rootJsonObject.has("passthrough")) {
JSONArray passThroughArray = rootJsonObject.getJSONArray("passthrough");
for (int i = 0; i < passThroughArray.length(); i++) {
JSONObject passThrough = passThroughArray.getJSONObject(i);
if (passThrough.has("type")) {
String currentType = passThrough.getString("type");
if (currentType.equals("prebidmobilesdk") && passThrough.has("adconfiguration")) {
return new MobileSdkPassThrough(passThrough);
}
}
}
}
} catch (JSONException e) {
LogUtil.error(TAG, "Can't parse json");
}
return null;
}
/**
* Creates unified MobileSdkPassThrough. An object from bid has higher priority.
*
* @param fromBid - object from seatbid[].bid[].ext.prebid.passthrough[]
* @param fromRoot - object from ext.prebid.passthrough[]
*/
@Nullable
public static MobileSdkPassThrough combine(
@Nullable MobileSdkPassThrough fromBid,
@Nullable MobileSdkPassThrough fromRoot
) {
if (fromBid == null && fromRoot == null) {
return null;
} else if (fromBid == null) {
return fromRoot;
} else if (fromRoot == null) {
return fromBid;
}
if (fromBid.isMuted == null) {
fromBid.isMuted = fromRoot.isMuted;
}
if (fromBid.maxVideoDuration == null) {
fromBid.maxVideoDuration = fromRoot.maxVideoDuration;
}
if (fromBid.skipDelay == null) {
fromBid.skipDelay = fromRoot.skipDelay;
}
if (fromBid.closeButtonArea == null) {
fromBid.closeButtonArea = fromRoot.closeButtonArea;
}
if (fromBid.skipButtonArea == null) {
fromBid.skipButtonArea = fromRoot.skipButtonArea;
}
if (fromBid.closeButtonPosition == null) {
fromBid.closeButtonPosition = fromRoot.closeButtonPosition;
}
if (fromBid.skipButtonPosition == null) {
fromBid.skipButtonPosition = fromRoot.skipButtonPosition;
}
return fromBid;
}
/**
* Combines unified pass through object with rendering controls
* from ad unit configuration. Settings from ad unit configuration
* have lower priority.
*/
@NonNull
public static MobileSdkPassThrough combine(
@Nullable MobileSdkPassThrough unifiedPassThrough,
@NonNull AdUnitConfiguration configuration
) {
MobileSdkPassThrough result;
if (unifiedPassThrough == null) {
result = new MobileSdkPassThrough();
} else {
result = unifiedPassThrough;
}
if (result.isMuted == null) {
result.isMuted = configuration.isMuted();
}
if (result.maxVideoDuration == null) {
result.maxVideoDuration = configuration.getMaxVideoDuration();
}
if (result.skipDelay == null) {
result.skipDelay = configuration.getSkipDelay();
}
if (result.skipButtonArea == null) {
result.skipButtonArea = configuration.getSkipButtonArea();
}
if (result.skipButtonPosition == null) {
result.skipButtonPosition = configuration.getSkipButtonPosition();
}
if (result.closeButtonArea == null) {
result.closeButtonArea = configuration.getCloseButtonArea();
}
if (result.closeButtonPosition == null) {
result.closeButtonPosition = configuration.getCloseButtonPosition();
}
return result;
}
public Boolean isMuted;
public Integer maxVideoDuration;
public Integer skipDelay;
public Double closeButtonArea;
public Double skipButtonArea;
public Position closeButtonPosition;
public Position skipButtonPosition;
private JSONObject configuration;
private MobileSdkPassThrough() {}
private MobileSdkPassThrough(JSONObject passThrough) {
try {
if (passThrough.has("adconfiguration")) {
configuration = passThrough.getJSONObject("adconfiguration");
getAndSave("ismuted", Boolean.class, it -> isMuted = it);
getAndSave("maxvideoduration", Integer.class, it -> maxVideoDuration = it);
getAndSave("skipdelay", Integer.class, it -> skipDelay = it);
getAndSave("closebuttonarea", Double.class, it -> closeButtonArea = it);
getAndSave("skipbuttonarea", Double.class, it -> skipButtonArea = it);
getAndSave("closebuttonposition", String.class, it -> closeButtonPosition = Position.fromString(it));
getAndSave("skipbuttonposition", String.class, it -> skipButtonPosition = Position.fromString(it));
}
} catch (JSONException exception) {
LogUtil.error(TAG, "Can't parse configuration");
}
}
public void modifyAdUnitConfiguration(AdUnitConfiguration adUnitConfiguration) {
if (isMuted != null) {
adUnitConfiguration.setIsMuted(isMuted);
}
if (maxVideoDuration != null) {
adUnitConfiguration.setMaxVideoDuration(maxVideoDuration);
}
if (skipDelay != null) {
adUnitConfiguration.setSkipDelay(skipDelay);
}
if (closeButtonArea != null) {
adUnitConfiguration.setCloseButtonArea(closeButtonArea);
}
if (skipButtonArea != null) {
adUnitConfiguration.setSkipButtonArea(skipButtonArea);
}
if (closeButtonPosition != null) {
adUnitConfiguration.setCloseButtonPosition(closeButtonPosition);
}
if (skipButtonPosition != null) {
adUnitConfiguration.setSkipButtonPosition(skipButtonPosition);
}
}
private <T> void getAndSave(
String key,
Class<T> classType,
AfterCast<T> afterCast
) {
try {
if (configuration.has(key)) {
T result = classType.cast(configuration.get(key));
afterCast.save(result);
}
} catch (JSONException e) {
LogUtil.error(TAG, "Object " + key + " has wrong type!");
}
}
private interface AfterCast<T> {
void save(T variable);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/Native.java | package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.NativeAsset;
import org.prebid.mobile.NativeEventTracker;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.configuration.NativeAdUnitConfiguration;
import java.util.ArrayList;
import java.util.List;
public class Native extends BaseBid {
private JSONObject request;
private Ext ext;
// Won't be implemented in 1.1
private int[] api;
private int[] battr;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put("request", request.toString());
jsonObject.put("ver", PrebidMobile.NATIVE_VERSION);
jsonObject.putOpt("ext", ext != null ? ext.getJsonObject() : null);
return jsonObject;
}
public void setRequestFrom(NativeAdUnitConfiguration config) {
request = new JSONObject();
try {
request.put("ver", PrebidMobile.NATIVE_VERSION);
if (config.getContextType() != null) {
request.put("context", config.getContextType().getID());
}
if (config.getContextSubtype() != null) {
request.put("contextsubtype", config.getContextSubtype().getID());
}
if (config.getPlacementType() != null) {
request.put("plcmttype", config.getPlacementType().getID());
}
if (config.getSeq() >= 0) {
request.put("seq", config.getSeq());
}
request.put("assets", getAssetsJsonArray(config.getAssets()));
if (!config.getEventTrackers().isEmpty()) {
request.put("eventtrackers", getTrackersJsonArray(config.getEventTrackers()));
}
if (config.getPrivacy()) {
request.put("privacy", 1);
}
request.putOpt("ext", config.getExt() != null ? config.getExt() : null);
} catch (JSONException e) {
e.printStackTrace();
}
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
private JSONArray getAssetsJsonArray(List<NativeAsset> assetList) throws JSONException {
JSONArray assetJsonArray = new JSONArray();
for (NativeAsset asset : assetList) {
assetJsonArray.put(asset.getJsonObject());
}
return assetJsonArray;
}
private JSONArray getTrackersJsonArray(List<NativeEventTracker> trackerList)
throws JSONException {
JSONArray trackersJsonArray = new JSONArray();
for (NativeEventTracker eventTracker : trackerList) {
JSONObject evenTrackerJson = new JSONObject();
if (eventTracker.getEvent() != null) {
evenTrackerJson.put("event", eventTracker.getEvent().getID());
}
ArrayList<NativeEventTracker.EVENT_TRACKING_METHOD> eventTrackingMethods = eventTracker.getMethods();
if (eventTrackingMethods != null) {
JSONArray methodsArray = new JSONArray();
for (NativeEventTracker.EVENT_TRACKING_METHOD method : eventTrackingMethods) {
methodsArray.put(method.getID());
}
evenTrackerJson.put("methods", methodsArray);
}
if (eventTracker.getExtObject() != null) {
evenTrackerJson.put("ext", eventTracker.getExtObject());
}
trackersJsonArray.put(evenTrackerJson);
}
return trackersJsonArray;
}
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/Regs.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import org.json.JSONException;
import org.json.JSONObject;
public class Regs extends BaseBid {
public Integer coppa = null;
private Ext ext = null;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "coppa", this.coppa);
toJSON(jsonObject, "ext", (ext != null) ? ext.getJsonObject() : null);
return jsonObject;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/User.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.DataObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo;
import java.util.ArrayList;
public class User extends BaseBid {
public Integer yob = null;
public String gender = null;
public String keywords = null;
public Geo geo = null;
public String customData = null;
public String id = null;
public Ext ext = null;
public String buyerUid = null;
public ArrayList<DataObject> dataObjects = new ArrayList<>();
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "id", this.id);
toJSON(jsonObject, "buyeruid", this.buyerUid);
toJSON(jsonObject, "yob", this.yob);
toJSON(jsonObject, "gender", this.gender);
toJSON(jsonObject, "keywords", this.keywords);
toJSON(jsonObject, "customdata", this.customData);
toJSON(jsonObject, "geo", (geo != null) ? this.geo.getJsonObject() : null);
if (ext != null) {
JSONObject extJson = this.ext.getJsonObject();
if (extJson.length() > 0) {
toJSON(jsonObject, "ext", extJson);
}
}
JSONArray dataJsonArray = getDataJsonArray();
if (dataJsonArray != null) {
toJSON(jsonObject, "data", dataJsonArray);
}
return jsonObject;
}
// Accessors to prevent NPE while maintaining null if object is not set
// Geo
public Geo getGeo() {
if (geo == null) {
geo = new Geo();
}
return geo;
}
public void setGeo(Geo geo) {
this.geo = geo;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
public void setExt(Ext ext) {
this.ext = ext;
}
@Nullable
private JSONArray getDataJsonArray() {
if (dataObjects.isEmpty()) return null;
JSONArray result = new JSONArray();
for (DataObject dataObject : dataObjects) {
result.put(dataObject.getJsonObject());
}
return result;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/apps/Content.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.apps;
import androidx.annotation.VisibleForTesting;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
//TODO: ORTB2.5: get back for In-stream video - per Product
public class Content extends BaseBid {
@VisibleForTesting
String id = null;
@VisibleForTesting
Integer episode = null;
@VisibleForTesting
String title = null;
@VisibleForTesting
String series = null;
@VisibleForTesting
String season = null;
@VisibleForTesting
String url = null;
@VisibleForTesting
String[] cat = null;
@VisibleForTesting
Integer videoquality = null;
@VisibleForTesting
Integer context = null;
@VisibleForTesting
Integer qagmediarating = null;
@VisibleForTesting
String contentrating = null;
@VisibleForTesting
String userrating = null;
@VisibleForTesting
String keywords = null;
@VisibleForTesting
String livestream = null;
@VisibleForTesting
String sourcerelationship = null;
@VisibleForTesting
String len = null;
@VisibleForTesting
String language = null;
@VisibleForTesting
String embeddable = null;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "id", this.id);
toJSON(jsonObject, "episode", this.episode);
toJSON(jsonObject, "title", this.title);
toJSON(jsonObject, "series", this.series);
toJSON(jsonObject, "season", this.season);
toJSON(jsonObject, "url", this.url);
if (cat != null) {
JSONArray jsonArray = new JSONArray();
for (String catItem : cat) {
jsonArray.put(catItem);
}
toJSON(jsonObject, "cat", jsonArray);
}
toJSON(jsonObject, "videoquality", this.videoquality);
toJSON(jsonObject, "context", this.context);
toJSON(jsonObject, "qagmediarating", this.qagmediarating);
toJSON(jsonObject, "contentrating", this.contentrating);
toJSON(jsonObject, "userrating", this.userrating);
toJSON(jsonObject, "keywords", this.keywords);
toJSON(jsonObject, "livestream", this.livestream);
toJSON(jsonObject, "sourcerelationship", this.sourcerelationship);
toJSON(jsonObject, "len", this.len);
toJSON(jsonObject, "language", this.language);
toJSON(jsonObject, "embeddable", this.embeddable);
return jsonObject;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/apps/Publisher.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.apps;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
public class Publisher extends BaseBid {
public String id = null;
public String name = null;
public String[] cat = null;
public String domain = null;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "id", id);
toJSON(jsonObject, "name", name);
if (cat != null) {
JSONArray jsonArray = new JSONArray();
for (String catItem : cat) {
jsonArray.put(catItem);
}
toJSON(jsonObject, "cat", jsonArray);
}
toJSON(jsonObject, "domain", domain);
return jsonObject;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/devices/Geo.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.devices;
public class Geo extends org.prebid.mobile.rendering.models.openrtb.bidRequests.geo.Geo
{
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/geo/Geo.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.geo;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
public class Geo extends BaseBid {
public Float lat = null;
public Float lon = null;
public Integer type = null;
public Integer accuracy = null;
public Integer lastfix = null;
public String country = null;
public String region = null;
//TODO: ORTB2.5: Auto detect? how?
//Region of a country using FIPS 10-4 notation. While OpenRTB supports this attribute, it has been withdrawn by NIST in 2008.
public String regionfips104 = null;
public String metro = null;
public String city = null;
public String zip = null;
public Integer utcoffset = null;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "lat", this.lat);
toJSON(jsonObject, "lon", this.lon);
toJSON(jsonObject, "type", this.type);
toJSON(jsonObject, "accuracy", this.accuracy);
toJSON(jsonObject, "lastfix", this.lastfix);
toJSON(jsonObject, "country", this.country);
toJSON(jsonObject, "region", this.region);
toJSON(jsonObject, "regionfips104", this.regionfips104);
toJSON(jsonObject, "metro", this.metro);
toJSON(jsonObject, "city", this.city);
toJSON(jsonObject, "zip", this.zip);
toJSON(jsonObject, "utcoffset", this.utcoffset);
return jsonObject;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/imps/Banner.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.imps;
import androidx.annotation.VisibleForTesting;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps.Format;
import java.util.HashSet;
public class Banner extends BaseBid {
public Integer pos = null;
public int[] api;
private HashSet<Format> formats = new HashSet<>();
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "pos", this.pos);
if (api != null) {
JSONArray jsonArray = new JSONArray();
for (int apiItem : api) {
jsonArray.put(apiItem);
}
toJSON(jsonObject, "api", jsonArray);
}
if (formats.size() > 0) {
JSONArray formatsArray = new JSONArray();
for (Format format : formats) {
formatsArray.put(format.getJsonObject());
}
toJSON(jsonObject, "format", formatsArray);
}
return jsonObject;
}
public void addFormat(int w, int h) {
formats.add(new Format(w, h));
}
@VisibleForTesting
public HashSet<Format> getFormats() {
return formats;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/imps/Pmp.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.imps;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps.Deals;
import java.util.ArrayList;
import java.util.List;
public class Pmp extends BaseBid {
public Integer private_auction= null;
public List<Deals> deals = new ArrayList<>();
//deals
//ext
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "private_auction", this.private_auction);
if (deals != null && deals.size() > 0) {
JSONArray jsonArray = new JSONArray();
for (Deals i : deals) {
jsonArray.put(i.getJsonObject());
}
toJSON(jsonObject, "deals", jsonArray);
}
return jsonObject;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/imps/Video.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.imps;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
public class Video extends BaseBid {
public String[] mimes = null;
public Integer minduration = null;
public Integer maxduration = null;
public int[] protocols;
public int[] api;
//TODO: ORTB2.5: Auto detect? how?
public Integer w = null;
//TODO: ORTB2.5: Auto detect? how?
public Integer h = null;
public Integer linearity = null;
public Integer minbitrate = null;
public Integer maxbitrate = null;
public int[] playbackmethod;
public int[] delivery;
public Integer pos = null;
public Integer placement = null;
public Integer playbackend;
public Integer startDelay;
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
if (mimes != null) {
JSONArray jsonArray = new JSONArray();
for (String mime : mimes) {
jsonArray.put(mime);
}
toJSON(jsonObject, "mimes", jsonArray);
}
toJSON(jsonObject, "minduration", minduration);
toJSON(jsonObject, "maxduration", maxduration);
toJSON(jsonObject, "playbackend", playbackend);
if (protocols != null) {
JSONArray jsonArray = new JSONArray();
for (int protocol : protocols) {
jsonArray.put(protocol);
}
toJSON(jsonObject, "protocols", jsonArray);
}
toJSON(jsonObject, "w", w);
toJSON(jsonObject, "h", h);
toJSON(jsonObject, "startdelay", startDelay);
toJSON(jsonObject, "linearity", linearity);
toJSON(jsonObject, "minbitrate", minbitrate);
toJSON(jsonObject, "maxbitrate", maxbitrate);
toJSON(jsonObject, "placement", placement);
if (playbackmethod != null) {
JSONArray jsonArray = new JSONArray();
for (int method : playbackmethod) {
jsonArray.put(method);
}
toJSON(jsonObject, "playbackmethod", jsonArray);
}
if (delivery != null) {
JSONArray jsonArray = new JSONArray();
for (int del : delivery) {
jsonArray.put(del);
}
toJSON(jsonObject, "delivery", jsonArray);
}
if (api != null) {
JSONArray jsonArray = new JSONArray();
for (int number : api) {
jsonArray.put(number);
}
toJSON(jsonObject, "api", jsonArray);
}
toJSON(jsonObject, "pos", pos);
return jsonObject;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/imps | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/imps/pmps/Deals.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
public class Deals extends BaseBid {
public String id = null;
public Float bidfloor;
public String bidfloorcur = null;
public Integer at= null;
public String[] wseat = null;
public String[] wadomain = null;
//ext
JSONObject jsonObject;
public JSONObject getJsonObject() throws JSONException {
this.jsonObject = new JSONObject();
toJSON(jsonObject, "id", this.id);
toJSON(jsonObject, "bidfloor", this.bidfloor);
toJSON(jsonObject, "bidfloorcur", this.bidfloorcur);
toJSON(jsonObject, "at", this.at);
if (wseat != null) {
JSONArray jsonArray = new JSONArray();
for (String seat : wseat) {
jsonArray.put(seat);
}
toJSON(jsonObject, "wseat", jsonArray);
}
if (wadomain != null) {
JSONArray jsonArray = new JSONArray();
for (String domain : wadomain) {
jsonArray.put(domain);
}
toJSON(jsonObject, "wadomain", jsonArray);
}
return jsonObject;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/imps | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/imps/pmps/Format.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
public class Format extends BaseBid {
public Integer w;
public Integer h;
public Format(int w, int h) {
this.w = w;
this.h = h;
}
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "w", w);
toJSON(jsonObject, "h", h);
return jsonObject;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Format format = (Format) o;
if (w != null ? !w.equals(format.w) : format.w != null) {
return false;
}
return h != null ? h.equals(format.h) : format.h == null;
}
@Override
public int hashCode() {
int result = w != null ? w.hashCode() : 0;
result = 31 * result + (h != null ? h.hashCode() : 0);
return result;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/source/Source.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.source;
import android.text.TextUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.BaseBid;
import org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext;
public class Source extends BaseBid {
private String tid;
private Ext ext;
public void setExt(Ext ext) {
this.ext = ext;
}
public void setTid(String tid) {
this.tid = tid;
}
public Ext getExt() {
if (ext == null) {
ext = new Ext();
}
return ext;
}
public String getTid() {
return tid;
}
public JSONObject getJsonObject() throws JSONException {
JSONObject jsonObject = new JSONObject();
toJSON(jsonObject, "tid", !TextUtils.isEmpty(tid) ? tid : null);
toJSON(jsonObject, "ext", (ext != null) ? ext.getJsonObject() : null);
return jsonObject;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/models/openrtb/bidRequests/users/Geo.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.models.openrtb.bidRequests.users;
public class Geo extends org.prebid.mobile.rendering.models.openrtb.bidRequests.geo.Geo
{
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/mraid/MraidEnv.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.mraid;
import androidx.annotation.NonNull;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.rendering.utils.helpers.AdIdManager;
import org.prebid.mobile.rendering.utils.helpers.AppInfoManager;
public class MraidEnv {
private MraidEnv() {
}
@NonNull
public static String getWindowMraidEnv() {
return "window.MRAID_ENV = {"
+ getStringPropertyWithSeparator("version", PrebidMobile.MRAID_VERSION)
+ getStringPropertyWithSeparator("sdk", PrebidMobile.SDK_NAME)
+ getStringPropertyWithSeparator("sdkVersion", PrebidMobile.SDK_VERSION)
+ getStringPropertyWithSeparator("appId", AppInfoManager.getPackageName())
+ getStringPropertyWithSeparator("ifa", AdIdManager.getAdId())
+ getBooleanPropertyWithSeparator("limitAdTracking", AdIdManager.isLimitAdTrackingEnabled(), ",")
+ getBooleanPropertyWithSeparator("coppa", PrebidMobile.isCoppaEnabled, "")
+ "};";
}
static String getStringPropertyWithSeparator(String propertyName, String propertyValue) {
String separator = ",";
return String.format("%s: \"%s\"%s", propertyName, propertyValue, separator);
}
static String getBooleanPropertyWithSeparator(String propertyName, boolean propertyValue, String separator) {
return String.format("%s: %s%s", propertyName, propertyValue, separator);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/mraid | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/mraid/handler/FetchPropertiesHandler.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.mraid.handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.NonNull;
import org.prebid.mobile.rendering.views.webview.mraid.JSInterface;
public class FetchPropertiesHandler extends Handler {
@NonNull private final FetchPropertyCallback callback;
public FetchPropertiesHandler(
@NonNull
FetchPropertyCallback callback) {
this.callback = callback;
}
@Override
public void handleMessage(final Message message) {
super.handleMessage(message);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
try {
final String expandProperties = message.getData().getString(JSInterface.JSON_VALUE);
callback.onResult(expandProperties);
}
catch (Exception e) {
callback.onError(e);
}
});
}
public interface FetchPropertyCallback {
void onResult(String propertyJson);
void onError(Throwable throwable);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/mraid | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/mraid/methods/CompletedCallBack.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.mraid.methods;
public interface CompletedCallBack {
void expandDialogShown();
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.