MyRecorder v1.01.90.0219版本的 MD5 值为:c361f51174a0bf833abfa72929caf8d3
以下内容为反编译后的 MraidJsBridge.java 源代码,内容仅作参考
package com.smaato.sdk.richmedia.mraid.bridge;
import android.net.Uri;
import android.webkit.WebView;
import com.smaato.sdk.core.log.LogDomain;
import com.smaato.sdk.core.log.Logger;
import com.smaato.sdk.core.util.Objects;
import com.smaato.sdk.core.util.TextUtils;
import com.smaato.sdk.core.util.collections.Maps;
import com.smaato.sdk.core.util.fi.Consumer;
import com.smaato.sdk.richmedia.mraid.MraidUtils;
import com.smaato.sdk.richmedia.mraid.bridge.MraidJsBridge;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public final class MraidJsBridge {
private final Map<String, MraidCommandHandler> handlers = Collections.synchronizedMap(new HashMap());
private final Logger logger;
private final WebView webView;
public MraidJsBridge(WebView webView, Logger logger) {
this.webView = (WebView) Objects.requireNonNull(webView);
this.logger = (Logger) Objects.requireNonNull(logger);
}
private void fireNativeCallCompleteEvent() {
runScript("window.mraidbridge.nativeCallComplete();");
}
private Map<String, String> getQueryParamMap(Uri uri) {
HashMap hashMap = new HashMap();
for (String str : uri.getQueryParameterNames()) {
String queryParameter = uri.getQueryParameter(str);
if (queryParameter != null) {
hashMap.put(str, queryParameter);
}
}
return Maps.toImmutableMap(hashMap);
}
private void handleCommand(String str, Map<String, String> map, boolean z7) {
MraidCommandHandler mraidCommandHandler = this.handlers.get(str);
if (mraidCommandHandler != null) {
mraidCommandHandler.handle(map, z7);
return;
}
Logger logger = this.logger;
LogDomain logDomain = LogDomain.MRAID;
logger.debug(logDomain, "A handler for command \"" + str + "\" is not registered", new Object[0]);
}
public void lambda$handleMraidUrl$0(Uri uri, boolean z7, String str) {
handleCommand(str, getQueryParamMap(uri), z7);
}
public void addCommandHandler(String str, MraidCommandHandler mraidCommandHandler) {
if (TextUtils.isEmpty(str)) {
return;
}
this.handlers.put(str, mraidCommandHandler);
}
public void fireReadyEvent() {
runScript("window.mraidbridge.fireReadyEvent();");
}
public void handleMraidUrl(String str, final boolean z7) {
final Uri parse = Uri.parse(str);
Objects.onNotNull(parse.getHost(), new Consumer() {
@Override
public final void accept(Object obj) {
MraidJsBridge.this.lambda$handleMraidUrl$0(parse, z7, (String) obj);
}
});
fireNativeCallCompleteEvent();
}
public void runScript(String str) {
Logger logger = this.logger;
LogDomain logDomain = LogDomain.MRAID;
logger.info(logDomain, "Running script: " + str, new Object[0]);
this.webView.loadUrl(MraidUtils.format("javascript:%s", str));
}
}