|
@@ -73,9 +73,11 @@ import com.cooleshow.base.utils.LogUtils;
|
|
|
import com.cooleshow.base.utils.NetworkUtil;
|
|
|
import com.cooleshow.base.utils.PermissionUtils;
|
|
|
import com.cooleshow.base.utils.ScreenUtils;
|
|
|
+import com.cooleshow.base.utils.SizeUtils;
|
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
|
import com.cooleshow.base.utils.UiUtils;
|
|
|
import com.cooleshow.base.utils.UriUtils;
|
|
|
+import com.cooleshow.base.utils.Utils;
|
|
|
import com.cooleshow.base.utils.WebParamsUtils;
|
|
|
import com.cooleshow.base.utils.helper.CommonShareHelper;
|
|
|
import com.cooleshow.base.utils.helper.DialogHelper;
|
|
@@ -269,6 +271,14 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
isNeedResetScreenOrientation = c_orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
|
|
|
LOG.i("c_orientation:" + c_orientation + "--isNeedResetScreenOrientation:" + isNeedResetScreenOrientation);
|
|
|
|
|
|
+
|
|
|
+ boolean isShowLoadingAnim = intent.getBooleanExtra(WebConstants.WEB_SHOW_LOADINGANIM, false);
|
|
|
+ if (isShowLoadingAnim) {
|
|
|
+ //显示loading的时候隐藏顶部状态栏
|
|
|
+ QMUIStatusBarHelper.hideStatusBar(this);
|
|
|
+ viewBinding.loadingLayout.startShow();
|
|
|
+ }
|
|
|
+
|
|
|
setStatusBarTextColor(intent.getBooleanExtra("statusBarTextColor", false));
|
|
|
if (isHideTitle) {
|
|
|
headerBbarView.setVisibility(View.GONE);
|
|
@@ -290,6 +300,13 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
finish();
|
|
|
});
|
|
|
|
|
|
+ viewBinding.loadingLayout.setBackClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
try {
|
|
|
if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) {
|
|
@@ -584,7 +601,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
String publicDirectoryMusic = FileUtils.getPublicDirectoryMusic();
|
|
|
String fileLastPath = publicDirectoryMusic + "/yyszkt/" + fileName;
|
|
|
String tip = "音频已保存到以下地址: 手机存储/Music/yyszkt/" + fileName;
|
|
|
- UiUtils.showSaveCopyDialog(getSupportFragmentManager(),HtmlActivity.this,"保存成功", tip,fileLastPath);
|
|
|
+ UiUtils.showSaveCopyDialog(getSupportFragmentManager(), HtmlActivity.this, "保存成功", tip, fileLastPath);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -600,12 +617,12 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void downloadFile(String url,String fileName) {
|
|
|
+ public void downloadFile(String url, String fileName) {
|
|
|
if (TextUtils.isEmpty(url)) {
|
|
|
ToastUtil.getInstance().showShort("文件异常");
|
|
|
return;
|
|
|
}
|
|
|
- String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE};
|
|
|
+ String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
|
|
|
PermissionTipHelper.getInstance().showTipDialog(this, permissions);
|
|
|
new RxPermissions(this)
|
|
|
.request(permissions)
|
|
@@ -1155,7 +1172,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
}
|
|
|
DownloadFileTipDialog dialog = new DownloadFileTipDialog(this);
|
|
|
dialog.show();
|
|
|
- dialog.setData(title,content);
|
|
|
+ dialog.setData(title, content);
|
|
|
dialog.handleTitleBg(false);
|
|
|
dialog.setOnEventListener(new DownloadFileTipDialog.OnEventListener() {
|
|
|
@Override
|
|
@@ -1207,7 +1224,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
public void onPageFinished(WebView view, String url) {
|
|
|
super.onPageFinished(view, url);
|
|
|
if (!isLoadError) {
|
|
|
- isLoadCompleted =true;
|
|
|
+ isLoadCompleted = true;
|
|
|
showWebView();
|
|
|
}
|
|
|
if (!TextUtils.isEmpty(authorization)) {
|
|
@@ -1272,14 +1289,14 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
LOG.i("onReceivedError:" + error.getErrorCode());
|
|
|
LOG.i("onReceivedError:" + error.getDescription());
|
|
|
int errorCode = error.getErrorCode();
|
|
|
- if (errorCode== WebViewClient.ERROR_HOST_LOOKUP || errorCode == WebViewClient.ERROR_CONNECT || errorCode == WebViewClient.ERROR_PROXY_AUTHENTICATION) {
|
|
|
+ if (errorCode == WebViewClient.ERROR_HOST_LOOKUP || errorCode == WebViewClient.ERROR_CONNECT || errorCode == WebViewClient.ERROR_PROXY_AUTHENTICATION) {
|
|
|
if (isLoadCompleted) {
|
|
|
//20240827同步加载完后的error不需要显示 错误页
|
|
|
return;
|
|
|
}
|
|
|
showLoadErrorView();
|
|
|
- }else {
|
|
|
- if(error.getErrorCode() == WebViewClient.ERROR_UNKNOWN){
|
|
|
+ } else {
|
|
|
+ if (error.getErrorCode() == WebViewClient.ERROR_UNKNOWN) {
|
|
|
return;
|
|
|
}
|
|
|
String errorMsg = "url:" + request.getUrl().toString() + " " + error.getDescription();
|
|
@@ -1702,6 +1719,9 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
+ if (viewBinding != null) {
|
|
|
+ viewBinding.loadingLayout.release();
|
|
|
+ }
|
|
|
super.onDestroy();
|
|
|
if (null != webView) {
|
|
|
webView.destroy();
|
|
@@ -1768,8 +1788,8 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
|
|
|
@Override
|
|
|
public void checkCoursewareCache(JSONObject jsonObject) {
|
|
|
- String [] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
|
|
|
- PermissionTipHelper.getInstance().showTipDialog(this,permissions);
|
|
|
+ String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
|
|
|
+ PermissionTipHelper.getInstance().showTipDialog(this, permissions);
|
|
|
new RxPermissions(this)
|
|
|
.request(permissions)
|
|
|
.subscribe(permission -> {
|
|
@@ -1800,8 +1820,8 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
if (!checkActivityExist()) {
|
|
|
return;
|
|
|
}
|
|
|
- String [] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
|
|
|
- PermissionTipHelper.getInstance().showTipDialog(this,permissions);
|
|
|
+ String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
|
|
|
+ PermissionTipHelper.getInstance().showTipDialog(this, permissions);
|
|
|
new RxPermissions(this)
|
|
|
.request(permissions)
|
|
|
.subscribe(permission -> {
|
|
@@ -1819,6 +1839,31 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void cloudLoading(JSONObject jsonObject) {
|
|
|
+ try {
|
|
|
+ JSONObject content = jsonObject.getJSONObject("content");
|
|
|
+ boolean show = content.optBoolean("show", false);
|
|
|
+ if (webView != null) {
|
|
|
+ webView.post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (viewBinding != null) {
|
|
|
+ if (show) {
|
|
|
+ viewBinding.loadingLayout.startShow();
|
|
|
+ } else {
|
|
|
+ viewBinding.loadingLayout.stopAndHide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ onSendMessage(jsonObject.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void showWifiTipDialog(String data) {
|
|
|
CommonConfirmDialog2 commonDialog2 = new CommonConfirmDialog2(this);
|
|
|
commonDialog2.show();
|