ProcessUtils.java
61.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
package com.wd.common.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import com.google.gson.JsonObject;
import com.wd.base.log.Logger;
import com.wd.capability.router.WdRouterRule;
import com.wd.capability.router.data.ActionBean;
import com.wd.foundation.wdkit.constant.PageNameConstants;
import com.wd.common.constant.RouterConstants;
import com.wd.common.manager.AudioThemManager;
import com.wd.fastcoding.base.R;
import com.wd.foundation.bean.custom.MenuBean;
import com.wd.foundation.bean.custom.SimpleAudioThemeBean;
import com.wd.foundation.bean.custom.SimpleAudioThemeBeans;
import com.wd.foundation.bean.custom.act.BaseActivityBean;
import com.wd.foundation.bean.custom.comp.ChannelInfoBean;
import com.wd.foundation.bean.custom.video.VodDetailIntentBean;
import com.wd.foundation.bean.music.bean.VoicePlayerBean;
import com.wd.foundation.bean.paper.PaperPageItemBean;
import com.wd.foundation.wdkit.base.BaseApplication;
import com.wd.foundation.wdkit.constant.EventConstants;
import com.wd.foundation.wdkit.constant.GloadLogicParams;
import com.wd.foundation.wdkit.constant.IntentConstants;
import com.wd.foundation.wdkit.imageglide.ImageUtils;
import com.wd.foundation.bean.custom.comp.CompBean;
import com.wd.foundation.bean.custom.comp.CompDataSourceBean;
import com.wd.foundation.bean.custom.content.ContentBean;
import com.wd.foundation.bean.custom.content.ContentTypeConstant;
import com.wd.foundation.bean.response.BottomNavBean;
import com.wd.foundation.bean.response.ChannelBean;
import com.wd.foundation.wdkit.json.GsonUtils;
import com.wd.foundation.wdkit.utils.ActivityController;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.foundation.wdkit.utils.ToastNightUtil;
import com.wd.foundation.wdkitcore.livedata.LiveDataBus;
import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
import com.wd.foundation.wdkitcore.tools.AppContext;
import com.wd.foundation.wdkitcore.tools.ArrayUtils;
import com.wd.foundation.wdkitcore.tools.JsonUtils;
import com.wd.foundation.wdkitcore.tools.ResUtils;
import com.wd.foundation.wdkitcore.tools.StringUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* 跳转场景业务封装类<BR>
*
* @author zhangbo
* @version [V1.0.0, 2020/7/24]
* @since V1.0.0
*/
public class ProcessUtils implements IntentConstants {
private static final String TAG = "ProcessUtils";
/**
* 首页底部导航栏业务数据
*/
public static BottomNavBean navBean;
/**
* 视频频道的page id (唯一)
*/
public static String VideoChannelPageId = null;
/**
* 版面频道(电子报)
*/
public static String CHANNEL_ID_EL_NEWS = "2006";
// 播报频道(音频频道)
public static String CHANNEL_ID_VOICE = "2066";
// 直播
public static String CHANNEL_ID_LIVE = "2061";
private ProcessUtils() {
}
/**
* 进入主页
*/
public static void goMainPage() {
WdRouterRule.getInstance().processAction(AppContext.getContext(), RouterConstants.PATH_MODULE_Main);
}
/**
* 进入带顶部背景图的专题页
*/
public static void goToAreaSubjectPage(String pageId, String titleName) {
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.PAGE_TYPE, ContentTypeConstant.URL_TYPE_FIVE);
jsonObject.addProperty(IntentConstants.PARAM_PAGE_ID, pageId);
// jsonObject.addProperty(IntentConstants.PARAM_PAGE_TITLE, titleName);
jsonObject.addProperty(IntentConstants.PARAM_PAGE_MANAGER, "ItemAreaSubjectLayoutManager");
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_MODULE_COMMONFLOOR;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 进入区域榜单页
*
* @param pageId
*/
public static void goToAreaBillboardPage(String pageId, String titleName) {
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.PARAM_PAGE_ID, pageId);
// jsonObject.addProperty(IntentConstants.PARAM_PAGE_TITLE, titleName);
jsonObject.addProperty(IntentConstants.PARAM_PAGE_MANAGER, "ItemFeatureBillboardLayoutManager");
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_MODULE_COMMONFLOOR;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 校验是否登录了
*/
public static boolean checkLogin() {
String userToken = SpUtils.getUserToken();
return !TextUtils.isEmpty(userToken);
}
/**
* 一键登录
*/
public static void toOneKeyLoginActivity() {
// if (FastClickUtil.isOneKeyLoginFastClick()) {
// Logger.t(TAG).i("FastClickUtil.isFastClick()");
// return;
// }
// if (SpUtils.getHttp377()) {
// DssToastUtils.showShort(ResUtils.getString(R.string.force_login_out));
// }
// IOneKeyLoginHelper oneKeyLoginHelper = new OneKeyLoginHelperImpl();
// oneKeyLoginHelper.toLogin();
}
/**
* 跳转管理页面
*
* @param pageId
*/
public static void jumpChannelManage(String pageId) {
// ActionBean actionBean = new ActionBean();
// actionBean.paramBean.pageID = RouterConstants.PATH_MODULE_CHANNEL_EDIT;
// JsonObject jsonObject = new JsonObject();
// jsonObject.addProperty("originPageId", pageId);
// actionBean.paramBean.params = jsonObject.toString();
// WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 跳转短视频播放详情
*
* @param contentId
* @param isShowComment 1为进入页面评论自动打开
*/
public static void jumpShortPlay(String contentId, String isShowComment) {
jumpShortPlay(contentId, isShowComment, "", "", "", "");
}
public static void jumpShortPlay(String contentId, String isShowComment, String from, String cover,
String userIpInfo, String previewVideoUrl) {
ActionBean actionBean = new ActionBean();
// actionBean.paramBean.pageID = RouterConstants.PATH_SHORT_VIDEO_ACTIVITY;
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.CONTENT_ID, contentId);
// jsonObject.addProperty(IntentConstants.FROM, from);
jsonObject.addProperty(IntentConstants.PAGE_TYPE, GloadLogicParams.ColumnContentTypeValue);
// 从列表点击进去观看第一条需要首帧图
// jsonObject.addProperty(IntentConstants.FIRST_ITEM_COVER, cover);
// 子线程加载下图片进行缓存
preloadImage(cover);
if (!StringUtils.isBlank(userIpInfo)) {
// jsonObject.addProperty(IntentConstants.USER_IP_ADDRESS, userIpInfo);
}
// 携带视频地址
if (!StringUtils.isBlank(previewVideoUrl)) {
// jsonObject.addProperty(IntentConstants.PREVIEW_VIDEO_URL, previewVideoUrl);
}
actionBean.paramBean.params = jsonObject.toString();
actionBean.type = isShowComment;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 其它页面的业务类型换成 正规 业务类型
*
* @param type 内容类型 1:图文 2:视频 3:直播 4:纯文本 5 活动
* @return 1:点播,2直播,3活动,4信息流广告,5专题,6链接
*/
public static int changeProgramType(int type) {
// 内容类型 1:图文 2:视频 3:直播 4:纯文本 5 活动
// 跳转类型:1:点播,2直播,3活动,4信息流广告,5专题,6链接
// -1 表示没有对应跳转类型
int retType = -1;
if (2 == type) {
// 视频 -> 点播跳转
retType = ContentTypeConstant.URL_TYPE_ONE;
} else if (3 == type) {
// 直播 -> 直播跳转
retType = ContentTypeConstant.URL_TYPE_TWO;
} else if (5 == type) {
// 活动 -> 活动跳转
retType = ContentTypeConstant.URL_TYPE_THREE;
}
return retType;
}
/**
* 跳转详情
*
* @param content
*/
public static void processPage(ContentBean content) {
if (content == null) {
Logger.t(TAG).w("processPage, action is null or getType is empty");
//ToastNightUtil.showShort(R.string.tips_content_offline);
return;
}
if (TextUtils.isEmpty(content.getObjectType())) {
//ToastNightUtil.showShort(R.string.tips_content_offline);
return;
}
String fromPage = StringUtils.getStringValue(content.getFromPage());
// //检测主态作品状态
// if(checkContentStatus(content)){
// //不需要进行下一步
// return;
// }
int type = 0;
try {
type = Integer.parseInt(content.getObjectType());
} catch (NumberFormatException e) {
e.printStackTrace();
}
String contentId = content.getObjectId();
if (ContentTypeConstant.URL_TYPE_ZERO == type) {
// 不跳转
} else if (ContentTypeConstant.URL_TYPE_ONE == type) {
// 点播
String videoUrl = "";
String firstFrameImageUri = "";
if (content.getVideoInfo() != null) {
videoUrl = content.getVideoInfo().videoUrl;
firstFrameImageUri = content.getVideoInfo().firstFrameImageUri;
}
String pageId = "";
if (StringUtils.isNotBlank(content.getPageId())) {
pageId = content.getPageId();
}
String channelId = "";
if (content.getChannelInfoBean() != null) {
channelId = content.getChannelInfoBean().getChannelId();
}
String topicId = "";
if (content.getTopicInfoBean() != null) {
topicId = content.getTopicInfoBean().getTopicId();
}
VodDetailIntentBean intentBean = new VodDetailIntentBean();
intentBean.setPageId(pageId);
intentBean.setContentId(contentId);
intentBean.setContentType(content.getObjectType());
intentBean.setVideoUrl(videoUrl);
intentBean.setChannelId(channelId);
intentBean.setTopicId(topicId);
intentBean.setRecommend(content.getRecommend() == 1);
intentBean.setCompId(content.getCompId());
//搜索keyWord
intentBean.setKeyWord(content.getKeyWord());
// 浏览历史、收藏页面、站内信(预约直播列表、推送消息记录列表)
intentBean.setFrom(content.getFromPage());
// 处理来自哪个页面
dealIntentBeanRequestType(intentBean, content);
//站内信(预约直播列表、推送消息记录列表)
intentBean.localFiledIdType = content.getNewsTitle();
//添加关联关系
intentBean.setRelType(content.getRelType() + "");
intentBean.setContentRelId(content.getRelId());
// 是否滚动到底部
intentBean.setScrollToBottom(content.getScrollToBottom());
// 从列表点击进去观看第一条需要首帧图
intentBean.setFirstFrameImageUri(firstFrameImageUri);
// 子线程加载下图片进行缓存
preloadImage(firstFrameImageUri);
// // 处理埋点字段
// dealTrackField(intentBean, content);
goVideoDetail(intentBean);
// } else if (ContentTypeConstant.URL_TYPE_TWO == type) {
// // 直播
// //每次调接口,调完接口带数据进入直播详情
// jumpToLiveDetailActivity(contentId, content.getRelType() + "",
// content.getRelId(), content.getCoverUrl(), fromPage);
} else if (ContentTypeConstant.URL_TYPE_THREE == type) {
// 活动
BaseActivityBean itemActivity = content.itemActivity;
if(itemActivity != null){
content.setOpenType("1");
content.setLinkUrl(itemActivity.getLinkUrl());
goToH5Page(content);
}else {
ToastNightUtil.showShort("无活动");
}
} else if (ContentTypeConstant.URL_TYPE_FIVE == type) {
// 5专题
goToCommonSubjectPage(content);
} else if (ContentTypeConstant.URL_TYPE_SIX == type || ContentTypeConstant.URL_TYPE_FOUR == type) {
// 6,跳转H5外链 4、信息流广告
goToH5Page(content);
} else if (ContentTypeConstant.URL_TYPE_EIGHT == type) {
// 8 图文
goToArticleDetailPage(content);
} else if (ContentTypeConstant.URL_TYPE_NINE == type) {
// 9 组图 图集
goToImageDetailPage(content);
} else if (ContentTypeConstant.URL_TYPE_TEN == type) {
// 10 H5新闻
goToArticleDetailPage(content);
} else if (ContentTypeConstant.URL_TYPE_ELEVEN == type) {
// 11 频道
goToChannelSubjectPage(content);
// } else if (ContentTypeConstant.URL_TYPE_THIRTEEN == type) {
// // 13 音频
// goToMusicDetailPageNetWork(content);
// } else if (ContentTypeConstant.URL_TYPE_FOURTEEN == type || ContentTypeConstant.URL_TYPE_FIFTEEN == type) {
// // 14动态图文 和 15 动态视频
// goTrendsDetailPage(content);
// } else if (ContentTypeConstant.URL_TYPE_SIXTEEN == type) {
// // 留言坂详情
// if (content.askInfo != null) {
// if (TextUtils.isEmpty(content.askInfo.id)) {
// content.askInfo.id = content.getObjectId();
// }else {
// //避免objectId为空
// if (StringUtils.isBlank(content.getObjectId())){
// content.setObjectId(content.askInfo.id);
// }
// }
// ProcessUtils.goLeaveMessageDetailActivity(content.getRelId(),
// content.askInfo.realAskId, content.askInfo.localMyWord, content.askInfo.id
// , String.valueOf(content.getRelType()),content.getObjectType(),
// content.getScrollToBottom(),fromPage);
// }else {
// ProcessUtils.goLeaveMessageDetailActivity("",content.getRelId(), false,content.getObjectId()
// , String.valueOf(content.getRelType()),content.getObjectType(),
// false,fromPage);
// }
} else if (ContentTypeConstant.URL_TYPE_THIRTY == type) {
if (TextUtils.isEmpty(content.getExtra())) {
ToastNightUtil.showShort("extra无值");
return;
}
// 金刚卡位跳转
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.CONTENT_TYPE, CompDataSourceBean.GOLDEN_TWO_PAGE);
jsonObject.addProperty(IntentConstants.PAGE_TITLE, content.getNewsTitle());
jsonObject.addProperty(IntentConstants.PAGE_EXTRA, content.getExtra());
//推荐定义字段
jsonObject.addProperty(IntentConstants.SCENEID, content.getSceneId());
jsonObject.addProperty(IntentConstants.SUBSCENEID, content.getSubSceneId());
jsonObject.addProperty(IntentConstants.CNSTRACEID, content.getTraceId());
jsonObject.addProperty(IntentConstants.ITEMID, content.getItemId());
jsonObject.addProperty(IntentConstants.EXPIDS, content.getExpIds());
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_MODULE_TWO_LIVE_DETAIL;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
// } else if (ContentTypeConstant.VIDEO_ALBUM == type){
// //合集详情
// goVideoCollectionActivity(content.getObjectId());
} else {
// 提示"请升级至最新版本体验完整功能"
ToastNightUtil.showShort(ResUtils.getString(R.string.jump_not_find));
}
/*if (!PDUtils.isLogin()){
//本地保存不控制
HistoryDataHelper.getInstance().addHistory(content);
}else {
//视频、图文在详情里添加,其他类型在这里添加
if (!addHistoryInDetail(type)) {
HistoryDataHelper.getInstance().addHistory(content);
}
}*/
}
/**
* 处理来自哪个页面
*/
private static void dealIntentBeanRequestType(VodDetailIntentBean vodDetailIntentBean, ContentBean contentBean) {
// 数据异常时,默认推荐
if (vodDetailIntentBean == null || contentBean == null) {
return;
}
// 历史、收藏、作品这几种情况有值,其他情况为空
String fromPage = contentBean.getFromPage();
// 是否来自推荐
int recommend = contentBean.getRecommend();
// 频道 id
String channelId = "";
ChannelInfoBean channelInfoBean = contentBean.getChannelInfoBean();
if (channelInfoBean != null) {
channelId = channelInfoBean.getChannelId();
}
if (StringUtils.isNotBlank(fromPage) && PageNameConstants.MY_HISTORY_PAGE.equals(fromPage)){
// 历史
vodDetailIntentBean.setType(VodDetailIntentBean.Type.HISTORY);
}else if (StringUtils.isNotBlank(fromPage) && PageNameConstants.MY_COLLECT_PAGE.equals(fromPage)){
// 收藏
vodDetailIntentBean.setType(VodDetailIntentBean.Type.COLLECT);
}else if (StringUtils.isNotBlank(fromPage) && PageNameConstants.CUSTOMER_PERSONAL_HOME_PAGE.equals(fromPage)){
// 号主页主态
vodDetailIntentBean.setType(VodDetailIntentBean.Type.WORKS);
}else if (StringUtils.isNotBlank(fromPage) && PageNameConstants.MAIN_PERSONAL_HOME_PAGE.equals(fromPage)){
// 号主页客态
vodDetailIntentBean.setType(VodDetailIntentBean.Type.WORKS);
}else if (StringUtils.isNotBlank(fromPage) && PageNameConstants.SEARCH_RESULT_PAGE.equals(fromPage)){
// 搜索结果页
vodDetailIntentBean.setContentId(contentBean.getObjectId());
vodDetailIntentBean.setType(VodDetailIntentBean.Type.SEARCH);
}else if (StringUtils.isBlank(fromPage) && StringUtils.isNotBlank(channelId) && recommend == 1) {
// 推荐
vodDetailIntentBean.setType(VodDetailIntentBean.Type.RECOMMEND);
} else if (StringUtils.isBlank(fromPage) && StringUtils.isNotBlank(channelId) && recommend != 1) {
// 频道
vodDetailIntentBean.setType(VodDetailIntentBean.Type.CHANNEL);
}else {
// 动态、活动、彩蛋、早晚报通用这一个逻辑
vodDetailIntentBean.setType(VodDetailIntentBean.Type.COMMON);
}
}
/**
* 跳转点播详情页
*/
public static void goVideoDetail(VodDetailIntentBean intentBean) {
// 拦截画中画
interceptorPictureInPicture();
ActionBean actionBean = new ActionBean();
actionBean.paramBean.pageID = RouterConstants.PATH_VIDEO_DETAIL;
actionBean.paramBean.params = JsonUtils.convertObjectToJson(intentBean);
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 跳转H5页
*
* @param bean
*/
public static void goToH5Page(ContentBean bean) {
if (bean == null){
return;
}
// 拦截画中画
interceptorPictureInPicture();
if ("1".equals(bean.getOpenType())) {
if (isAppWhiteHostForOpen(bean.getLinkUrl())){
//白名单内可以打开
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.WEBSITES_SEARCHURL, bean.getLinkUrl());
jsonObject.addProperty(IntentConstants.CONTENT_ID, bean.getObjectId());
jsonObject.addProperty(IntentConstants.REL_ID, bean.getRelId());
jsonObject.addProperty(IntentConstants.REL_TYPE, bean.getRelType());
//推荐定义字段
jsonObject.addProperty(IntentConstants.SCENEID, bean.getSceneId());
jsonObject.addProperty(IntentConstants.SUBSCENEID, bean.getSubSceneId());
jsonObject.addProperty(IntentConstants.CNSTRACEID, bean.getTraceId());
jsonObject.addProperty(IntentConstants.ITEMID, bean.getItemId());
jsonObject.addProperty(IntentConstants.EXPIDS, bean.getExpIds());
//分享数据
if(bean.isShowH5Share() && bean.getShareInfo() != null){
jsonObject.addProperty(IntentConstants.SHARE_INFO,
GsonUtils.objectToJson(bean.getShareInfo()));
}
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_H5_PAGE;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}else {
//不在白名单进行拦截
goToBlockedH5Page(bean.getLinkUrl());
}
} else {
jumpBrowser(ActivityController.getCurrentActivity(), bean.getLinkUrl());
}
}
/**
* 跳转H5拦截页面
*
* @param url 网页地址
*/
public static void goToBlockedH5Page(String url) {
// 拦截画中画
interceptorPictureInPicture();
ActionBean actionBean = new ActionBean();
actionBean.paramBean.pageID = RouterConstants.BLOCKED_WEB_PAGE;
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.BLOCK_H5_URL, url);
actionBean.paramBean.params = jsonObject.toString();
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* H5打开白名单拦截
* @param webUrl
* @return
*/
private static boolean isAppWhiteHostForOpen(String webUrl){
boolean appWhiteHostForOpen = H5JsApiPermissionUtil.getInstance().isAppWhiteHostForOpen(webUrl);
return appWhiteHostForOpen;
}
/**
* 跳转到浏览器
*
* @param mWebUrl
*/
public static void jumpBrowser(String mWebUrl) {
if (TextUtils.isEmpty(mWebUrl)) {
return;
}
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mWebUrl));
// 注意此处的判断intent.resolveActivity()可以返回显示该Intent的Activity对应的组件名
// 官方解释 : Name of the component implementing an activity that can display the intent
if (intent.resolveActivity(AppContext.getContext().getPackageManager()) != null) {
AppContext.getContext().startActivity(Intent.createChooser(intent, "请选择浏览器"));
} else {
ToastNightUtil.showShort("加载失败,请稍后重试 ");
}
}
/**
* 跳转到浏览器
*
* @param context
* @param mWebUrl
*/
public static void jumpBrowser(Context context, String mWebUrl) {
if (TextUtils.isEmpty(mWebUrl)) {
return;
}
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mWebUrl));
// 注意此处的判断intent.resolveActivity()可以返回显示该Intent的Activity对应的组件名
// 官方解释 : Name of the component implementing an activity that can display the intent
if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(Intent.createChooser(intent, "请选择浏览器"));
} else {
ToastNightUtil.showShort("加载失败,请稍后重试 ");
}
}
/**
* 跳转通用专题页
* 直播专题 文章专题 音频专题 话题专题 早晚报专题 时间轴专题
*
* @param bean
*/
@SuppressLint("ResourceType")
public static void goToCommonSubjectPage(ContentBean bean) {
// 拦截画中画
interceptorPictureInPicture();
String objectLevel = bean.getObjectLevel();
String linkUrl = bean.getLinkUrl();
int objectLevelInt = 0;
if (!TextUtils.isEmpty(objectLevel)) {
try {
objectLevelInt = Integer.parseInt(objectLevel);
} catch (Exception e) {
e.printStackTrace();
}
}
// objectLevelInt = ContentTypeConstant.SUBJECT_TOPICTYPE_25;
if (objectLevelInt == ContentTypeConstant.SUBJECT_TOPICTYPE_22) {
if (TextUtils.isEmpty(bean.getPageId())) {
ToastNightUtil.showShort(R.string.tips_content_offline);
return;
}
// 音频专题
List<SimpleAudioThemeBean> simpleAudioThemeBeanList = new ArrayList<>();
SimpleAudioThemeBean simpleAudioThemeBean = new SimpleAudioThemeBean();
simpleAudioThemeBean.contentBean = bean;
simpleAudioThemeBeanList.add(simpleAudioThemeBean);
JumpToAudioTopic(simpleAudioThemeBeanList, 0);
} else if (objectLevelInt == ContentTypeConstant.SUBJECT_TOPICTYPE_25) {
if (TextUtils.isEmpty(bean.getPageId())) {
ToastNightUtil.showShort(R.string.tips_content_offline);
return;
}
ActionBean actionBean = new ActionBean();
//早晚报专题
if (objectLevelInt == ContentTypeConstant.SUBJECT_TOPICTYPE_25) {
// 加进场动效
actionBean.enterAnim = R.anim.enter_page_bottom_top_in;
actionBean.exitAnim = R.anim.enter_page_alpha_top_out;
}
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.CONTENT_TYPE, objectLevelInt);
jsonObject.addProperty(IntentConstants.PARAM_PAGE_ID, bean.getPageId());
jsonObject.addProperty(IntentConstants.PAGE_TITLE, bean.getNewsTitle());
jsonObject.addProperty(IntentConstants.PAGE_DESC, bean.getNewsSummary());
jsonObject.addProperty(IntentConstants.PAGE_COMMENT_OPEN, bean.getScrollToBottom());
//推荐定义字段
jsonObject.addProperty(IntentConstants.SCENEID, bean.getSceneId());
jsonObject.addProperty(IntentConstants.SUBSCENEID, bean.getSubSceneId());
jsonObject.addProperty(IntentConstants.CNSTRACEID, bean.getTraceId());
jsonObject.addProperty(IntentConstants.ITEMID, bean.getItemId());
jsonObject.addProperty(IntentConstants.EXPIDS, bean.getExpIds());
jsonObject.addProperty(IntentConstants.JUMP_FROM_PAGE, bean.getFromPage());
jsonObject.addProperty(IntentConstants.REL_ID, bean.getRelId());
jsonObject.addProperty(IntentConstants.REL_TYPE, bean.getRelType());
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_MODULE_COMMONFLOOR;
WdRouterRule.getInstance().processAction(ActivityController.getCurrentActivity(), actionBean);
} else if (!StringUtils.isBlank(linkUrl)) {
if (!TextUtils.isEmpty(bean.timeNewsId)) {
int wIndex = linkUrl.lastIndexOf("?");
if (wIndex > 0) {
} else {
linkUrl = linkUrl + "?newsId=" + bean.timeNewsId;
}
}
//h5专题
jumpH5SubjectPage(linkUrl,bean);
} else {
// 提示"请升级至最新版本体验完整功能"
ToastNightUtil.showShort(ResUtils.getString(R.string.jump_not_find));
}
}
/**
* 跳转专题web页
*/
public static void jumpH5SubjectPage(String url,ContentBean bean) {
// 拦截画中画
interceptorPictureInPicture();
if (isAppWhiteHostForOpen(url)){
//白名单内可以打开
ActionBean actionBean = new ActionBean();
actionBean.paramBean.pageID = RouterConstants.PATH_SUBJECT_WEB_PAGE;
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.WEB_URL, url);
if(bean != null ) {
//推荐定义字段
jsonObject.addProperty(IntentConstants.SCENEID, bean.getSceneId());
jsonObject.addProperty(IntentConstants.SUBSCENEID, bean.getSubSceneId());
jsonObject.addProperty(IntentConstants.CNSTRACEID, bean.getTraceId());
jsonObject.addProperty(IntentConstants.ITEMID, bean.getItemId());
jsonObject.addProperty(IntentConstants.EXPIDS, bean.getExpIds());
//通用h5专题
if(StringUtils.isNotBlank(bean.getNormalLinkUrl())){
jsonObject.addProperty(IntentConstants.NORMAL_LINK_URL, bean.getNormalLinkUrl());
jsonObject.addProperty(IntentConstants.TOPIC_ID, bean.getObjectId());
jsonObject.addProperty(IntentConstants.PARAM_PAGE_ID, bean.getPageId());
}
jsonObject.addProperty(IntentConstants.JUMP_FROM_PAGE, bean.getFromPage());
jsonObject.addProperty(IntentConstants.REL_ID, bean.getRelId());
jsonObject.addProperty(IntentConstants.REL_TYPE, bean.getRelType());
}
actionBean.paramBean.params = jsonObject.toString();
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
//点击时候更新下这个专题接口缓存-->H5通过js调用缓存时候再请求
// requestH5TopicCache(bean);
}else {
//不在白名单进行拦截
goToBlockedH5Page(url);
}
}
//跳转音频专题
public static void JumpToAudioTopic(List<SimpleAudioThemeBean> simpleAudioThemeBeanList, int select) {
// 拦截画中画
interceptorPictureInPicture();
SimpleAudioThemeBeans audioThemeBeans = new SimpleAudioThemeBeans();
audioThemeBeans.simpleAudioThemeBeanList = simpleAudioThemeBeanList;
audioThemeBeans.index = select;
AudioThemManager.getInstance().JumpToAudioTopic(audioThemeBeans);
}
/**
* 跳转图文详情页
*
* @param bean
*/
public static void goToArticleDetailPage(ContentBean bean) {
// 拦截画中画
interceptorPictureInPicture();
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
if (bean.getTopicInfoBean() != null) {
jsonObject.addProperty(IntentConstants.TOPIC_ID, bean.getTopicInfoBean().getTopicId());
}
if (bean.getChannelInfoBean() != null) {
jsonObject.addProperty(IntentConstants.CHANNEL_ID, bean.getChannelInfoBean().getChannelId());
}
jsonObject.addProperty(IntentConstants.WEBSITES_SEARCHURL, bean.getLinkUrl());
jsonObject.addProperty(IntentConstants.CONTENT_ID, bean.getObjectId());
jsonObject.addProperty(IntentConstants.COMP_ID, bean.getCompId());
jsonObject.addProperty(IntentConstants.REL_ID, bean.getRelId());
jsonObject.addProperty(IntentConstants.REL_TYPE, bean.getRelType());
jsonObject.addProperty(IntentConstants.PARAM_BOTTOM_COMMENT_AREA, bean.getScrollToBottom());
jsonObject.addProperty(IntentConstants.CONTENT_TYPE, ContentTypeConstant.URL_TYPE_EIGHT);
if (PageNameConstants.MY_COLLECT_PAGE.equals(bean.getFromPage())) {
//收藏1
jsonObject.addProperty(IntentConstants.SOURCE_PAGE, "1");
} else if (PageNameConstants.MY_HISTORY_PAGE.equals(bean.getFromPage())) {
//历史2
jsonObject.addProperty(IntentConstants.SOURCE_PAGE, "2");
} else if (PageNameConstants.AUDIO_DETAIL_PAGE.equals(bean.getFromPage())){
//音频详情3
jsonObject.addProperty(IntentConstants.SOURCE_PAGE, "3");
jsonObject.addProperty(IntentConstants.CONTENT_TYPE, ContentTypeConstant.URL_TYPE_THIRTEEN);
} else {
jsonObject.addProperty(IntentConstants.SOURCE_PAGE, "0");
}
//推荐定义字段
jsonObject.addProperty(IntentConstants.SCENEID, bean.getSceneId());
jsonObject.addProperty(IntentConstants.SUBSCENEID, bean.getSubSceneId());
jsonObject.addProperty(IntentConstants.CNSTRACEID, bean.getTraceId());
jsonObject.addProperty(IntentConstants.ITEMID, bean.getItemId());
jsonObject.addProperty(IntentConstants.EXPIDS, bean.getExpIds());
actionBean.paramBean.params = jsonObject.toString();
if (StringUtils.isEmpty(bean.getLinkUrl())) {
//图文详情
actionBean.paramBean.pageID = RouterConstants.PATH_ARTICLE_DETAIL_PAGE;
if (isSameArticleDetail(bean.getObjectId())) {
return;
}
} else {
//图文链接
if (!isAppWhiteHostForOpen(bean.getLinkUrl())){
//不在白名单进行拦截
goToBlockedH5Page(bean.getLinkUrl());
return;
}
actionBean.paramBean.pageID = RouterConstants.PATH_ARTICLE_LINK_PAGE;
}
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 相同的页面相同是数据,不再打开新的图文详情页面。
* */
public static boolean isSameArticleDetail(String objectId) {
//如果是当前页面,则不再跳转
if(CommonVarUtils.articleDetailMusicObjectId != null && CommonVarUtils.articleDetailMusicObjectId.equals(objectId)
&&BaseApplication.getInstance().getLifecycleCallbacks().current()!= null
&& "com.wd.webview.ui.ArticleDetailActivity".equals(BaseApplication.getInstance().getLifecycleCallbacks().current().getClass().getName())
){
//图文详情页的播放内容和悬浮窗的一致,不用再打开一次
return true;
}
return false;
}
/**
* 跳转图集详情页
*
* @param bean
*/
public static void goToImageDetailPage(ContentBean bean) {
// 拦截画中画
interceptorPictureInPicture();
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.PAGE_TYPE, ContentTypeConstant.URL_TYPE_NINE + "");
jsonObject.addProperty(IntentConstants.PARAM_PAGE_ID, bean.getPageId());
jsonObject.addProperty(IntentConstants.CONTENT_ID, bean.getObjectId());
jsonObject.addProperty(IntentConstants.REL_ID, bean.getRelId());
jsonObject.addProperty(IntentConstants.REL_TYPE, bean.getRelType());
jsonObject.addProperty(IntentConstants.PARAM_BOTTOM_COMMENT_AREA, bean.getScrollToBottom());
jsonObject.addProperty(IntentConstants.JUMP_FROM_PAGE, bean.getFromPage());
//推荐定义字段
jsonObject.addProperty(IntentConstants.SCENEID, bean.getSceneId());
jsonObject.addProperty(IntentConstants.SUBSCENEID, bean.getSubSceneId());
jsonObject.addProperty(IntentConstants.CNSTRACEID, bean.getTraceId());
jsonObject.addProperty(IntentConstants.ITEMID, bean.getItemId());
jsonObject.addProperty(IntentConstants.EXPIDS, bean.getExpIds());
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_IMAGE_DETAIL_PAGE;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 跳转频道专题
*
* @param bean
*/
public static void goToChannelSubjectPage(ContentBean bean) {
// 拦截画中画
interceptorPictureInPicture();
String homeTabNavId = null;
String channelId = bean.getObjectId();//tab页面顶部的频道id //"2005";//"2001";///
//bean.setObjectId(channelId);
// 依据提供频道id,在tab对应的频道中寻找匹配 tab
if (navBean != null && !TextUtils.isEmpty(channelId)) {
// 除去 tab 我的,在剩余的tab中找到频道id
List<MenuBean> bottomNavList = navBean.getMenus();
if (ArrayUtils.isNotEmpty(bottomNavList)) {
for (MenuBean menuBean : bottomNavList) {
boolean jumpTraverse = false;
if (menuBean.isMine()) {
bean.setBottomNavId(null);
} else {
// 获取tab对应的频道数据
List<ChannelBean> myChannelList = menuBean.getTopNavChannelList();
if (menuBean.isTabNew()) {
homeTabNavId = menuBean.getNavId();
// 新闻tab,正在使用的频道
// myChannelList = ChannelDbHelper.getInstance(AppContext.getContext()).searchAllSelectChannel();
}
if (ArrayUtils.isNotEmpty(myChannelList)) {
for (ChannelBean channelBean : myChannelList) {
String tempChannelId = channelBean.getChannelId();
if (channelId.equals(tempChannelId)) {
bean.setBottomNavId(menuBean.getNavId());
bean.setPageId(channelBean.getPageId());
jumpTraverse = true;
break;
}
}
}
}
// 首次发现符合channelId,终止所有的遍历
if (jumpTraverse) {
break;
}
}
}
}
// 检测查询现展示的所有频道,可存在channelId这个频道
if (TextUtils.isEmpty(bean.getBottomNavId())) {
/*
在 新闻tab 页面中,从 非我的栏目 中所有频道数据中查找该频道对象
*/
ChannelBean resultChannelBean = null;
boolean haveChannelData = false;
// List<ChannelBean> nomyChannelList = ChannelDbHelper.getInstance(AppContext.getContext()).searchAllUnSelectChannel();
// for (ChannelBean channelBean : nomyChannelList) {
// String tempChannelId = channelBean.getChannelId();
// if (channelId.equals(tempChannelId)) {
// resultChannelBean = channelBean;
// bean.setPageId(channelBean.getPageId());
// bean.setBottomNavId(homeTabNavId);
// haveChannelData = true;
// break;
// }
// }
if (haveChannelData && !TextUtils.isEmpty(homeTabNavId)) {
// 有频道数据
goBackMainPage();
ThreadPoolUtils.postToMainDelay(new Runnable() {
@Override
public void run() {
// 一级频道 跳转到首页 tab 页面
LiveDataBus.getInstance().with(EventConstants.HOME_TAB_ONE_CHANNEL_JUMP).postValue(bean);
}
},100);
// 跳转顶部频道
LiveDataBus.getInstance().with(EventConstants.COLUMN_NAVIGATION_DATACHANGE_ADD).postValue(resultChannelBean);
} else {
// 无该频道数据
if (TextUtils.isEmpty(bean.getPageId())) {
ToastNightUtil.showShort(R.string.tips_content_offline);
return;
}
// 二级频道 跳转到频道详情页面
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.PARAM_PAGE_ID, bean.getPageId());
jsonObject.addProperty(IntentConstants.PAGE_TITLE, bean.getNewsTitle());
jsonObject.addProperty(IntentConstants.PARAM_PAGE_MANAGER, "ItemChannelSubjectLayoutManager");
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_MODULE_CHANNEL;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
} else {
goBackMainPage();
// 一级频道 跳转到首页某个 页面
LiveDataBus.getInstance().with(EventConstants.HOME_TAB_ONE_CHANNEL_JUMP).postValue(bean);
}
}
/**
* 回到主页
*/
public static void goBackMainPage() {
BaseApplication.getInstance().getLifecycleCallbacks().skipToFront("com.peopledailychina.activity.activity.AppMainActivity");
}
/**
* 拦截画中画,如果开启则关闭
*/
public static void interceptorPictureInPicture() {
// if (PipUtils.isInPictureInPictureMode(ActivityController.getCurrentActivity())) {
// ActivityController.getCurrentActivity().finish();
// }
}
/**
* 跳转播放详情页
*
* @param programId
*/
public static void jumpVideoDetailPage(String programId) {
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
// jsonObject.addProperty(IntentConstants.VOD_ID, programId);
// jsonObject.addProperty(IntentConstants.VOD_ID, CommonConstant.TEST_VIDEO_ID);
actionBean.paramBean.params = jsonObject.toString();
// actionBean.paramBean.pageID = RouterConstants.PATH_LIVE_DETAIL_ACTIVITY;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
public static void preloadImage(String firstItemCover) {
if (!TextUtils.isEmpty(firstItemCover)) {
ThreadPoolUtils.backgroundSubmit(new Runnable() {
@Override
public void run() {
ImageUtils.getInstance().preloadImage(AppContext.getContext(), firstItemCover);
}
});
}
}
/**
* 链接跳转
* skipType 1.跳转原生页面,带参数:(视频、直播、活动) 2.跳转原生页面,不带参数:(搜索、设置、登录、个人中心)
* 3.跳转H5页面(APP内部打开) 4.跳转H5页面(APP外部打开) 5 跳转拉起第三方页面
* neatlyParameter 第一个参数专题页title 第二参数创作者id
*/
public static void linkJump(String linkurl, String... neatlyParameter) {
// displayschedulesystemapp://dss.app/openwith?contentType=video&contentld=124 contentld
// ?后面接参数 contentType=subjectpage 专题页 contentType=video 视频详情页 ;contentld专题页面ID或视频内容ID
try {
String[] openwith = linkurl.split("openwith\\?");
if (openwith.length < 2) {
// 进入默认跳转页面
ProcessUtils.pullDefaultPage();
return;
}
String parameter = openwith[1];
String[] param = parameter.split("&");
HashMap<String, String> result = new HashMap();
for (String str : param) {
String[] eq = str.split("=", 2);
if (eq.length > 1) {
String decodeUrl = eq[1];
try {
// 使用的时候解码
decodeUrl = URLDecoder.decode(decodeUrl, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
result.put(eq[0], decodeUrl);
}
}
// // 兼容老版 链接
// if (linkurl.contains("pageType=subjectpage")) {
// ProcessUtils.goToAreaSubjectPage(result.get("pageId"), neatlyParameter.length == 0 ? "" :
// neatlyParameter[0]);
// return;
// }
// if (linkurl.contains("pageType=fanslist")) {
// jumpMyFollowList("1");
// return;
// }
// if (linkurl.contains("pageType=homepage")) {
// LiveDataBus.getInstance().with(EventConstants.SWITCH_HOME_TAB).postValue(0);
// ProcessUtils.goMainPage();
// return;
// }
// switch (result.get("skipType")) {
// case "1":
switch (result.get("contentType")) {
// 视频详情页面
case "video":
ProcessUtils.jumpShortPlay(result.get("contentld"), "");
break;
// // 直播详情页面
// case "live":
// dealJumpLive(result.get("contentld"), "");
// break;
// // 活动详情页
// case "activity":
// ProcessUtils.jumpActivity(ContentBean.SubType.COLLECT, result.get("contentld"), "");
// break;
// // 活动详情页
// case "accountowner":
//
// break;
// 专题页详情
case "subjectpage":
ProcessUtils.goToAreaSubjectPage(result.get("contentld"),
neatlyParameter.length == 0 ? "" : neatlyParameter[0]);
break;
// // 跳转合集
// case "videoserials":
// ProcessUtils.jumpVideoAlbumDetail(result.get("serialsId"),
// CommonConstant.H5_PULL_ALBUM_ENTRY);
// break;
default:
// 进入默认跳转页面
ProcessUtils.pullDefaultPage();
break;
}
// break;
// case "2":
// switch (result.get("contentType")) {
// // 搜索
// case "search":
// toSearchActivity();
// break;
// // 登录
// case "login":
// toOneKeyLoginActivity();
// break;
// // 我的粉丝列表
// case "fanslist":
// jumpMyFollowList("1");
// break;
// // 回 首页列表
// case "homepage":
// LiveDataBus.getInstance().with(EventConstants.SWITCH_HOME_TAB).postValue(0);
// ProcessUtils.goMainPage();
// break;
// default:
// //进入默认跳转页面
// ProcessUtils.pullDefaultPage();
// break;
// }
// break;
// case "3":
// //外链
// if (linkurl.contains("type=h5")) {
// if ("1".equals(result.get("isLogin"))) {
// toOneKeyLoginActivity();
// } else {
// ProcessUtils.jumpH5Page(result.get("url"));
// }
//
// }
// break;
// case "4":
// break;
// case "5":
// break;
// default:
// //进入默认跳转页面
// ProcessUtils.pullDefaultPage();
// break;
// }
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 进入启动页
*/
public static void startWelcomeActivity() {
ActionBean actionBean = new ActionBean();
actionBean.paramBean.pageID = RouterConstants.PATH_WELCOME_ACTIVITY;
WdRouterRule.getInstance()
.processAction(AppContext.getContext(), actionBean,
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
/**
* 未匹配到拉起的页面,默认跳转
*/
public static void pullDefaultPage() {
if (!SpUtils.isFirstAgreementFlag()
&& BaseApplication.getInstance().getLifecycleCallbacks().hasActivity("AppMainActivity")) {
BaseApplication.getInstance().getLifecycleCallbacks().makeMainTaskToFront();
} else {
startWelcomeActivity();
}
}
/**
* 组件跳转页面
*
* @param compBean
*/
public static ContentBean compJumpPage(CompBean compBean) {
// 组件跳转的基本信息转换成 ContentBean对象
ContentBean bean = new ContentBean();
// if(compBean.positionList != null && compBean.positionList.size() > 0
// && compBean.positionList.get(0) != null
// && compBean.positionList.get(0).posObjectList != null
// && compBean.positionList.get(0).posObjectList.size()>0
// && compBean.positionList.get(0).posObjectList.get(0) != null){
//
// bean.setObjectType(compBean.positionList.get(0).posObjectList.get(0).objectType);
// bean.setObjectId(compBean.positionList.get(0).posObjectList.get(0).objectId);
// if(compBean.positionList.get(0).posObjectList.get(0).topicInfo != null
// && compBean.positionList.get(0).posObjectList.get(0).topicInfo.size()>0
// && compBean.positionList.get(0).posObjectList.get(0).topicInfo.get(0)!=null){
// bean.setTopicInfo(compBean.positionList.get(0).posObjectList.get(0).topicInfo.get(0));
// bean.setNewsSummary(compBean.positionList.get(0).posObjectList.get(0).topicInfo.get(0).description);
// }
// bean.setNewsTitle(compBean.positionList.get(0).posObjectList.get(0).title);
// }
//// bean.setObjectLevel(compBean.getObjectLevel());
// bean.setPageId(compBean.getPageId());
//
//// bean.setChannelInfoBean(compBean.getChannelInfoBean());
//// bean.setBottomNavId(compBean.getBottomNavId());
//// bean.setSourceInterfaceVal(compBean.getSourceInterfaceVal());
// bean.setCompId(compBean.getId());
//// bean.setTopicTemplate(compBean.getTopicTemplate());
//
//// bean.setRecommend(compBean.getRecommend());
// bean.setPageId(compBean.getPageId());
// bean.setGroupId(compBean.getGroupId());
// bean.setSortValue(compBean.sortValue);
// bean.setObjectId(compBean.objectId);
// bean.setTitle(compBean.objectTitle);
// bean.setObjectType(compBean.objectType);
// bean.topicInfo = compBean.topicInfo;
// 页面跳转方法
processPage(bean);
return bean;
}
/**
* 进入H5页面
*
* @param linkUrl h5页面地址
*/
public static void goH5DetailPage(String linkUrl) {
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.WEBSITES_SEARCHURL, linkUrl);
actionBean.paramBean.params = jsonObject.toString();
// actionBean.paramBean.pageID = RouterConstants.PATH_MODULE_H5_DETAIL;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 检测当前频道是否是特殊频道
*
* @param tabBean
* @return
*/
public static boolean checkSpcialChannle(ChannelBean tabBean) {
String channelId = tabBean.getChannelId();// 频道id
if (CHANNEL_ID_EL_NEWS.equals(channelId)) {
// 跳转电子报
return true;
} else if (CHANNEL_ID_VOICE.equals(channelId)) {
// 音频频道
return true;
}
return false;
}
/**
* 特殊频道跳转页面方法
*
* @param tabBean
* @return true:表示完成跳转;false:不支持跳转
*/
public static boolean specialChannelJumpPage(ChannelBean tabBean) {
boolean jump = false;
String channelId = tabBean.getChannelId();// 频道id
if (CHANNEL_ID_EL_NEWS.equals(channelId)) {
jump = true;
// 跳转电子报
goToPaperActivity();
} else if (CHANNEL_ID_VOICE.equals(channelId)) {
jump = true;
// 音频频道
// goTestAudio(tabBean.getPageId(), channelId);
}
return jump;
}
/**
* 特殊频道跳转页面方法
*
* @param tabBean
* @return true:表示完成跳转;false:不支持跳转
*/
public static boolean specialChannelJumpPage(ContentBean tabBean) {
boolean jump = false;
String channelId = tabBean.getObjectId();// 频道id
if (CHANNEL_ID_EL_NEWS.equals(channelId)) {
jump = true;
// 跳转电子报
goToPaperActivity();
} else if (CHANNEL_ID_VOICE.equals(channelId)) {
jump = true;
// 音频频道
// goTestAudio(tabBean.getPageId(), channelId);
}
return jump;
}
/**
* 进入电子报
*/
@SuppressLint("ResourceType")
public static void goToPaperActivity() {
// 加进场动效
ActionBean actionBean = new ActionBean();
actionBean.enterAnim = R.anim.enter_page_bottom_top_in;
actionBean.exitAnim = R.anim.enter_page_alpha_top_out;
actionBean.paramBean.pageID = RouterConstants.PATH_MODULE_PAPER;
WdRouterRule.getInstance().processAction(ActivityController.getCurrentActivity(), actionBean);
}
/**
* 从电子报跳转进入相应的详情页面
*
* @param paperPageItemBean
*/
public static void goToDetailFromElPage(PaperPageItemBean paperPageItemBean) {
ContentBean contentBean = new ContentBean();
contentBean.setObjectId(paperPageItemBean.getNewsId());
contentBean.setObjectType(String.valueOf(paperPageItemBean.getNewsType()));
contentBean.setRelId(paperPageItemBean.getRelId());
contentBean.setRelType(TextUtils.isEmpty(paperPageItemBean.getRelType()) ? 0 : Integer.parseInt(paperPageItemBean.getRelType()));
processPage(contentBean);
//埋点
// GeneralTrack.getInstance().contentClickElePage(paperPageItemBean);
}
/**
* 检测组件的“more”视图是否显示
*
* @param compBean
* @return
*/
public static boolean checkCompMoreShow(CompBean compBean) {
boolean showMore = checkMoreJumpPage(compBean);
if (!showMore) {
return true;
} else {
String objectType = compBean.getObjectType();
if (TextUtils.isEmpty(objectType)) {
return false;
} else {
int type = Integer.parseInt(objectType);
if (ContentTypeConstant.URL_TYPE_ZERO == type) {
return false;
} else {
return true;
}
}
}
}
/**
* 检测组件more跳转
*
* @param compBean
* @return true : 表示正常业务跳转;false:指定特殊页面跳转
*/
public static boolean checkMoreJumpPage(CompBean compBean) {
boolean loacalJump = true;
String dataSourceType = compBean.getDataSourceType();
if (!TextUtils.isEmpty(dataSourceType)) {
if (CompDataSourceBean.LIVE_HORIZONTAL_CARD.equals(dataSourceType)
|| CompDataSourceBean.LIVE_RESERVATION.equals(dataSourceType)
|| CompDataSourceBean.LIVE_MONTHLY_RANKING.equals(dataSourceType)) {
loacalJump = false;
}
}
return loacalJump;
}
/**
* 移动生产-发布图文携带数据
*
* @param dataSource 来源
* @param dataJson 携带的数据
*/
public static void jumpArticlePage(int dataSource, String dataJson) {
// 拦截画中画
interceptorPictureInPicture();
ActionBean actionBean = new ActionBean();
actionBean.paramBean.pageID = RouterConstants.PATH_PUBLISH_ARTICLE_ACTIVITY;
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.PUBLISH_DATA_BEAN,
dataJson);
jsonObject.addProperty(IntentConstants.PUBLISH_SOURCE, dataSource);
actionBean.paramBean.params = jsonObject.toString();
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 跳转图集详情页
*
* @param data
*/
public static void goToImageSlidePage(String data) {
// 拦截画中画
interceptorPictureInPicture();
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.IMAGE_SLIDE_DATA, data);
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_IMAGE_SLIDE_PAGE;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 跳转到举报
*/
public static void goReport(String object, String source) {
// 拦截画中画
interceptorPictureInPicture();
ActionBean actionBean = new ActionBean();
actionBean.paramBean.pageID = RouterConstants.PATH_BASE_COMMON_REPORT;
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("objectBean", object);
jsonObject.addProperty("objectSource", source);
actionBean.paramBean.params = jsonObject.toString();
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 播报悬浮窗点击头像跳转音频详情页
*
* @param music
*/
public static void goToMusicDetailPageFromMiniPlayer(String music) {
if (!TextUtils.isEmpty(music)) {
VoicePlayerBean data = GsonUtils.fromJson(music, VoicePlayerBean.class);
//图文详情页
if((ContentTypeConstant.URL_TYPE_EIGHT+"").equals(data.objectType)){
goToArticleDetailPageVoice(data);
return;
}
data.setType(3);
String json = GsonUtils.objectToJson(data);
// 拦截画中画
interceptorPictureInPicture();
ActionBean actionBean = new ActionBean();
actionBean.paramBean.pageID = RouterConstants.PATH_MUSIC_AUDIO_DEAILS;
String musicBeanJsonObj = json;
if (musicBeanJsonObj == null) {
return;
}
//当前是图文详情页,并且之前的是音频详情页,并且objectid一样,直接关闭当前页面。避免多次间接打开相同页面
if(isSameArticleDetail(data.getObjectId()) && isSameBeforePageMusicDetail(data.getObjectId())){
BaseApplication.getInstance().getLifecycleCallbacks().current().finish();
return;
}
actionBean.paramBean.params = musicBeanJsonObj;
BaseApplication.getInstance().getLifecycleCallbacks().finishTarget("com.people.musicplayer.ui.activity.MusicNewPlayerActivity");
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
}
/**
* 语音播报点击头像跳转图文详情页
*/
public static void goToArticleDetailPageVoice(VoicePlayerBean voicePlayerBean) {
if (isSameArticleDetail(voicePlayerBean.getObjectId())) {
return;
}
// 拦截画中画
ActionBean actionBean = new ActionBean();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(IntentConstants.TOPIC_ID, voicePlayerBean.getTopicId());
jsonObject.addProperty(IntentConstants.CHANNEL_ID, voicePlayerBean.getChannelId());
jsonObject.addProperty(IntentConstants.CONTENT_ID, voicePlayerBean.getObjectId());
jsonObject.addProperty(IntentConstants.CONTENT_TYPE, voicePlayerBean.getContentType());
jsonObject.addProperty(IntentConstants.COMP_ID, voicePlayerBean.getCompId());
jsonObject.addProperty(IntentConstants.SOURCE_PAGE, voicePlayerBean.getSourcePage());
jsonObject.addProperty(IntentConstants.REL_ID, voicePlayerBean.getRelId());
jsonObject.addProperty(IntentConstants.REL_TYPE, voicePlayerBean.getRelType());
jsonObject.addProperty(IntentConstants.PARAM_BOTTOM_COMMENT_AREA, voicePlayerBean.isScrollToBottom());
//推荐定义字段
if(voicePlayerBean.getTraceBean() != null){
jsonObject.addProperty(IntentConstants.SCENEID, voicePlayerBean.getTraceBean().sceneId);
jsonObject.addProperty(IntentConstants.SUBSCENEID, voicePlayerBean.getTraceBean().subSceneId);
jsonObject.addProperty(IntentConstants.CNSTRACEID, voicePlayerBean.getTraceBean().traceId);
jsonObject.addProperty(IntentConstants.ITEMID, voicePlayerBean.getTraceBean().itemId);
jsonObject.addProperty(IntentConstants.EXPIDS, voicePlayerBean.getTraceBean().expIds);
}
actionBean.paramBean.params = jsonObject.toString();
actionBean.paramBean.pageID = RouterConstants.PATH_ARTICLE_DETAIL_PAGE;
WdRouterRule.getInstance().processAction(AppContext.getContext(), actionBean);
}
/**
* 之前的页面是音频详情页,并且图文详情页的id和音频详情页的id一致
* */
public static boolean isSameBeforePageMusicDetail(String objectId) {
//如果是当前页面,则不再跳转
if(CommonVarUtils.musicDetailMusicObjectId != null && CommonVarUtils.musicDetailMusicObjectId.equals(objectId)
&&BaseApplication.getInstance().getLifecycleCallbacks().before()!= null
&& "com.people.musicplayer.ui.activity.MusicNewPlayerActivity".equals(BaseApplication.getInstance().getLifecycleCallbacks().before().getClass().getName())
){
return true;
}
return false;
}
}