@chiyou/minigame-framework 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +66 -0
  2. package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.d.ts +78 -0
  3. package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.js +230 -0
  4. package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.d.ts +31 -0
  5. package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.js +224 -0
  6. package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.d.ts +34 -0
  7. package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.js +524 -0
  8. package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.d.ts +34 -0
  9. package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.js +631 -0
  10. package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.d.ts +33 -0
  11. package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.js +460 -0
  12. package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.d.ts +31 -0
  13. package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.js +227 -0
  14. package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.d.ts +33 -0
  15. package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.js +458 -0
  16. package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.d.ts +35 -0
  17. package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.js +770 -0
  18. package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.d.ts +33 -0
  19. package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.js +519 -0
  20. package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.d.ts +33 -0
  21. package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.js +492 -0
  22. package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.d.ts +33 -0
  23. package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.js +695 -0
  24. package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.d.ts +34 -0
  25. package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.js +597 -0
  26. package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.d.ts +33 -0
  27. package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.js +458 -0
  28. package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.d.ts +51 -0
  29. package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.js +17 -0
  30. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.d.ts +45 -0
  31. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.js +555 -0
  32. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.d.ts +44 -0
  33. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.js +148 -0
  34. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.d.ts +48 -0
  35. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.js +715 -0
  36. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.d.ts +44 -0
  37. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.js +296 -0
  38. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.d.ts +45 -0
  39. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.js +284 -0
  40. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.d.ts +44 -0
  41. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.js +283 -0
  42. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.d.ts +43 -0
  43. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.js +406 -0
  44. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.d.ts +43 -0
  45. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.js +248 -0
  46. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.d.ts +44 -0
  47. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.js +517 -0
  48. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.d.ts +44 -0
  49. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.js +295 -0
  50. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.d.ts +55 -0
  51. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.js +964 -0
  52. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.d.ts +44 -0
  53. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.js +295 -0
  54. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.d.ts +44 -0
  55. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.js +393 -0
  56. package/dist/Framework/Definition/AdDefinition.d.ts +130 -0
  57. package/dist/Framework/Definition/AdDefinition.js +208 -0
  58. package/dist/Framework/Definition/FrameworkBase.d.ts +13 -0
  59. package/dist/Framework/Definition/FrameworkBase.js +23 -0
  60. package/dist/Framework/Definition/PrivacyDefinition.d.ts +51 -0
  61. package/dist/Framework/Definition/PrivacyDefinition.js +70 -0
  62. package/dist/Framework/Definition/SocialDefinition.d.ts +16 -0
  63. package/dist/Framework/Definition/SocialDefinition.js +2 -0
  64. package/dist/Framework/Definition/SystemDefinition.d.ts +43 -0
  65. package/dist/Framework/Definition/SystemDefinition.js +28 -0
  66. package/dist/Framework/Definition/UIDefinition.d.ts +6 -0
  67. package/dist/Framework/Definition/UIDefinition.js +7 -0
  68. package/dist/Framework/Definition/UserDefinition.d.ts +14 -0
  69. package/dist/Framework/Definition/UserDefinition.js +10 -0
  70. package/dist/Framework/Manager/AdMgr.d.ts +57 -0
  71. package/dist/Framework/Manager/AdMgr.js +684 -0
  72. package/dist/Framework/Manager/AudioMgr.d.ts +28 -0
  73. package/dist/Framework/Manager/AudioMgr.js +265 -0
  74. package/dist/Framework/Manager/BaseMgr.d.ts +18 -0
  75. package/dist/Framework/Manager/BaseMgr.js +114 -0
  76. package/dist/Framework/Manager/EventMgr.d.ts +18 -0
  77. package/dist/Framework/Manager/EventMgr.js +90 -0
  78. package/dist/Framework/Manager/ExcelMgr.d.ts +24 -0
  79. package/dist/Framework/Manager/ExcelMgr.js +156 -0
  80. package/dist/Framework/Manager/LifeCycleMgr.d.ts +20 -0
  81. package/dist/Framework/Manager/LifeCycleMgr.js +110 -0
  82. package/dist/Framework/Manager/NodePoolMgr.d.ts +53 -0
  83. package/dist/Framework/Manager/NodePoolMgr.js +279 -0
  84. package/dist/Framework/Manager/PrivacyMgr.d.ts +15 -0
  85. package/dist/Framework/Manager/PrivacyMgr.js +176 -0
  86. package/dist/Framework/Manager/ResMgr.d.ts +49 -0
  87. package/dist/Framework/Manager/ResMgr.js +337 -0
  88. package/dist/Framework/Manager/SocialMgr.d.ts +23 -0
  89. package/dist/Framework/Manager/SocialMgr.js +220 -0
  90. package/dist/Framework/Manager/SystemMgr.d.ts +24 -0
  91. package/dist/Framework/Manager/SystemMgr.js +222 -0
  92. package/dist/Framework/Manager/TimerMgr.d.ts +11 -0
  93. package/dist/Framework/Manager/TimerMgr.js +63 -0
  94. package/dist/Framework/Manager/UIMgr.d.ts +33 -0
  95. package/dist/Framework/Manager/UIMgr.js +223 -0
  96. package/dist/Framework/Manager/UserMgr.d.ts +15 -0
  97. package/dist/Framework/Manager/UserMgr.js +148 -0
  98. package/dist/Framework/Utils/BezierUtils.d.ts +49 -0
  99. package/dist/Framework/Utils/BezierUtils.js +247 -0
  100. package/dist/Framework/Utils/CSVUtils.d.ts +35 -0
  101. package/dist/Framework/Utils/CSVUtils.js +341 -0
  102. package/dist/Framework/Utils/LogUtils.d.ts +7 -0
  103. package/dist/Framework/Utils/LogUtils.js +32 -0
  104. package/dist/Framework/Utils/NumberUtils.d.ts +16 -0
  105. package/dist/Framework/Utils/NumberUtils.js +44 -0
  106. package/dist/Framework/Utils/TaskUtils.d.ts +10 -0
  107. package/dist/Framework/Utils/TaskUtils.js +24 -0
  108. package/dist/Framework/Utils/TimeUtils.d.ts +19 -0
  109. package/dist/Framework/Utils/TimeUtils.js +33 -0
  110. package/dist/Framework/Utils/WXBizDataCryptUtils.d.ts +12 -0
  111. package/dist/Framework/Utils/WXBizDataCryptUtils.js +37 -0
  112. package/dist/index.d.ts +30 -0
  113. package/dist/index.js +35 -0
  114. package/package.json +40 -0
