派享便利 v1.0.3版本的 MD5 值为:1fc1776275e6607636a3a1f946b1f976
以下内容为反编译后的 PlusUriAdapter.java 源代码,内容仅作参考
package io.dcloud.feature.weex.adapter;
import android.net.Uri;
import android.text.TextUtils;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.adapter.URIAdapter;
import com.taobao.weex.el.parse.Operators;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.feature.uniapp.adapter.AbsURIAdapter;
import io.dcloud.feature.weex.WeexInstanceMgr;
public class PlusUriAdapter implements URIAdapter {
@Override
public Uri rewrite(WXSDKInstance wXSDKInstance, String str, Uri uri) {
String standardizedURL;
if (!TextUtils.isEmpty(wXSDKInstance.getBundleUrl()) && !PdrUtil.isEmpty(uri)) {
String bundleUrl = wXSDKInstance.getBundleUrl();
String uri2 = uri.toString();
if (uri.isRelative()) {
if (uri.getEncodedPath().length() == 0) {
return Uri.parse(bundleUrl);
}
IWebview findWebview = WeexInstanceMgr.self().findWebview(wXSDKInstance);
if (findWebview != null) {
byte obtainRunningAppMode = findWebview.obtainApp().obtainRunningAppMode();
if (!uri2.startsWith("/storage") && obtainRunningAppMode == 1) {
String convert2AbsFullPath = findWebview.obtainApp().convert2AbsFullPath(bundleUrl, uri2);
if ("web".equals(str)) {
convert2AbsFullPath = findWebview.obtainApp().convert2WebviewFullPath(bundleUrl, uri2);
}
if (convert2AbsFullPath.startsWith("/storage/")) {
standardizedURL = findWebview.obtainApp().convert2WebviewFullPath(bundleUrl, uri2);
} else {
if (convert2AbsFullPath.startsWith(Operators.DIV)) {
convert2AbsFullPath = convert2AbsFullPath.substring(1, convert2AbsFullPath.length());
}
if (str.equals(AbsURIAdapter.FONT)) {
standardizedURL = "local:///" + convert2AbsFullPath;
} else {
standardizedURL = "asset:///" + convert2AbsFullPath;
}
}
} else {
standardizedURL = findWebview.obtainApp().convert2WebviewFullPath(bundleUrl, uri2);
}
} else {
standardizedURL = standardizedURL(bundleUrl, uri2);
}
if (bundleUrl.startsWith("/storage")) {
standardizedURL = DeviceInfo.FILE_PROTOCOL + standardizedURL;
} else if (bundleUrl.startsWith("storage")) {
standardizedURL = "file:///" + standardizedURL;
}
return Uri.parse(standardizedURL);
}
}
return uri;
}
@Override
public Uri rewrite(String str, String str2, Uri uri) {
String uri2 = uri.toString();
if (uri.isRelative()) {
if (uri.getEncodedPath().length() == 0) {
return Uri.parse(str);
}
return Uri.parse(standardizedURL(str, uri2));
}
return uri;
}
private String standardizedURL(String str, String str2) {
if (str2.startsWith("./")) {
str2 = str2.substring(2);
int lastIndexOf = str.lastIndexOf(47);
if (lastIndexOf >= 0) {
return str.substring(0, lastIndexOf + 1) + str2;
}
}
int indexOf = str2.indexOf("../");
int lastIndexOf2 = str.lastIndexOf(47);
if (lastIndexOf2 > -1) {
String substring = str.substring(0, lastIndexOf2);
while (indexOf > -1) {
str2 = str2.substring(3);
substring = substring.substring(0, substring.lastIndexOf(47));
indexOf = str2.indexOf("../");
}
return substring + '/' + str2;
}
return str2;
}
}