i自然 v1.5.2版本的 MD5 值为:4186de3133535afd3ad8a76e7e4d0eff
以下内容为反编译后的 WebDelegate.java 源代码,内容仅作参考
package com.mnr.app.delegate;
import android.app.Activity;
import android.text.TextUtils;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mnr.app.R;
import com.mnr.app.app.AppCache;
import com.mnr.app.app.Myapp;
import com.mnr.app.net.UrlConstKt;
import com.mnr.app.splash.bean.AppConfig;
import com.mnr.app.umeng.ShareHelper;
import com.mnr.app.umeng.bean.JsShareInfoBean;
import com.mnr.app.umeng.bean.ShareInfoBean;
import com.mnr.dependencies.Utils.Loger;
import com.tencent.open.SocialConstants;
import com.umeng.socialize.bean.HandlerRequestCode;
import com.umeng.socialize.bean.SHARE_MEDIA;
import java.util.Map;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J@\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\b\b\u0002\u0010\t\u001a\u00020\n2\b\b\u0002\u0010\u000b\u001a\u00020\f2\n\b\u0002\u0010\r\u001a\u0004\u0018\u00010\u000e2\b\b\u0002\u0010\u000f\u001a\u00020\fJZ\u0010\u0010\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\b\b\u0002\u0010\u0011\u001a\u00020\n2\b\b\u0002\u0010\u0012\u001a\u00020\n2\b\b\u0002\u0010\u0013\u001a\u00020\n2\b\b\u0002\u0010\u000b\u001a\u00020\f2\n\b\u0002\u0010\r\u001a\u0004\u0018\u00010\u000e2\b\b\u0002\u0010\u000f\u001a\u00020\f2\n\b\u0002\u0010\u0014\u001a\u0004\u0018\u00010\nH\u0002¨\u0006\u0015"}, d2 = {"Lcom/mnr/app/delegate/WebDelegate;", "", "()V", "getShareInfo", "", "activity", "Landroid/app/Activity;", "webView", "Landroid/webkit/WebView;", "defaultTitle", "", "articleID", "", "shareMedia", "Lcom/umeng/socialize/bean/SHARE_MEDIA;", "tag", "setShareData", "title", "imageUrl", "des", "linkUrl", "app_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class WebDelegate {
public static final WebDelegate INSTANCE = new WebDelegate();
private WebDelegate() {
}
public static void getShareInfo$default(WebDelegate webDelegate, Activity activity, WebView webView, String str, int i, SHARE_MEDIA share_media, int i2, int i3, Object obj) {
if ((i3 & 4) != 0) {
str = "";
}
String str2 = str;
int i4 = (i3 & 8) != 0 ? 0 : i;
if ((i3 & 16) != 0) {
share_media = null;
}
webDelegate.getShareInfo(activity, webView, str2, i4, share_media, (i3 & 32) != 0 ? 0 : i2);
}
public final void getShareInfo(final Activity activity, final WebView webView, final String defaultTitle, final int articleID, final SHARE_MEDIA shareMedia, final int tag) {
Intrinsics.checkNotNullParameter(activity, "activity");
Intrinsics.checkNotNullParameter(webView, "webView");
Intrinsics.checkNotNullParameter(defaultTitle, "defaultTitle");
webView.evaluateJavascript("javascript:getShareInfo()", new ValueCallback() {
@Override
public final void onReceiveValue(Object obj) {
WebDelegate.m125getShareInfo$lambda1(webView, articleID, activity, shareMedia, tag, defaultTitle, (String) obj);
}
});
}
public static final void m125getShareInfo$lambda1(final WebView webView, final int i, final Activity activity, final SHARE_MEDIA share_media, int i2, final String defaultTitle, String it) {
Intrinsics.checkNotNullParameter(webView, "$webView");
Intrinsics.checkNotNullParameter(activity, "$activity");
Intrinsics.checkNotNullParameter(defaultTitle, "$defaultTitle");
Loger.e("123", "getShareInfo:" + it);
if (TextUtils.isEmpty(it) || it.equals("null")) {
webView.evaluateJavascript("javascript:window.RRXAPI.getShareInfo()", new ValueCallback() {
@Override
public final void onReceiveValue(Object obj) {
WebDelegate.m126getShareInfo$lambda1$lambda0(activity, share_media, defaultTitle, i, webView, (String) obj);
}
});
return;
}
Intrinsics.checkNotNullExpressionValue(it, "it");
String replace$default = StringsKt.replace$default(it, "\\", "", false, 4, (Object) null);
if (StringsKt.startsWith$default(replace$default, "\"", false, 2, (Object) null) || StringsKt.endsWith$default(replace$default, "\"", false, 2, (Object) null)) {
replace$default = replace$default.substring(1, replace$default.length() - 1);
Intrinsics.checkNotNullExpressionValue(replace$default, "this as java.lang.String…ing(startIndex, endIndex)");
}
JsShareInfoBean jsShareInfoBean = (JsShareInfoBean) new Gson().fromJson(replace$default, JsShareInfoBean.class);
if (jsShareInfoBean != null) {
WebDelegate webDelegate = INSTANCE;
String title = jsShareInfoBean.getTitle();
String imgUrl = jsShareInfoBean.getImgUrl();
String description = jsShareInfoBean.getDescription();
if (description == null) {
description = "";
}
String url = webView.getUrl();
Intrinsics.checkNotNullExpressionValue(title, "title");
Intrinsics.checkNotNullExpressionValue(imgUrl, "imgUrl");
webDelegate.setShareData(activity, title, imgUrl, description, i, share_media, i2, url);
return;
}
setShareData$default(INSTANCE, activity, defaultTitle, null, null, i, share_media, i2, null, HandlerRequestCode.TWITTER_REQUEST_AUTH_CODE, null);
}
public static final void m126getShareInfo$lambda1$lambda0(Activity activity, SHARE_MEDIA share_media, String defaultTitle, int i, WebView webView, String str) {
Intrinsics.checkNotNullParameter(activity, "$activity");
Intrinsics.checkNotNullParameter(defaultTitle, "$defaultTitle");
Intrinsics.checkNotNullParameter(webView, "$webView");
if (str != null && !TextUtils.isEmpty(str) && !str.equals("null")) {
Map map = (Map) new Gson().fromJson(str, new TypeToken<Map<String, ? extends Object>>() {
}.getType());
setShareData$default(INSTANCE, activity, String.valueOf(map.get("title")), String.valueOf(map.get("image")), String.valueOf(map.get(SocialConstants.PARAM_APP_DESC)), 0, share_media, 0, String.valueOf(map.get("url")), 64, null);
} else {
setShareData$default(INSTANCE, activity, defaultTitle, null, null, i, null, 0, webView.getUrl(), 108, null);
}
Loger.e("123", "javascript:window.RRXAPI.getShareInfo()===============" + str);
}
static void setShareData$default(WebDelegate webDelegate, Activity activity, String str, String str2, String str3, int i, SHARE_MEDIA share_media, int i2, String str4, int i3, Object obj) {
webDelegate.setShareData(activity, (i3 & 2) != 0 ? "" : str, (i3 & 4) != 0 ? "" : str2, (i3 & 8) == 0 ? str3 : "", (i3 & 16) != 0 ? 0 : i, (i3 & 32) != 0 ? null : share_media, (i3 & 64) == 0 ? i2 : 0, (i3 & 128) == 0 ? str4 : null);
}
private final void setShareData(Activity activity, String title, String imageUrl, String des, int articleID, SHARE_MEDIA shareMedia, int tag, String linkUrl) {
String str;
AppConfig config = AppCache.INSTANCE.getConfig();
String valueOf = String.valueOf(config != null ? config.getWebUrl() : null);
String str2 = tag == 0 ? "news.html?id=" : "media-article.html?id=";
boolean z = false;
if (articleID != 0) {
if (StringsKt.endsWith$default(valueOf, "/", false, 2, (Object) null)) {
linkUrl = valueOf + str2 + articleID;
} else {
linkUrl = valueOf + '/' + str2 + articleID;
}
}
ShareInfoBean shareInfoBean = new ShareInfoBean();
if (TextUtils.isEmpty(title)) {
title = Myapp.INSTANCE.getApp().getString(R.string.app_name);
}
shareInfoBean.articleTitle = title;
shareInfoBean.imageUrl = imageUrl;
if (TextUtils.isEmpty(des)) {
des = Myapp.INSTANCE.getApp().getString(R.string.app_name);
}
shareInfoBean.articleDesc = des;
shareInfoBean.url = linkUrl;
shareInfoBean.articleID = String.valueOf(articleID);
shareInfoBean.tag = tag;
AppConfig config2 = AppCache.INSTANCE.getConfig();
String webUrl = config2 != null ? config2.getWebUrl() : null;
if (webUrl != null && StringsKt.endsWith$default(webUrl, "/", false, 2, (Object) null)) {
z = true;
}
if (z) {
str = webUrl + UrlConstKt.POSTER_URL + articleID;
} else {
str = webUrl + "/app/html/poster.html?id=" + articleID;
}
shareInfoBean.postUrl = str;
if (tag == 1) {
shareInfoBean.postUrl += "&type=1";
}
if (shareMedia == null) {
ShareHelper.INSTANCE.show(activity, shareInfoBean);
} else {
ShareHelper.INSTANCE.shareTo(activity, shareMedia, shareInfoBean);
}
}
}