|
40 | 40 | import cn.com.venvy.common.observer.VenvyObservable; |
41 | 41 | import cn.com.venvy.common.observer.VenvyObservableTarget; |
42 | 42 | import cn.com.venvy.common.observer.VenvyObserver; |
| 43 | +import cn.com.venvy.common.statistics.VenvyStatisticsManager; |
43 | 44 | import cn.com.venvy.common.utils.VenvyAesUtil; |
44 | 45 | import cn.com.venvy.common.utils.VenvyBase64; |
45 | 46 | import cn.com.venvy.common.utils.VenvyDeviceUtil; |
@@ -222,6 +223,81 @@ public void requestProgress(Request request, int progress) { |
222 | 223 |
|
223 | 224 | } |
224 | 225 |
|
| 226 | + /*** |
| 227 | + * 统计通用追踪 |
| 228 | + * @param jsParams |
| 229 | + */ |
| 230 | + @JavascriptInterface |
| 231 | + public void commonTrack(final String jsParams) { |
| 232 | + if (TextUtils.isEmpty(jsParams)) { |
| 233 | + return; |
| 234 | + } |
| 235 | + try { |
| 236 | + JSONObject jsonObject = new JSONObject(jsParams); |
| 237 | + if (jsonObject == null) { |
| 238 | + return; |
| 239 | + } |
| 240 | + JSONObject msgObject = jsonObject.optJSONObject("msg"); |
| 241 | + if (msgObject == null) { |
| 242 | + return; |
| 243 | + } |
| 244 | + Integer type = msgObject.optInt("type"); |
| 245 | + String data = msgObject.optString("data"); |
| 246 | + VenvyStatisticsManager.getInstance().submitCommonTrack(type, new JSONObject(data)); |
| 247 | + } catch (Exception e) { |
| 248 | + e.printStackTrace(); |
| 249 | + } |
| 250 | + } |
| 251 | + |
| 252 | + /*** |
| 253 | + * 打开广告 |
| 254 | + * @param jsParams |
| 255 | + */ |
| 256 | + @JavascriptInterface |
| 257 | + public void openAds(String jsParams) { |
| 258 | + try { |
| 259 | + if(TextUtils.isEmpty(jsParams)) |
| 260 | + return; |
| 261 | + JSONObject msgObject= |
| 262 | + JSONObject jsonObject = new JSONObject(jsParams); |
| 263 | +// VenvyLog.d("openAds : " + jsonObject.toString()); |
| 264 | + if (jsonObject.has("targetType")) { |
| 265 | + String targetType = jsonObject.optString("targetType"); |
| 266 | + JSONObject linkData = jsonObject.optJSONObject("linkData"); |
| 267 | + String downAPI = jsonObject.optString("downloadApkUrl"); |
| 268 | + String deepLink = linkData.optString("deepLink"); |
| 269 | + // targetType 1 落地页 2 deepLink 3 下载 |
| 270 | + if (targetType.equalsIgnoreCase("3")) { |
| 271 | + JSONObject downloadTrackLink = jsonObject.optJSONObject("downloadTrackLink"); |
| 272 | + Bundle trackData = new Bundle(); |
| 273 | + trackData.putString(VenvyObservableTarget.Constant.CONSTANT_DOWNLOAD_API, downAPI); |
| 274 | + trackData.putStringArray("isTrackLinks", JsonUtil.toStringArray(downloadTrackLink.optJSONArray("isTrackLinks"))); |
| 275 | + trackData.putStringArray("dsTrackLinks", JsonUtil.toStringArray(downloadTrackLink.optJSONArray("dsTrackLinks"))); |
| 276 | + trackData.putStringArray("dfTrackLinks", JsonUtil.toStringArray(downloadTrackLink.optJSONArray("dfTrackLinks"))); |
| 277 | + trackData.putStringArray("instTrackLinks", JsonUtil.toStringArray(downloadTrackLink.optJSONArray("instTrackLinks"))); |
| 278 | + trackData.putString("launchPlanId",jsonObject.optString("launchPlanId")); |
| 279 | + ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_DOWNLOAD_TASK, trackData); |
| 280 | + } else { |
| 281 | + // 走Native:widgetNotify() 逻辑 |
| 282 | + WidgetInfo.Builder builder = new WidgetInfo.Builder() |
| 283 | + .setWidgetActionType(WidgetInfo.WidgetActionType.ACTION_OPEN_URL) |
| 284 | + .setUrl(""); |
| 285 | + if (targetType.equalsIgnoreCase("1")) { |
| 286 | + builder.setLinkUrl(downAPI); |
| 287 | + } else if (targetType.equalsIgnoreCase("2")) { |
| 288 | + builder.setDeepLink(deepLink); |
| 289 | + } |
| 290 | + WidgetInfo widgetInfo = builder.build(); |
| 291 | + if (platform.getWidgetClickListener() != null) { |
| 292 | + platform.getWidgetClickListener().onClick(widgetInfo); |
| 293 | + } |
| 294 | + } |
| 295 | + } |
| 296 | + }catch (Exception e){ |
| 297 | + e.printStackTrace(); |
| 298 | + } |
| 299 | + } |
| 300 | + |
225 | 301 | @JavascriptInterface |
226 | 302 | public void openUrl(String jsParams) { |
227 | 303 | try { |
|
0 commit comments