| | |
| | | import com.tejia.lijin.app.entity.share.ShareImageEntity; |
| | | import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog; |
| | | import com.tejia.lijin.app.ui.invite.ShareBrowserActivity; |
| | | import com.tejia.lijin.app.updateApp.UpdateApp; |
| | | import com.tejia.lijin.app.util.JumpActivityUtil; |
| | | import com.tejia.lijin.app.util.PermissionHelper; |
| | | import com.tejia.lijin.app.util.ToastUtil; |
| | |
| | | } else {//存储权限已开 |
| | | String md5 = MD5Utils.getMD532(url.toString()); |
| | | String path = com.wpc.library.util.Environment.getExternalStorageDirectory() |
| | | + "/blksapp"; |
| | | + "/tejiaapp"; |
| | | File file = new File(path + "/" + md5 + ".jpg"); |
| | | if (!file.exists()) { |
| | | try { |
| | |
| | | |
| | | } else { |
| | | Toast.makeText(mContext, "图片已经保存!", Toast.LENGTH_LONG).show(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 异步保存图片 |
| | | * |
| | | * @param args |
| | | * @param handler |
| | | * @throws JSONException |
| | | */ |
| | | public void savePictureAsync(Object args, final CompletionHandler handler) throws JSONException { |
| | | JSONObject jsonObject = new JSONObject(args.toString()); |
| | | String url = jsonObject.optString("url"); |
| | | if (mPermissionsChecker == null) |
| | | mPermissionsChecker = new PermissionHelper(mContext, this); |
| | | if (mPermissionsChecker.lacksPermissions(getPermissions())) { //存储权限未开启 |
| | | mPermissionsChecker.showNormalDialog(); |
| | | } else {//存储权限已开 |
| | | String md5 = MD5Utils.getMD532(url); |
| | | String path = com.wpc.library.util.Environment.getExternalStorageDirectory() |
| | | + "/tejiaapp"; |
| | | File file = new File(path + "/" + md5 + ".jpg"); |
| | | if (!file.exists()) { |
| | | try { |
| | | File resultFile = Tools.saveImageFromPathToSdCard(mContext, url, path, md5 + ".jpg"); |
| | | if (resultFile != null) { |
| | | JSONObject result = new JSONObject(); |
| | | result.put("code", 0); |
| | | result.put("msg", "保存成功"); |
| | | handler.complete(result); |
| | | } |
| | | } catch (Exception e) { |
| | | JSONObject result = new JSONObject(); |
| | | result.put("code", 1); |
| | | result.put("msg", "图片保存失败"); |
| | | handler.complete(result); |
| | | if (file.exists()) |
| | | file.delete(); |
| | | } |
| | | |
| | | } else { |
| | | JSONObject result = new JSONObject(); |
| | | result.put("code", 2); |
| | | result.put("msg", "图片已经保存"); |
| | | handler.complete(result); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | @JavascriptInterface |
| | | public void hiddenTopMenuCloseBtn() { |
| | | public void hiddenTopMenuCloseBtn(Object obj) { |
| | | if (!boo) |
| | | tv_top_bar_left2.setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | @JavascriptInterface |
| | | public void hideLoading() { |
| | | public void hideLoading(Object obj) { |
| | | if (!boo) |
| | | iv_right.post(new Runnable() { |
| | | @Override |
| | |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void showLoading() { |
| | | public void showLoading(Object obj) { |
| | | if (!boo) |
| | | iv_right.post(new Runnable() { |
| | | @Override |
| | |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void finishPage() { |
| | | public void finishPage(Object obj) { |
| | | if (!boo) |
| | | iv_right.post(new Runnable() { |
| | | @Override |
| | |
| | | |
| | | |
| | | @JavascriptInterface |
| | | public void showSharePanel() { |
| | | public void showSharePanel(Object obj) { |
| | | webShareDesc.setShare(); |
| | | } |
| | | |
| | |
| | | //请求广告失败 |
| | | @Override |
| | | public void onError(int code, String message) { |
| | | com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); |
| | | result.put("code", 1); |
| | | result.put("msg", message); |
| | | handler.complete(result); |
| | |
| | | //视频广告加载后,视频资源缓存到本地的回调,在此回调后,播放本地视频,流畅不阻塞。 |
| | | @Override |
| | | public void onRewardVideoCached() { |
| | | |
| | | //开发者做一个标识 |
| | | if (mttRewardVideoAd != null) { |
| | | mttRewardVideoAd.showRewardVideoAd(mContext, TTAdConstant.RitScenes.CUSTOMIZE_SCENES, "scenes_test"); |
| | | mttRewardVideoAd = null; |
| | | } |
| | | com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); |
| | | result.put("code", 100); |
| | | result.put("msg", "缓存成功"); |
| | | handler.setProgressData(result); |
| | | } |
| | | |
| | | //视频广告的素材加载完毕,比如视频url等,在此回调后,可以播放在线视频,网络不好可能出现加载缓冲,影响体验。 |
| | |
| | | mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() { |
| | | @Override |
| | | public void onAdShow() { |
| | | |
| | | com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); |
| | | result.put("code", 201); |
| | | result.put("msg", "广告开始展示"); |
| | | handler.setProgressData(result); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void onVideoError() { |
| | | com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); |
| | | result.put("code", 2); |
| | | result.put("msg", "视频出错"); |
| | | handler.complete(result); |
| | |
| | | |
| | | @Override |
| | | public void onRewardVerify(boolean b, int i, String s, int i1, String s1) { |
| | | com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); |
| | | result.put("code", 0); |
| | | result.put("msg", "广告展示完成"); |
| | | handler.complete(result); |
| | |
| | | @Override |
| | | public void run() { |
| | | View view = LayoutInflater.from(mContext).inflate(R.layout.item_reward_ad_fail, null); |
| | | LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(DimenUtils.getScreenWidth(mContext)*4/5,LinearLayout.LayoutParams.WRAP_CONTENT); |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DimenUtils.getScreenWidth(mContext) * 4 / 5, LinearLayout.LayoutParams.WRAP_CONTENT); |
| | | view.setLayoutParams(params); |
| | | TextView tv_content = view.findViewById(R.id.tv_content); |
| | | tv_content.setText(msg + ""); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | @JavascriptInterface |
| | | public void checkUpdate(Object obj) { |
| | | UpdateApp app = new UpdateApp(mContext,mContext.getResources().getString(R.string.update_key)); |
| | | app.getUpdateInfo(new UpdateApp.UpdateJudgeCallback() { |
| | | |
| | | @Override |
| | | public void onSuccess(boolean show) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void closeUpdate(boolean close) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | |
| | | } |
| | | }, true);//强制检测更新 |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | int type; |
| | |
| | | + "/rebateshare"; |
| | | } else if (type == 2) { |
| | | path = com.wpc.library.util.Environment.getExternalStorageDirectory() |
| | | + "/blksapp"; |
| | | + "/tejiaapp"; |
| | | } |
| | | final File storageDir = new File(path); |
| | | List<String> filePathList = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | if (urlList.size() > 0) { |
| | | showLoading(); |
| | | showLoading(null); |
| | | shareTempImgEntity = new ArrayList<>(); |
| | | //去下载 |
| | | new DownLoadFile().downloadMultiImages(urlList, filePathList, mContext, new DownLoadFile.FileDownLoadListener() { |
| | | @Override |
| | | public void finish(List<File> fileList) { |
| | | hideLoading(); |
| | | hideLoading(null); |
| | | //完成下载 |
| | | |
| | | if (fileList != null) |
| | |
| | | } |
| | | }); |
| | | } else { |
| | | hideLoading(); |
| | | hideLoading(null); |
| | | if (type == 1) |
| | | shareHandler.sendEmptyMessage(platform); |
| | | else { |