| | |
| | | |
| | | 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.Toast; |
| | | |
| | | import com.ysvideo.zhibo.app.util.JumpActivityUtil; |
| | | import com.ysvideo.zhibo.lib.common.dialog.DialogUtil; |
| | | import com.ysvideo.zhibo.lib.common.dialog.LoadingDialogUtil; |
| | | import com.ysvideo.zhibo.lib.common.util.Environment; |
| | | import com.ysvideo.zhibo.lib.common.util.common.StringUtils; |
| | | import com.ysvideo.zhibo.lib.common.util.security.MD5Utils; |
| | |
| | | TextView tv_top_bar_middle, tv_top_bar_left2, tv_top_bar_right; |
| | | ImageView iv_right; |
| | | private boolean boo = false; |
| | | private Dialog loadingDialog = null; |
| | | |
| | | public MyJavaInterface(Activity activity) { |
| | | super(activity); |
| | | mContext = activity; |
| | | boo = true; |
| | | loadingDialog = LoadingDialogUtil.getLoadingDialog(activity, ""); |
| | | } |
| | | |
| | | public MyJavaInterface(Activity activity, TextView tv_top_bar_middle |
| | |
| | | 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) |
| | | + "/zhibo"; |
| | | if (!new File(path).exists()) { |
| | | new File(path).mkdirs(); |
| | | } |
| | | |
| | | File file = new File(path + "/" + md5 + ".jpg"); |
| | | if (!file.exists()) { |
| | | try { |
| | |
| | | success = true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); |
| | | } |
| | | |
| | | if (success) { |