|
@@ -43,9 +43,11 @@ import com.cooleshow.base.BuildConfig;
|
|
|
import com.cooleshow.base.bean.WxPayResult;
|
|
|
import com.cooleshow.base.common.WebConstants;
|
|
|
import com.cooleshow.base.constanst.Constants;
|
|
|
+import com.cooleshow.base.constanst.StyleConfig;
|
|
|
import com.cooleshow.base.data.net.RetrofitClientNoToken;
|
|
|
import com.cooleshow.base.ui.fragment.BaseMVPFragment;
|
|
|
import com.cooleshow.base.utils.AppUtils;
|
|
|
+import com.cooleshow.base.utils.LOG;
|
|
|
import com.cooleshow.base.utils.PermissionUtils;
|
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
|
import com.cooleshow.base.utils.UiUtils;
|
|
@@ -130,6 +132,8 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
|
|
|
RelativeLayout rl_activity_html;
|
|
|
LinearLayout ll_activity_html;
|
|
|
|
|
|
+ private boolean isLoadError = false;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
@@ -340,8 +344,8 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
|
|
|
jsonObject.put("api", "downloadFile");
|
|
|
onSendMessage(jsonObject.toString());
|
|
|
}
|
|
|
- }else{
|
|
|
- UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请打开存储权限");
|
|
|
+ } else {
|
|
|
+ UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请打开存储权限");
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -379,7 +383,7 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
|
|
|
String imageBase64 = content.getString("image");
|
|
|
/*增加自定义按钮的分享面板*/
|
|
|
mShareAction = new ShareAction(getActivity()).setDisplayList(
|
|
|
- SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA)
|
|
|
+ SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA)
|
|
|
.setShareboardclickCallback(new ShareBoardlistener() {
|
|
|
@Override
|
|
|
public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
|
|
@@ -800,12 +804,16 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
|
|
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
super.onPageStarted(view, url, favicon);
|
|
|
webViewUrl = url;
|
|
|
+ isLoadError = false;
|
|
|
}
|
|
|
|
|
|
//页面载入结束时调用
|
|
|
@Override
|
|
|
public void onPageFinished(WebView view, String url) {
|
|
|
super.onPageFinished(view, url);
|
|
|
+ if (!isLoadError) {
|
|
|
+ showWebView();
|
|
|
+ }
|
|
|
webViewUrl = url;
|
|
|
if (!TextUtils.isEmpty(authorization)) {
|
|
|
String js = "window.localStorage.setItem('Authorization','" + authorization + "');";
|
|
@@ -842,11 +850,45 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
|
|
|
//处理报错信息
|
|
|
@Override
|
|
|
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
|
|
- super.onReceivedError(view, request, error);
|
|
|
+// super.onReceivedError(view, request, error);
|
|
|
+ if (error != null) {
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
|
+ LOG.i("onReceivedError:" + error.getErrorCode());
|
|
|
+ LOG.i("onReceivedError:" + error.getDescription());
|
|
|
+ if (error.getErrorCode() == WebViewClient.ERROR_HOST_LOOKUP || error.getErrorCode() == WebViewClient.ERROR_CONNECT) {
|
|
|
+ showLoadErrorView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void showWebView() {
|
|
|
+ viewParent.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void hideErrorView() {
|
|
|
+ mViewBinding.flError.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showLoadErrorView() {
|
|
|
+ isLoadError = true;
|
|
|
+ viewParent.setVisibility(View.GONE);
|
|
|
+ mViewBinding.flError.setVisibility(View.VISIBLE);
|
|
|
+ mViewBinding.errorView.hideBack();
|
|
|
+ mViewBinding.errorView.setIcon(com.cooleshow.base.R.drawable.icon_error_tip);
|
|
|
+ mViewBinding.errorView.setOnRefreshClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (webView != null) {
|
|
|
+ webView.reload();
|
|
|
+ hideErrorView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
public void clickBack() {
|
|
|
if (webView.canGoBack()) {
|
|
|
webView.goBack();
|