146 lines
5.9 KiB
Java
146 lines
5.9 KiB
Java
package com.unity3d.ads.api;
|
|
|
|
import com.unity3d.ads.adunit.AdUnitError;
|
|
import com.unity3d.ads.log.DeviceLog;
|
|
import com.unity3d.ads.misc.Utilities;
|
|
import com.unity3d.ads.webplayer.WebPlayerError;
|
|
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
|
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
|
import java.util.Map;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class WebPlayer {
|
|
private static JSONObject _webPlayerEventSettings;
|
|
private static JSONObject _webPlayerSettings;
|
|
private static JSONObject _webSettings;
|
|
|
|
@WebViewExposed
|
|
public static void clearSettings(WebViewCallback webViewCallback) {
|
|
_webSettings = null;
|
|
_webPlayerSettings = null;
|
|
_webPlayerEventSettings = null;
|
|
webViewCallback.invoke(new Object[0]);
|
|
}
|
|
|
|
@WebViewExposed
|
|
public static void getErroredSettings(WebViewCallback webViewCallback) {
|
|
if (AdUnit.getAdUnitActivity() == null) {
|
|
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
|
return;
|
|
}
|
|
if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
|
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
|
return;
|
|
}
|
|
Map<String, String> erroredSettings = AdUnit.getAdUnitActivity().getWebPlayer().getErroredSettings();
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
for (Map.Entry<String, String> entry : erroredSettings.entrySet()) {
|
|
jSONObject.put(entry.getKey(), entry.getValue());
|
|
}
|
|
} catch (Exception e) {
|
|
DeviceLog.exception("Error forming JSON object", e);
|
|
}
|
|
webViewCallback.invoke(jSONObject);
|
|
}
|
|
|
|
public static JSONObject getWebPlayerEventSettings() {
|
|
return _webPlayerEventSettings;
|
|
}
|
|
|
|
public static JSONObject getWebPlayerSettings() {
|
|
return _webPlayerSettings;
|
|
}
|
|
|
|
public static JSONObject getWebSettings() {
|
|
return _webSettings;
|
|
}
|
|
|
|
@WebViewExposed
|
|
public static void sendEvent(JSONArray jSONArray, WebViewCallback webViewCallback) {
|
|
if (AdUnit.getAdUnitActivity() == null) {
|
|
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
|
} else if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
|
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
|
} else {
|
|
AdUnit.getAdUnitActivity().getWebPlayer().sendEvent(jSONArray);
|
|
webViewCallback.invoke(new Object[0]);
|
|
}
|
|
}
|
|
|
|
@WebViewExposed
|
|
public static void setData(final String str, final String str2, final String str3, WebViewCallback webViewCallback) {
|
|
if (AdUnit.getAdUnitActivity() == null) {
|
|
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
|
} else if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
|
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
|
} else {
|
|
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.WebPlayer.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (AdUnit.getAdUnitActivity().getWebPlayer() != null) {
|
|
AdUnit.getAdUnitActivity().getWebPlayer().loadData(str, str2, str3);
|
|
}
|
|
}
|
|
});
|
|
webViewCallback.invoke(new Object[0]);
|
|
}
|
|
}
|
|
|
|
@WebViewExposed
|
|
public static void setDataWithUrl(final String str, final String str2, final String str3, final String str4, WebViewCallback webViewCallback) {
|
|
if (AdUnit.getAdUnitActivity() == null) {
|
|
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
|
} else if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
|
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
|
} else {
|
|
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.WebPlayer.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (AdUnit.getAdUnitActivity().getWebPlayer() != null) {
|
|
AdUnit.getAdUnitActivity().getWebPlayer().loadDataWithBaseURL(str, str2, str3, str4, null);
|
|
}
|
|
}
|
|
});
|
|
webViewCallback.invoke(new Object[0]);
|
|
}
|
|
}
|
|
|
|
@WebViewExposed
|
|
public static void setEventSettings(JSONObject jSONObject, WebViewCallback webViewCallback) {
|
|
_webPlayerEventSettings = jSONObject;
|
|
if (AdUnit.getAdUnitActivity() != null && AdUnit.getAdUnitActivity().getWebPlayer() != null) {
|
|
AdUnit.getAdUnitActivity().getWebPlayer().setEventSettings(jSONObject);
|
|
}
|
|
webViewCallback.invoke(new Object[0]);
|
|
}
|
|
|
|
@WebViewExposed
|
|
public static void setSettings(JSONObject jSONObject, JSONObject jSONObject2, WebViewCallback webViewCallback) {
|
|
_webSettings = jSONObject;
|
|
_webPlayerSettings = jSONObject2;
|
|
webViewCallback.invoke(new Object[0]);
|
|
}
|
|
|
|
@WebViewExposed
|
|
public static void setUrl(final String str, WebViewCallback webViewCallback) {
|
|
if (AdUnit.getAdUnitActivity() == null) {
|
|
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
|
} else if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
|
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
|
} else {
|
|
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.WebPlayer.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (AdUnit.getAdUnitActivity().getWebPlayer() != null) {
|
|
AdUnit.getAdUnitActivity().getWebPlayer().loadUrl(str);
|
|
}
|
|
}
|
|
});
|
|
webViewCallback.invoke(new Object[0]);
|
|
}
|
|
}
|
|
}
|