@@ -0,0 +1,460 @@
1
+ import { AdDefinition, InterstitialAd_Callback_Status, RewardedVideoAd_Callback_Status } from "../../Definition/AdDefinition";
2
+ import { PlatformID } from "../../Definition/SystemDefinition";
3
+ import { LogUtils } from "../../Utils/LogUtils";
4
+ import { AbsAdAdapter, InterstitialAdStatus, RewardedVideoAdStatus } from "./AbsAdAdapter";
5
+ class HWBannerAd {
6
+ constructor(adUnitId, ad, isFirstLoad) {
7
+ this.unitId = adUnitId;
8
+ this.ad = ad;
9
+ this.errorListener = null;
10
+ this.loadListener = null;
11
+ this.isRecreating = false;
12
+ this.isFirstLoad = isFirstLoad;
13
+ }
14
+ destroy() {
15
+ if (this.ad !== null) {
16
+ if (this.errorListener !== null) {
17
+ this.ad.offError(this.errorListener);
18
+ this.errorListener = null;
19
+ }
20
+ if (this.loadListener !== null) {
21
+ this.ad.offLoad(this.loadListener);
22
+ this.loadListener = null;
23
+ }
24
+ this.ad.destroy();
25
+ this.ad = null;
26
+ }
27
+ this.isRecreating = false;
28
+ }
29
+ }
30
+ class HWInterstitialAd {
31
+ constructor(adUnitId, callback) {
32
+ this.unitId = adUnitId;
33
+ this.ad = null;
34
+ this.status = InterstitialAdStatus.Status_Init;
35
+ this.callback = callback;
36
+ this.errorListener = null;
37
+ this.loadListener = null;
38
+ this.closeListener = null;
39
+ this.isShowImmediately = false;
40
+ }
41
+ destroy() {
42
+ if (this.ad !== null) {
43
+ if (this.errorListener !== null) {
44
+ this.ad.offError(this.errorListener);
45
+ this.errorListener = null;
46
+ }
47
+ if (this.loadListener !== null) {
48
+ this.ad.offLoad(this.loadListener);
49
+ this.loadListener = null;
50
+ }
51
+ if (this.closeListener !== null) {
52
+ this.ad.offClose(this.closeListener);
53
+ this.closeListener = null;
54
+ }
55
+ this.ad.destroy();
56
+ this.ad = null;
57
+ }
58
+ this.isShowImmediately = false;
59
+ this.status = InterstitialAdStatus.Status_Destroyed;
60
+ }
61
+ }
62
+ class HWRewardedVideoAd {
63
+ constructor(adUnitId, callback) {
64
+ this.unitId = adUnitId;
65
+ this.ad = null;
66
+ this.status = RewardedVideoAdStatus.Status_Destroyed;
67
+ this.callback = callback;
68
+ this.errorListener = null;
69
+ this.loadListener = null;
70
+ this.closeListener = null;
71
+ this.isShowImmediately = false;
72
+ }
73
+ destroy() {
74
+ if (this.ad !== null) {
75
+ if (this.errorListener !== null) {
76
+ this.ad.offError(this.errorListener);
77
+ this.errorListener = null;
78
+ }
79
+ if (this.loadListener !== null) {
80
+ this.ad.offLoad(this.loadListener);
81
+ this.loadListener = null;
82
+ }
83
+ if (this.closeListener !== null) {
84
+ this.ad.offClose(this.closeListener);
85
+ this.closeListener = null;
86
+ }
87
+ this.ad.destroy();
88
+ this.ad = null;
89
+ }
90
+ this.isShowImmediately = false;
91
+ this.status = RewardedVideoAdStatus.Status_Destroyed;
92
+ }
93
+ }
94
+ export class AdAdapterHuaWei extends AbsAdAdapter {
95
+ constructor() {
96
+ super(...arguments);
97
+ this.hwInterstitialAd = null;
98
+ this.hwRewardedVideoAd = null;
99
+ this.hwBannerAds = [];
100
+ }
101
+ init(interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback) {
102
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "init()");
103
+ this.hwInterstitialAd = new HWInterstitialAd(interstitialAdUnitId, interstitialAdCallback);
104
+ this.hwRewardedVideoAd = new HWRewardedVideoAd(rewardedVideoAdUnitId, rewardedVideoAdCallback);
105
+ this.hwBannerAds = [];
106
+ }
107
+ createBannerAd(adUnitId) {
108
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "createBannerAd()");
109
+ let isFirstLoad = true;
110
+ for (let i = 0; i < this.hwBannerAds.length; i++) {
111
+ if (this.hwBannerAds[i].unitId === adUnitId) {
112
+ isFirstLoad = this.hwBannerAds[i].isFirstLoad;
113
+ break;
114
+ }
115
+ }
116
+ this.destroyBannerAd(adUnitId);
117
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "createBannerAd() adUnitId=" + adUnitId);
118
+ let bannerAdInfo = AdDefinition.AdInfoConfig.BannerAd_Info;
119
+ if (bannerAdInfo === null || !bannerAdInfo.shouldShow) {
120
+ return false;
121
+ }
122
+ let bannerAdPlatformInfo = AdDefinition.BannerAdStyleConfig.get(PlatformID.ID_QuickGame_HuaWei);
123
+ if (bannerAdPlatformInfo === null) {
124
+ return false;
125
+ }
126
+ let bannerAdPosition = this.calcBannerAdPosition(bannerAdInfo, bannerAdPlatformInfo);
127
+ let sysInfo = window["qg"].getSystemInfoSync();
128
+ let bannerTop = sysInfo.safeArea.height;
129
+ let bannerAdParam = {
130
+ adUnitId: adUnitId,
131
+ style: {
132
+ top: bannerTop - bannerAdPosition.realHeight,
133
+ left: 0,
134
+ width: bannerAdPosition.realWidth,
135
+ height: bannerAdPosition.realHeight,
136
+ },
137
+ };
138
+ if (bannerAdPlatformInfo.canAutoRefresh) {
139
+ bannerAdParam.adIntervals = bannerAdPlatformInfo.refreshInterval;
140
+ }
141
+ LogUtils.Instance.log("", "bannerAdParam");
142
+ LogUtils.Instance.log("", bannerAdParam);
143
+ let bannerAd = window["qg"].createBannerAd(bannerAdParam);
144
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "qg.createBannerAd() " + (bannerAd !== null ? "success" : "fail"));
145
+ LogUtils.Instance.log("", bannerAd);
146
+ if (!bannerAd) {
147
+ return false;
148
+ }
149
+ let hwBannerAd = new HWBannerAd(adUnitId, bannerAd, isFirstLoad);
150
+ this.hwBannerAds.push(hwBannerAd);
151
+ hwBannerAd.errorListener = (err) => {
152
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwBannerAd.ad.onError()");
153
+ if (err) {
154
+ LogUtils.Instance.log("", err);
155
+ }
156
+ if (hwBannerAd.isFirstLoad) {
157
+ hwBannerAd.isFirstLoad = false;
158
+ }
159
+ if (!hwBannerAd.isRecreating) {
160
+ hwBannerAd.isRecreating = true;
161
+ this.scheduleOnce(() => {
162
+ hwBannerAd.isRecreating = false;
163
+ this.createBannerAd(adUnitId);
164
+ }, 15);
165
+ }
166
+ };
167
+ hwBannerAd.ad.onError(hwBannerAd.errorListener);
168
+ hwBannerAd.loadListener = () => {
169
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwBannerAd.ad.onLoad()");
170
+ if (hwBannerAd.isFirstLoad) {
171
+ hwBannerAd.isFirstLoad = false;
172
+ }
173
+ };
174
+ hwBannerAd.ad.onLoad(hwBannerAd.loadListener);
175
+ if (!bannerAdPlatformInfo.canAutoRefresh) {
176
+ if (!hwBannerAd.isRecreating) {
177
+ hwBannerAd.isRecreating = true;
178
+ this.scheduleOnce(() => {
179
+ hwBannerAd.isRecreating = false;
180
+ this.createBannerAd(adUnitId);
181
+ }, bannerAdPlatformInfo.refreshInterval);
182
+ }
183
+ }
184
+ if (this.adMgr.isPermanentAdShowing()) {
185
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwBannerAd.ad.show()");
186
+ hwBannerAd.ad.show();
187
+ }
188
+ return true;
189
+ }
190
+ destroyBannerAd(adUnitId) {
191
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "destroyBannerAd(): adUnitId=" + adUnitId);
192
+ let index = -1;
193
+ for (let i = 0; i < this.hwBannerAds.length; i++) {
194
+ if (this.hwBannerAds[i].unitId === adUnitId) {
195
+ index = i;
196
+ break;
197
+ }
198
+ }
199
+ if (index >= 0) {
200
+ this.hwBannerAds[index].destroy();
201
+ this.hwBannerAds.splice(index, 1);
202
+ }
203
+ }
204
+ showBannerAd(adUnitId) {
205
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "showBannerAd(): adUnitId=" + adUnitId);
206
+ for (let i = 0; i < this.hwBannerAds.length; i++) {
207
+ if (this.hwBannerAds[i].unitId === adUnitId) {
208
+ this.hwBannerAds[i].ad.show();
209
+ break;
210
+ }
211
+ }
212
+ }
213
+ hideBannerAd(adUnitId) {
214
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hideBannerAd(): adUnitId=" + adUnitId);
215
+ for (let i = 0; i < this.hwBannerAds.length; i++) {
216
+ if (this.hwBannerAds[i].unitId === adUnitId) {
217
+ this.hwBannerAds[i].ad.hide();
218
+ break;
219
+ }
220
+ }
221
+ }
222
+ createInterstitialAd() {
223
+ this.destroyInterstitialAd();
224
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "createInterstitialAd() adUnitId=" + this.hwInterstitialAd.unitId);
225
+ let interstitialAd = window["qg"].createInterstitialAd({
226
+ adUnitId: this.hwInterstitialAd.unitId
227
+ });
228
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "qg.createInterstitialAd() " + (interstitialAd !== null ? "success" : "fail"));
229
+ LogUtils.Instance.log("", interstitialAd);
230
+ if (!interstitialAd) {
231
+ this.hwInterstitialAd.status = InterstitialAdStatus.Status_Error;
232
+ this.hwInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
233
+ return;
234
+ }
235
+ this.hwInterstitialAd.ad = interstitialAd;
236
+ this.hwInterstitialAd.status = InterstitialAdStatus.Status_Init;
237
+ this.hwInterstitialAd.errorListener = (err) => {
238
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwInterstitialAd.ad.onError()");
239
+ if (err) {
240
+ LogUtils.Instance.log("", err);
241
+ }
242
+ if (this.hwInterstitialAd.status !== InterstitialAdStatus.Status_Watching) {
243
+ this.hwInterstitialAd.status = InterstitialAdStatus.Status_Error;
244
+ this.hwInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
245
+ }
246
+ };
247
+ this.hwInterstitialAd.ad.onError(this.hwInterstitialAd.errorListener);
248
+ this.hwInterstitialAd.loadListener = () => {
249
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwInterstitialAd.ad.onLoad()");
250
+ this.hwInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
251
+ if (this.hwInterstitialAd.isShowImmediately) {
252
+ this.hwInterstitialAd.isShowImmediately = false;
253
+ this._showInterstitialAd();
254
+ }
255
+ };
256
+ this.hwInterstitialAd.ad.onLoad(this.hwInterstitialAd.loadListener);
257
+ this.hwInterstitialAd.closeListener = () => {
258
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwInterstitialAd.ad.onClose()");
259
+ this.hwInterstitialAd.status = InterstitialAdStatus.Status_Watched;
260
+ this.hwInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Close);
261
+ this.scheduleOnce(() => {
262
+ if (this.hwInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
263
+ this._loadInterstitialAd(false);
264
+ }
265
+ }, 2);
266
+ };
267
+ this.hwInterstitialAd.ad.onClose(this.hwInterstitialAd.closeListener);
268
+ this.scheduleOnce(() => {
269
+ if (this.hwInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
270
+ this._loadInterstitialAd(false);
271
+ }
272
+ }, 2);
273
+ }
274
+ showInterstitialAd() {
275
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "showInterstitialAd()");
276
+ if (this.hwInterstitialAd.ad === null) {
277
+ return;
278
+ }
279
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwInterstitialAd.status=" + InterstitialAdStatus[this.hwInterstitialAd.status]);
280
+ switch (this.hwInterstitialAd.status) {
281
+ case InterstitialAdStatus.Status_Destroyed:
282
+ case InterstitialAdStatus.Status_Watching:
283
+ case InterstitialAdStatus.Status_StartToWatch:
284
+ break;
285
+ case InterstitialAdStatus.Status_Loaded:
286
+ this._showInterstitialAd();
287
+ break;
288
+ case InterstitialAdStatus.Status_Watched:
289
+ case InterstitialAdStatus.Status_Init:
290
+ case InterstitialAdStatus.Status_Error:
291
+ this._loadInterstitialAd(true);
292
+ break;
293
+ default:
294
+ break;
295
+ }
296
+ }
297
+ destroyInterstitialAd() {
298
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "destroyInterstitialAd()");
299
+ this.hwInterstitialAd.destroy();
300
+ }
301
+ isIntersititialAdShowing() {
302
+ if (this.hwInterstitialAd.ad === null) {
303
+ return false;
304
+ }
305
+ if (this.hwInterstitialAd.status === InterstitialAdStatus.Status_Watching) {
306
+ return true;
307
+ }
308
+ return false;
309
+ }
310
+ _loadInterstitialAd(isShowImmediately) {
311
+ this.hwInterstitialAd.isShowImmediately = isShowImmediately;
312
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwInterstitialAd.ad.load()");
313
+ this.hwInterstitialAd.ad.load();
314
+ }
315
+ _showInterstitialAd() {
316
+ if (this.hwInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
317
+ return;
318
+ }
319
+ this.hwInterstitialAd.status = InterstitialAdStatus.Status_Watching;
320
+ this.hwInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Watching);
321
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwInterstitialAd.ad.show()");
322
+ this.hwInterstitialAd.ad.show();
323
+ }
324
+ createRewardedVideoAd() {
325
+ this.destroyRewardedVideoAd();
326
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "createRewardedVideoAd() adUnitId=" + this.hwRewardedVideoAd.unitId);
327
+ let rewardedVideoAd = window["qg"].createRewardedVideoAd({
328
+ adUnitId: this.hwRewardedVideoAd.unitId
329
+ });
330
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "qg.createRewardedVideoAd() " + (rewardedVideoAd !== null ? "success" : "fail"));
331
+ LogUtils.Instance.log("", rewardedVideoAd);
332
+ if (!rewardedVideoAd) {
333
+ this.hwRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
334
+ this.hwRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
335
+ return;
336
+ }
337
+ this.hwRewardedVideoAd.ad = rewardedVideoAd;
338
+ this.hwRewardedVideoAd.status = RewardedVideoAdStatus.Status_Init;
339
+ this.hwRewardedVideoAd.errorListener = (err) => {
340
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwRewardedVideoAd.ad.onError()");
341
+ if (err) {
342
+ LogUtils.Instance.log("", err);
343
+ }
344
+ if (this.hwRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Watching) {
345
+ this.hwRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
346
+ this.hwRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
347
+ }
348
+ };
349
+ this.hwRewardedVideoAd.ad.onError(this.hwRewardedVideoAd.errorListener);
350
+ this.hwRewardedVideoAd.loadListener = () => {
351
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwRewardedVideoAd.ad.onLoad()");
352
+ this.hwRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
353
+ if (this.hwRewardedVideoAd.isShowImmediately) {
354
+ this.hwRewardedVideoAd.isShowImmediately = false;
355
+ this._showRewardedVideoAd();
356
+ }
357
+ };
358
+ this.hwRewardedVideoAd.ad.onLoad(this.hwRewardedVideoAd.loadListener);
359
+ this.hwRewardedVideoAd.closeListener = (res) => {
360
+ let isEnded = (res !== null) ? res.isEnded : false;
361
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwRewardedVideoAd.ad.onClose()");
362
+ LogUtils.Instance.log("", "isEnded=" + isEnded);
363
+ this.hwRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watched;
364
+ if (isEnded) {
365
+ this.hwRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Complete);
366
+ }
367
+ else {
368
+ this.hwRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Giveup);
369
+ }
370
+ this.scheduleOnce(() => {
371
+ if (this.hwRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
372
+ this._loadRewardedVideoAd(false);
373
+ }
374
+ }, 2);
375
+ };
376
+ this.hwRewardedVideoAd.ad.onClose(this.hwRewardedVideoAd.closeListener);
377
+ this.scheduleOnce(() => {
378
+ if (this.hwRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
379
+ this._loadRewardedVideoAd(false);
380
+ }
381
+ }, 2);
382
+ }
383
+ showRewardedVideoAd() {
384
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "showRewardedVideoAd()");
385
+ if (this.hwRewardedVideoAd.ad === null) {
386
+ return;
387
+ }
388
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwRewardedVideoAd.status=" + RewardedVideoAdStatus[this.hwRewardedVideoAd.status]);
389
+ switch (this.hwRewardedVideoAd.status) {
390
+ case RewardedVideoAdStatus.Status_Destroyed:
391
+ case RewardedVideoAdStatus.Status_Watching:
392
+ case RewardedVideoAdStatus.Status_StartToWatch:
393
+ break;
394
+ case RewardedVideoAdStatus.Status_Loaded:
395
+ this._showRewardedVideoAd();
396
+ break;
397
+ case RewardedVideoAdStatus.Status_Watched:
398
+ case RewardedVideoAdStatus.Status_Error:
399
+ case RewardedVideoAdStatus.Status_Init:
400
+ this._loadRewardedVideoAd(true);
401
+ break;
402
+ default:
403
+ break;
404
+ }
405
+ }
406
+ destroyRewardedVideoAd() {
407
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "destroyRewardedVideoAd()");
408
+ this.hwRewardedVideoAd.destroy();
409
+ }
410
+ isRewardedVideoAdLoaded() {
411
+ if (this.hwRewardedVideoAd.ad === null) {
412
+ return false;
413
+ }
414
+ if (this.hwRewardedVideoAd.status === RewardedVideoAdStatus.Status_Loaded) {
415
+ return true;
416
+ }
417
+ return false;
418
+ }
419
+ isRewardedVideoAdShowing() {
420
+ if (this.hwRewardedVideoAd.ad === null) {
421
+ return false;
422
+ }
423
+ if (this.hwRewardedVideoAd.status === RewardedVideoAdStatus.Status_Watching) {
424
+ return true;
425
+ }
426
+ return false;
427
+ }
428
+ _loadRewardedVideoAd(isShowImmediately) {
429
+ this.hwRewardedVideoAd.isShowImmediately = isShowImmediately;
430
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwRewardedVideoAd.ad.load()");
431
+ this.hwRewardedVideoAd.ad.load();
432
+ }
433
+ _showRewardedVideoAd() {
434
+ if (this.hwRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
435
+ return;
436
+ }
437
+ this.hwRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watching;
438
+ this.hwRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Watching);
439
+ LogUtils.Instance.log(AdAdapterHuaWei.TAG, "hwRewardedVideoAd.ad.show()");
440
+ this.hwRewardedVideoAd.ad.show();
441
+ }
442
+ createCustomAd(adUnitId) {
443
+ return false;
444
+ }
445
+ destroyCustomAd(adUnitId) {
446
+ }
447
+ showCustomAd(adUnitId) {
448
+ }
449
+ hideCustomAd(adUnitId) {
450
+ }
451
+ createPortalAd(adUnitId) {
452
+ }
453
+ destroyPortalAd(adUnitId) {
454
+ }
455
+ showPortalAd(adUnitId) {
456
+ }
457
+ hidePortalAd(adUnitId) {
458
+ }
459
+ }
460
+ AdAdapterHuaWei.TAG = "AdAdapterHuaWei";
@@ -0,0 +1,31 @@
1
+ import { AbsAdAdapter } from './AbsAdAdapter';
2
+ export declare class AdAdapterJingDong extends AbsAdAdapter {
3
+ static TAG: string;
4
+ private jdRewardedVideoAd;
5
+ init(interstitialAdUnitId: string, interstitialAdCallback: Function, rewardedVideoAdUnitId: string, rewardedVideoAdCallback: Function): void;
6
+ createBannerAd(adUnitId: string): boolean;
7
+ destroyBannerAd(adUnitId: string): void;
8
+ showBannerAd(adUnitId: string): void;
9
+ hideBannerAd(adUnitId: string): void;
10
+ createInterstitialAd(): void;
11
+ showInterstitialAd(): void;
12
+ destroyInterstitialAd(): void;
13
+ isIntersititialAdShowing(): boolean;
14
+ protected _loadInterstitialAd(isShowImmediately: boolean): void;
15
+ protected _showInterstitialAd(): void;
16
+ createRewardedVideoAd(): void;
17
+ showRewardedVideoAd(): void;
18
+ destroyRewardedVideoAd(): void;
19
+ isRewardedVideoAdLoaded(): boolean;
20
+ isRewardedVideoAdShowing(): boolean;
21
+ protected _loadRewardedVideoAd(isShowImmediately: boolean): void;
22
+ protected _showRewardedVideoAd(): void;
23
+ createCustomAd(adUnitId: string): boolean;
24
+ destroyCustomAd(adUnitId: string): void;
25
+ showCustomAd(adUnitId: string): void;
26
+ hideCustomAd(adUnitId: string): void;
27
+ createPortalAd(adUnitId: string): void;
28
+ destroyPortalAd(adUnitId: string): void;
29
+ showPortalAd(adUnitId: string): void;
30
+ hidePortalAd(adUnitId: string): void;
31
+ }