| | |
| | | |
| | | import android.Manifest; |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.demo.app.utils.Constant; |
| | | import com.demo.app.utils.JumpActivityUtil; |
| | | import com.demo.lib.common.dialog.DialogUtil; |
| | | import com.demo.lib.common.util.ui.LoadingDialogUtil; |
| | | import com.demo.library_ec.AlibcTradeUtil; |
| | | import com.demo.lib.common.util.Environment; |
| | | import com.demo.lib.common.util.common.StringUtils; |
| | |
| | | ImageView iv_right; |
| | | WebView webview; |
| | | private boolean boo = false; |
| | | private Dialog loadingDialog; |
| | | |
| | | public MyJavaInterface(Activity activity, WebView webview) { |
| | | super(activity); |
| | | mContext = activity; |
| | | this.webview = webview; |
| | | boo = true; |
| | | loadingDialog = LoadingDialogUtil.getLoadingDialog(activity, ""); |
| | | } |
| | | |
| | | public MyJavaInterface(Activity activity, TextView tv_top_bar_middle |
| | |
| | | this.tv_top_bar_right = tv_top_bar_right; |
| | | this.iv_right = iv_right; |
| | | this.webview = webview; |
| | | loadingDialog = LoadingDialogUtil.getLoadingDialog(activity, ""); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | |
| | | AlibcTradeUtil.openAuthLink(mContext, url); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void showLoading() { |
| | | |
| | | mContext.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | DialogUtil.show(loadingDialog); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void hideLoading() { |
| | | mContext.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 判断权限集合 是否授权 false授权 true未授权 |
| | | public boolean lacksPermissions(String... permissions) { |
| | | for (String permission : permissions) { |
| | |
| | | ActivityCompat.requestPermissions(mContext, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 10023); |
| | | } else {//存储权限已开 |
| | | String md5 = MD5Utils.getMD532(url); |
| | | String path = Environment.getExternalStorageDirectory() |
| | | + "/hanju"; |
| | | String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) |
| | | + "/" + Constant.DOWNLOAD_DIR_NAME; |
| | | if (!new File(path).exists()) { |
| | | new File(path).mkdirs(); |
| | | } |
| | | |
| | | File file = new File(path + "/" + md5 + ".jpg"); |
| | | if (!file.exists()) { |
| | | try { |