Commit cb277c4f by 严久程

h5重定向后路由加载失败的问题

parent 8b67ef7a
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......@@ -251,7 +251,7 @@ ext {
"ydl-pushagent" : "com.ydl:ydl-pushagent:0.1.9",
"ydl-notracepoint" : "com.ydl:notracepoint-lib:0.1.8@aar",
"ydl-js" : "com.ydl:ydl-js:1.0.7-SNAPSHOT@aar",
"ydl-router" : "com.ydl:ydl-router:1.3.2-SNAPSHOT@aar",
"ydl-router" : "com.ydl:ydl-router:1.3.7-SNAPSHOT@aar",
"xrecyclerview" : "com.ydl:xrecyclerview:1.0.0-SNAPSHOT@aar",
"arouter-api" : "com.alibaba:arouter-api:1.4.1",
"arouter-compiler" : "com.alibaba:arouter-compiler:1.2.2",
......
......@@ -304,7 +304,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
@NotNull
@Override
public StatusBarOptions getStatusViewOptions() {
return new StatusBarOptions(true,true);
return new StatusBarOptions(true, true);
}
@Override
......@@ -331,7 +331,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
}
setUrlHeightParams();
EventBus.getDefault().register(this);
jtoJHandle = WebModularServiceUtils.Companion.getWebService().getJavascripHandler(this,tellData = tellData);
jtoJHandle = WebModularServiceUtils.Companion.getWebService().getJavascripHandler(this, tellData = tellData);
appFrom = BaseApp.instance.getGlobalConfig().getAppFrom();
init();
......@@ -396,11 +396,11 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
return pinjie(resultUrl);
}
private String pinjie(String jumpUrl){
if (jumpUrl.contains("hideNavBar=1")){
private String pinjie(String jumpUrl) {
if (jumpUrl.contains("hideNavBar=1")) {
hideJavaTitleBar();
return jumpUrl;
}else if (jumpUrl.contains("hideNavBar=2")){
} else if (jumpUrl.contains("hideNavBar=2")) {
showTitleBar();
return jumpUrl;
}
......@@ -500,7 +500,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
}
}
public void showTitleBar(){
public void showTitleBar() {
tb_title.setVisibility(VISIBLE);
if (null != getStatusView()) {
......@@ -634,16 +634,18 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Boolean overridePayUrl = shouldOverridePayUrl(view, url);
if(overridePayUrl != null) {
if (overridePayUrl != null) {
return overridePayUrl;
}
if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
loadUrl(setUrlHeightParams(url));
} else {
if (YDLRouterManager.Companion.router(url)) {
} else {
loadUrl(setUrlHeightParams(url));
}
}
return true;
}
......@@ -710,16 +712,22 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Boolean overridePayUrl = shouldOverridePayUrl(view, url);
if(overridePayUrl!=null) {
if (overridePayUrl != null) {
return overridePayUrl;
}
if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
loadUrl(setUrlHeightParams(url));
} else {
if (YDLRouterManager.Companion.router(url)) {
} else {
loadUrl(setUrlHeightParams(url));
}
}
return true;
}
......@@ -755,7 +763,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
tb_title.setImageVis(1);
}
} else {
tb_title.setImage(getResources().getDrawable(YDLConstants.FROM_YDL.equals(appFrom)?R.drawable.platform_toolbar_back :R.drawable.platform_toolbar_back_yellow));
tb_title.setImage(getResources().getDrawable(YDLConstants.FROM_YDL.equals(appFrom) ? R.drawable.platform_toolbar_back : R.drawable.platform_toolbar_back_yellow));
tb_title.setmLeftText("");
tb_title.setImageListener(v -> {
if (h5Params.getShowUrlTitle()) {
......@@ -831,7 +839,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
return true;
}
} else if (url.startsWith("alipays://") || url.startsWith("alipay")) {
try{
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
} catch (Exception e) {
......@@ -848,7 +856,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
// 处理微信 H5 支付跳转时验证请求头 referer 失效
// 验证不通过会出现“商家参数格式有误,请联系商家解决”
if (url.contains("wx.tenpay.com")){
if (url.contains("wx.tenpay.com")) {
// 申请微信 H5 支付时填写的域名
// 比如经常用来测试网络连通性的 http://www.baidu.com
......@@ -857,12 +865,12 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
String redirectUrlStr = parse.getQueryParameter("redirect_url");
Uri redirectUrl = Uri.parse(redirectUrlStr);
// 申请微信 H5 支付时填写的域名
String referer = redirectUrl.getScheme()+"://"+redirectUrl.getHost();
String referer = redirectUrl.getScheme() + "://" + redirectUrl.getHost();
// 兼容 Android 4.4.3 和 4.4.4 两个系统版本设置 referer 无效的问题
if (("4.4.3".equals(Build.VERSION.RELEASE))
|| ("4.4.4".equals(Build.VERSION.RELEASE))) {
if (firstVisitWXH5PayUrl){
if (firstVisitWXH5PayUrl) {
view.loadDataWithBaseURL(referer, "<script>window.location.href=\"" + url + "\";</script>",
"text/html", "utf-8", null);
// 修改标记位状态,避免循环调用
......@@ -878,7 +886,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
view.loadUrl(url, map);
return true;
}
}else if(url.contains("alipay")) {
} else if (url.contains("alipay")) {
return false;
}
......@@ -907,11 +915,11 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
}
public void onEvent(RefreshWebEvent event) {
if(event.isClearHistory) {
if (event.isClearHistory) {
wv_content.clearCache(true);
wv_content.clearHistory();
loadUrl(h5Params.getUrl());
}else{
} else {
//刷新页面
loadUrl(h5Params.getUrl());
shouldClearHistory = true;
......@@ -977,7 +985,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
}
String resultUrl = h5Params.getSuffix() ? TemporaryUtils.getSuffix(url) : url;
Log.e("AAAA",resultUrl);
Log.e("AAAA", resultUrl);
wv_content.loadUrl(resultUrl);
pointBI(resultUrl);
}
......@@ -994,7 +1002,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
private void initHead() {
// header
final MaterialHeader header = new MaterialHeader(this);
int[] colors = new int[]{getResources().getColor(YDLConstants.FROM_YDL.equals(appFrom)?R.color.platform_google_green :R.color.platform_google_yellow)};
int[] colors = new int[]{getResources().getColor(YDLConstants.FROM_YDL.equals(appFrom) ? R.color.platform_google_green : R.color.platform_google_yellow)};
header.setColorSchemeColors(colors);
header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
int padding = (int) getResources().getDimension(R.dimen.platform_default_dis_size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment