绒毛墙 v1.2.2版本的 MD5 值为:c016c327d19b09a996218d3acd478b85
以下内容为反编译后的 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 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 type, 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(type)) {
convert2AbsFullPath = findWebview.obtainApp().convert2WebviewFullPath(bundleUrl, uri2);
}
if (convert2AbsFullPath.startsWith("/storage/")) {
standardizedURL = findWebview.obtainApp().convert2WebviewFullPath(bundleUrl, uri2);
} else {
if (convert2AbsFullPath.startsWith("/")) {
convert2AbsFullPath = convert2AbsFullPath.substring(1, convert2AbsFullPath.length());
}
if (type.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 bundleURL, String type, Uri uri) {
String uri2 = uri.toString();
if (uri.isRelative()) {
if (uri.getEncodedPath().length() == 0) {
return Uri.parse(bundleURL);
}
return Uri.parse(standardizedURL(bundleURL, uri2));
}
return uri;
}
private String standardizedURL(String basePath, String pPath) {
if (pPath.startsWith("./")) {
pPath = pPath.substring(2);
int lastIndexOf = basePath.lastIndexOf(47);
if (lastIndexOf >= 0) {
return basePath.substring(0, lastIndexOf + 1) + pPath;
}
}
int indexOf = pPath.indexOf("../");
int lastIndexOf2 = basePath.lastIndexOf(47);
if (lastIndexOf2 > -1) {
String substring = basePath.substring(0, lastIndexOf2);
while (indexOf > -1) {
pPath = pPath.substring(3);
substring = substring.substring(0, substring.lastIndexOf(47));
indexOf = pPath.indexOf("../");
}
return substring + '/' + pPath;
}
return pPath;
}
}