| | |
| | | import com.tejia.lijin.app.callBack.GeneralBackCallback; |
| | | import com.tejia.lijin.app.callBack.PermissionInterface; |
| | | import com.tejia.lijin.app.entity.ImgText; |
| | | import com.tejia.lijin.app.entity.JumpDetail; |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | mContext.startActivity(intent); |
| | | if (!boo) |
| | | mContext.finish(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 跳转三方平台 |
| | | * |
| | | * @param args |
| | | * @throws JSONException |
| | | */ |
| | | @JavascriptInterface |
| | | public void jumpThirdPlatform(Object args) throws JSONException { |
| | | JSONObject json = new JSONObject(args.toString()); |
| | | JumpDetail jumpDetail = new JumpDetail(); |
| | | jumpDetail.setType("thirdPlatform"); |
| | | JumpActivityUtil.jumpPage(mContext, jumpDetail, com.alibaba.fastjson.JSONObject.parseObject(json.toString())); |
| | | } |
| | | |
| | | |
| | |
| | | int type = json.optInt("type"); |
| | | final String url = json.optString("url"); |
| | | |
| | | //检测权限 |
| | | String[] str = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, |
| | | Manifest.permission.WRITE_EXTERNAL_STORAGE}; |
| | | if (lacksPermissions(str)) {//缺少权限 |
| | | generalBackCallback.onSuccess(type, url); |
| | | if (mPermissionsChecker == null) |
| | | mPermissionsChecker = new PermissionHelper(mContext, this); |
| | | if (mPermissionsChecker.lacksPermissions(getPermissions())) { //存储权限未开启 |
| | | mPermissionsChecker.showNormalDialog(); |
| | | } else { |
| | | this.type = type; |
| | | this.imgurl = url; |
| | |
| | | final String urls = json.optString("urls"); |
| | | |
| | | |
| | | String[] str = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, |
| | | Manifest.permission.WRITE_EXTERNAL_STORAGE}; |
| | | if (lacksPermissions(str)) {//缺少权限 |
| | | generalBackCallback.onSuccess(type, null); |
| | | if (mPermissionsChecker == null) |
| | | mPermissionsChecker = new PermissionHelper(mContext, this); |
| | | if (mPermissionsChecker.lacksPermissions(getPermissions())) { //存储权限未开启 |
| | | mPermissionsChecker.showNormalDialog(); |
| | | } else { |
| | | List<String> urlList = new ArrayList<>(); |
| | | try { |
| | |
| | | TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(mContext); |
| | | AdSlot adSlot = new AdSlot.Builder() |
| | | .setCodeId(pid) |
| | | .setRewardName("金币") //奖励的名称 选填 |
| | | .setRewardAmount(3) //奖励的数量 选填 |
| | | // .setUserID("tag123")//tag_id |
| | | .setMediaExtra("media_extra") //附加参数 |
| | | .setOrientation(TTAdConstant.VERTICAL) //必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL |
| | |
| | | handler.setProgressData(result); |
| | | } |
| | | |
| | | @Override |
| | | public void onRewardVideoCached(TTRewardVideoAd ttRewardVideoAd) { |
| | | mttRewardVideoAd=ttRewardVideoAd; |
| | | //开发者做一个标识 |
| | | com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); |
| | | result.put("code", 100); |
| | | result.put("msg", "缓存成功"); |
| | | handler.setProgressData(result); |
| | | } |
| | | |
| | | //视频广告的素材加载完毕,比如视频url等,在此回调后,可以播放在线视频,网络不好可能出现加载缓冲,影响体验。 |
| | | @Override |
| | | public void onRewardVideoAdLoad(TTRewardVideoAd ad) { |
| | |
| | | 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(); |
| | | 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(); |
| | | com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); |
| | | result.put("code", 0); |
| | | result.put("msg", "广告展示完成"); |
| | | handler.complete(result); |
| | | } |
| | | |
| | | @Override |
| | | public void onRewardArrived(boolean b, int i, Bundle bundle) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | ToastUtil.showToast(view, view.getContext(), Toast.LENGTH_SHORT, Gravity.CENTER); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | @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);//强制检测更新 |
| | | } |
| | | |
| | | |
| | |
| | | + "/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<>(); |
| | |
| | | |
| | | ArrayList<Uri> uriList = new ArrayList<Uri>(); |
| | | if (imageList != null) |
| | | for (ShareImageEntity entity : imageList) |
| | | for (ShareImageEntity entity : imageList) { |
| | | uriList.add(Tools.getImageContentUri(mContext, new File(entity.getFilePath()))); |
| | | |
| | | } |
| | | if (platfrom == 1) { |
| | | ShareImageUtil.shareWXPictureByIntent(mContext, uriList); |
| | | } else if (platfrom == 2) { |
| | |
| | | public void requestPermissionsFail() { |
| | | // Toast.makeText(this, "你以拒绝权限", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | } |