@chiyou/minigame-framework 1.0.2 → 1.0.3
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.
- package/assets/Scripts/index.ts +2 -5
- package/package.json +5 -10
- package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.d.ts +0 -78
- package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.js +0 -230
- package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.d.ts +0 -31
- package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.js +0 -224
- package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.d.ts +0 -34
- package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.js +0 -524
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.d.ts +0 -34
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.js +0 -631
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.js +0 -460
- package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.d.ts +0 -31
- package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.js +0 -227
- package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.js +0 -458
- package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.d.ts +0 -35
- package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.js +0 -770
- package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.js +0 -519
- package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.js +0 -492
- package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.js +0 -695
- package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.d.ts +0 -34
- package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.js +0 -597
- package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.js +0 -458
- package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.d.ts +0 -51
- package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.js +0 -17
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.d.ts +0 -45
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.js +0 -555
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.js +0 -148
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.d.ts +0 -48
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.js +0 -715
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.js +0 -296
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.d.ts +0 -45
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.js +0 -284
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.js +0 -283
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.d.ts +0 -43
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.js +0 -406
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.d.ts +0 -43
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.js +0 -248
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.js +0 -517
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.js +0 -295
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.d.ts +0 -55
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.js +0 -964
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.js +0 -295
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.js +0 -393
- package/dist/Framework/Definition/AdDefinition.d.ts +0 -130
- package/dist/Framework/Definition/AdDefinition.js +0 -208
- package/dist/Framework/Definition/FrameworkBase.d.ts +0 -13
- package/dist/Framework/Definition/FrameworkBase.js +0 -23
- package/dist/Framework/Definition/PrivacyDefinition.d.ts +0 -51
- package/dist/Framework/Definition/PrivacyDefinition.js +0 -70
- package/dist/Framework/Definition/SocialDefinition.d.ts +0 -16
- package/dist/Framework/Definition/SocialDefinition.js +0 -2
- package/dist/Framework/Definition/SystemDefinition.d.ts +0 -43
- package/dist/Framework/Definition/SystemDefinition.js +0 -28
- package/dist/Framework/Definition/UIDefinition.d.ts +0 -6
- package/dist/Framework/Definition/UIDefinition.js +0 -7
- package/dist/Framework/Definition/UserDefinition.d.ts +0 -14
- package/dist/Framework/Definition/UserDefinition.js +0 -10
- package/dist/Framework/Manager/AdMgr.d.ts +0 -57
- package/dist/Framework/Manager/AdMgr.js +0 -684
- package/dist/Framework/Manager/AudioMgr.d.ts +0 -28
- package/dist/Framework/Manager/AudioMgr.js +0 -265
- package/dist/Framework/Manager/BaseMgr.d.ts +0 -18
- package/dist/Framework/Manager/BaseMgr.js +0 -114
- package/dist/Framework/Manager/EventMgr.d.ts +0 -18
- package/dist/Framework/Manager/EventMgr.js +0 -90
- package/dist/Framework/Manager/ExcelMgr.d.ts +0 -24
- package/dist/Framework/Manager/ExcelMgr.js +0 -156
- package/dist/Framework/Manager/LifeCycleMgr.d.ts +0 -20
- package/dist/Framework/Manager/LifeCycleMgr.js +0 -110
- package/dist/Framework/Manager/NodePoolMgr.d.ts +0 -53
- package/dist/Framework/Manager/NodePoolMgr.js +0 -279
- package/dist/Framework/Manager/PrivacyMgr.d.ts +0 -15
- package/dist/Framework/Manager/PrivacyMgr.js +0 -176
- package/dist/Framework/Manager/ResMgr.d.ts +0 -49
- package/dist/Framework/Manager/ResMgr.js +0 -337
- package/dist/Framework/Manager/SocialMgr.d.ts +0 -23
- package/dist/Framework/Manager/SocialMgr.js +0 -220
- package/dist/Framework/Manager/SystemMgr.d.ts +0 -24
- package/dist/Framework/Manager/SystemMgr.js +0 -222
- package/dist/Framework/Manager/TimerMgr.d.ts +0 -11
- package/dist/Framework/Manager/TimerMgr.js +0 -63
- package/dist/Framework/Manager/UIMgr.d.ts +0 -33
- package/dist/Framework/Manager/UIMgr.js +0 -223
- package/dist/Framework/Manager/UserMgr.d.ts +0 -15
- package/dist/Framework/Manager/UserMgr.js +0 -148
- package/dist/Framework/Utils/BezierUtils.d.ts +0 -49
- package/dist/Framework/Utils/BezierUtils.js +0 -247
- package/dist/Framework/Utils/CSVUtils.d.ts +0 -35
- package/dist/Framework/Utils/CSVUtils.js +0 -341
- package/dist/Framework/Utils/LogUtils.d.ts +0 -7
- package/dist/Framework/Utils/LogUtils.js +0 -32
- package/dist/Framework/Utils/NumberUtils.d.ts +0 -16
- package/dist/Framework/Utils/NumberUtils.js +0 -44
- package/dist/Framework/Utils/TaskUtils.d.ts +0 -10
- package/dist/Framework/Utils/TaskUtils.js +0 -24
- package/dist/Framework/Utils/TimeUtils.d.ts +0 -19
- package/dist/Framework/Utils/TimeUtils.js +0 -33
- package/dist/Framework/Utils/WXBizDataCryptUtils.d.ts +0 -12
- package/dist/Framework/Utils/WXBizDataCryptUtils.js +0 -37
- package/dist/index.d.ts +0 -30
- package/dist/index.js +0 -35
|
@@ -1,770 +0,0 @@
|
|
|
1
|
-
import { InterstitialAd_Callback_Status, RewardedVideoAd_Callback_Status, AdDefinition } from "../../Definition/AdDefinition";
|
|
2
|
-
import { PlatformID } from "../../Definition/SystemDefinition";
|
|
3
|
-
import { LogUtils } from "../../Utils/LogUtils";
|
|
4
|
-
import { AbsAdAdapter, InterstitialAdStatus, RewardedVideoAdStatus } from "./AbsAdAdapter";
|
|
5
|
-
class OppoBannerAd {
|
|
6
|
-
constructor(adUnitId, ad, isFirstLoad) {
|
|
7
|
-
this.unitId = adUnitId;
|
|
8
|
-
this.ad = ad;
|
|
9
|
-
this.errorListener = null;
|
|
10
|
-
this.loadListener = null;
|
|
11
|
-
this.resizeListener = null;
|
|
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
|
-
if (this.resizeListener !== null) {
|
|
25
|
-
this.ad.offResize(this.resizeListener);
|
|
26
|
-
this.resizeListener = null;
|
|
27
|
-
}
|
|
28
|
-
this.ad.destroy();
|
|
29
|
-
this.ad = null;
|
|
30
|
-
}
|
|
31
|
-
this.isRecreating = false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
class OppoInterstitialAd {
|
|
35
|
-
constructor(adUnitId, callback) {
|
|
36
|
-
this.unitId = adUnitId;
|
|
37
|
-
this.ad = null;
|
|
38
|
-
this.status = InterstitialAdStatus.Status_Init;
|
|
39
|
-
this.callback = callback;
|
|
40
|
-
this.errorListener = null;
|
|
41
|
-
this.loadListener = null;
|
|
42
|
-
this.closeListener = null;
|
|
43
|
-
this.isShowImmediately = false;
|
|
44
|
-
}
|
|
45
|
-
destroy() {
|
|
46
|
-
if (this.ad !== null) {
|
|
47
|
-
if (this.errorListener !== null) {
|
|
48
|
-
this.ad.offError(this.errorListener);
|
|
49
|
-
this.errorListener = null;
|
|
50
|
-
}
|
|
51
|
-
if (this.loadListener !== null) {
|
|
52
|
-
this.ad.offLoad(this.loadListener);
|
|
53
|
-
this.loadListener = null;
|
|
54
|
-
}
|
|
55
|
-
if (this.closeListener !== null) {
|
|
56
|
-
this.ad.offClose(this.closeListener);
|
|
57
|
-
this.closeListener = null;
|
|
58
|
-
}
|
|
59
|
-
this.ad.destroy();
|
|
60
|
-
this.ad = null;
|
|
61
|
-
}
|
|
62
|
-
this.isShowImmediately = false;
|
|
63
|
-
this.status = InterstitialAdStatus.Status_Destroyed;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
class OppoRewardedVideoAd {
|
|
67
|
-
constructor(adUnitId, callback) {
|
|
68
|
-
this.unitId = adUnitId;
|
|
69
|
-
this.ad = null;
|
|
70
|
-
this.status = RewardedVideoAdStatus.Status_Init;
|
|
71
|
-
this.callback = callback;
|
|
72
|
-
this.errorListener = null;
|
|
73
|
-
this.loadListener = null;
|
|
74
|
-
this.closeListener = null;
|
|
75
|
-
this.isShowImmediately = false;
|
|
76
|
-
}
|
|
77
|
-
destroy() {
|
|
78
|
-
if (this.ad !== null) {
|
|
79
|
-
if (this.errorListener !== null) {
|
|
80
|
-
this.ad.offError(this.errorListener);
|
|
81
|
-
this.errorListener = null;
|
|
82
|
-
}
|
|
83
|
-
if (this.loadListener !== null) {
|
|
84
|
-
this.ad.offLoad(this.loadListener);
|
|
85
|
-
this.loadListener = null;
|
|
86
|
-
}
|
|
87
|
-
if (this.closeListener !== null) {
|
|
88
|
-
this.ad.offClose(this.closeListener);
|
|
89
|
-
this.closeListener = null;
|
|
90
|
-
}
|
|
91
|
-
this.ad.destroy();
|
|
92
|
-
this.ad = null;
|
|
93
|
-
}
|
|
94
|
-
this.isShowImmediately = false;
|
|
95
|
-
this.status = RewardedVideoAdStatus.Status_Destroyed;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
class OppoCustomAd {
|
|
99
|
-
constructor(adUnitId, ad, isFirstLoad) {
|
|
100
|
-
this.unitId = adUnitId;
|
|
101
|
-
this.ad = ad;
|
|
102
|
-
this.errorListener = null;
|
|
103
|
-
this.loadListener = null;
|
|
104
|
-
this.isFirstLoad = isFirstLoad;
|
|
105
|
-
}
|
|
106
|
-
destroy() {
|
|
107
|
-
if (this.ad !== null) {
|
|
108
|
-
if (this.errorListener !== null) {
|
|
109
|
-
this.ad.offError(this.errorListener);
|
|
110
|
-
this.errorListener = null;
|
|
111
|
-
}
|
|
112
|
-
if (this.loadListener !== null) {
|
|
113
|
-
this.ad.offLoad(this.loadListener);
|
|
114
|
-
this.loadListener = null;
|
|
115
|
-
}
|
|
116
|
-
this.ad.destroy();
|
|
117
|
-
this.ad = null;
|
|
118
|
-
}
|
|
119
|
-
this.isRecreating = false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
class OppoPortalAd {
|
|
123
|
-
constructor(adUnitId, ad) {
|
|
124
|
-
this.unitId = adUnitId;
|
|
125
|
-
this.ad = ad;
|
|
126
|
-
this.errorListener = null;
|
|
127
|
-
this.loadListener = null;
|
|
128
|
-
this.showListener = null;
|
|
129
|
-
this.closeListener = null;
|
|
130
|
-
this.isLoaded = false;
|
|
131
|
-
this.isShowing = false;
|
|
132
|
-
this.isRecreating = false;
|
|
133
|
-
}
|
|
134
|
-
destroy() {
|
|
135
|
-
if (this.ad !== null) {
|
|
136
|
-
if (this.errorListener !== null) {
|
|
137
|
-
this.ad.offError(this.errorListener);
|
|
138
|
-
this.errorListener = null;
|
|
139
|
-
}
|
|
140
|
-
if (this.loadListener !== null) {
|
|
141
|
-
this.ad.offLoad(this.loadListener);
|
|
142
|
-
this.loadListener = null;
|
|
143
|
-
}
|
|
144
|
-
if (this.showListener !== null) {
|
|
145
|
-
this.ad.offShow(this.showListener);
|
|
146
|
-
this.showListener = null;
|
|
147
|
-
}
|
|
148
|
-
if (this.closeListener !== null) {
|
|
149
|
-
this.ad.offClose(this.closeListener);
|
|
150
|
-
this.closeListener = null;
|
|
151
|
-
}
|
|
152
|
-
this.ad.destroy();
|
|
153
|
-
this.ad = null;
|
|
154
|
-
}
|
|
155
|
-
this.isLoaded = false;
|
|
156
|
-
this.isShowing = false;
|
|
157
|
-
this.isRecreating = false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
export class AdAdapterOppo extends AbsAdAdapter {
|
|
161
|
-
constructor() {
|
|
162
|
-
super(...arguments);
|
|
163
|
-
this.oppoInterstitialAd = null;
|
|
164
|
-
this.oppoRewardedVideoAd = null;
|
|
165
|
-
this.oppoBannerAds = [];
|
|
166
|
-
this.oppoCustomAds = [];
|
|
167
|
-
this.oppoPortalAds = [];
|
|
168
|
-
}
|
|
169
|
-
init(interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback) {
|
|
170
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "init()");
|
|
171
|
-
this.oppoInterstitialAd = new OppoInterstitialAd(interstitialAdUnitId, interstitialAdCallback);
|
|
172
|
-
this.oppoRewardedVideoAd = new OppoRewardedVideoAd(rewardedVideoAdUnitId, rewardedVideoAdCallback);
|
|
173
|
-
this.oppoBannerAds = [];
|
|
174
|
-
this.oppoCustomAds = [];
|
|
175
|
-
this.oppoPortalAds = [];
|
|
176
|
-
}
|
|
177
|
-
createBannerAd(adUnitId) {
|
|
178
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "createBannerAd()");
|
|
179
|
-
let isFirstLoad = true;
|
|
180
|
-
for (let i = 0; i < this.oppoBannerAds.length; i++) {
|
|
181
|
-
if (this.oppoBannerAds[i].unitId === adUnitId) {
|
|
182
|
-
isFirstLoad = this.oppoBannerAds[i].isFirstLoad;
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
this.destroyBannerAd(adUnitId);
|
|
187
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "createBannerAd() adUnitId=" + adUnitId);
|
|
188
|
-
let bannerAdInfo = AdDefinition.AdInfoConfig.BannerAd_Info;
|
|
189
|
-
if (bannerAdInfo === null || !bannerAdInfo.shouldShow) {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
let bannerAdPlatformInfo = AdDefinition.BannerAdStyleConfig.get(PlatformID.ID_QuickGame_Oppo);
|
|
193
|
-
if (bannerAdPlatformInfo === null) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
let bannerAdPosition = this.calcBannerAdPosition(bannerAdInfo, bannerAdPlatformInfo);
|
|
197
|
-
let bannerAdParam = {
|
|
198
|
-
adUnitId: adUnitId,
|
|
199
|
-
style: {
|
|
200
|
-
width: bannerAdPosition.realWidth,
|
|
201
|
-
height: bannerAdPosition.realHeight,
|
|
202
|
-
left: bannerAdPosition.left,
|
|
203
|
-
top: bannerAdPosition.top,
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
if (bannerAdPlatformInfo.canAutoRefresh) {
|
|
207
|
-
bannerAdParam.adIntervals = bannerAdPlatformInfo.refreshInterval;
|
|
208
|
-
}
|
|
209
|
-
let bannerAd = window["qg"].createBannerAd(bannerAdParam);
|
|
210
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "qg.createBannerAd() " + (bannerAd !== null ? "success" : "fail"));
|
|
211
|
-
LogUtils.Instance.log("", bannerAd);
|
|
212
|
-
if (!bannerAd) {
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
let oppoBannerAd = new OppoBannerAd(adUnitId, bannerAd, isFirstLoad);
|
|
216
|
-
this.oppoBannerAds.push(oppoBannerAd);
|
|
217
|
-
oppoBannerAd.errorListener = (err) => {
|
|
218
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoBannerAd.ad.onError()");
|
|
219
|
-
if (err) {
|
|
220
|
-
LogUtils.Instance.log("", err);
|
|
221
|
-
}
|
|
222
|
-
if (!oppoBannerAd.isRecreating) {
|
|
223
|
-
oppoBannerAd.isRecreating = true;
|
|
224
|
-
this.scheduleOnce(() => {
|
|
225
|
-
oppoBannerAd.isRecreating = false;
|
|
226
|
-
this.createBannerAd(adUnitId);
|
|
227
|
-
}, 15);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
oppoBannerAd.ad.onError(oppoBannerAd.errorListener);
|
|
231
|
-
oppoBannerAd.resizeListener = (res) => {
|
|
232
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoBannerAd.ad.onResize()");
|
|
233
|
-
if (res) {
|
|
234
|
-
LogUtils.Instance.log("", res);
|
|
235
|
-
}
|
|
236
|
-
if (oppoBannerAd.isFirstLoad) {
|
|
237
|
-
oppoBannerAd.isFirstLoad = false;
|
|
238
|
-
oppoBannerAd.ad.hide();
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
oppoBannerAd.ad.onResize(oppoBannerAd.resizeListener);
|
|
242
|
-
oppoBannerAd.loadListener = () => {
|
|
243
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoBannerAd.ad.onLoad()");
|
|
244
|
-
};
|
|
245
|
-
oppoBannerAd.ad.onLoad(oppoBannerAd.loadListener);
|
|
246
|
-
if (!bannerAdPlatformInfo.canAutoRefresh) {
|
|
247
|
-
if (!oppoBannerAd.isRecreating) {
|
|
248
|
-
oppoBannerAd.isRecreating = true;
|
|
249
|
-
this.scheduleOnce(() => {
|
|
250
|
-
oppoBannerAd.isRecreating = false;
|
|
251
|
-
this.createBannerAd(adUnitId);
|
|
252
|
-
}, bannerAdPlatformInfo.refreshInterval);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
if (this.adMgr.isPermanentAdShowing()) {
|
|
256
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoBannerAd.ad.show()");
|
|
257
|
-
oppoBannerAd.ad.show()
|
|
258
|
-
.then(() => {
|
|
259
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoBannerAd.ad.show() success");
|
|
260
|
-
}).catch((err) => {
|
|
261
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoBannerAd.ad.show() fail");
|
|
262
|
-
if (err) {
|
|
263
|
-
LogUtils.Instance.log("", err);
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
destroyBannerAd(adUnitId) {
|
|
270
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "destroyBannerAd(): adUnitId=" + adUnitId);
|
|
271
|
-
let index = -1;
|
|
272
|
-
for (let i = 0; i < this.oppoBannerAds.length; i++) {
|
|
273
|
-
if (this.oppoBannerAds[i].unitId === adUnitId) {
|
|
274
|
-
index = i;
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (index >= 0) {
|
|
279
|
-
this.oppoBannerAds[index].destroy();
|
|
280
|
-
this.oppoBannerAds.splice(index, 1);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
showBannerAd(adUnitId) {
|
|
284
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "showBannerAd(): adUnitId=" + adUnitId);
|
|
285
|
-
for (let i = 0; i < this.oppoBannerAds.length; i++) {
|
|
286
|
-
if (this.oppoBannerAds[i].unitId === adUnitId) {
|
|
287
|
-
this.oppoBannerAds[i].ad.show();
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
hideBannerAd(adUnitId) {
|
|
293
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "hideBannerAd(): adUnitId=" + adUnitId);
|
|
294
|
-
for (let i = 0; i < this.oppoBannerAds.length; i++) {
|
|
295
|
-
if (this.oppoBannerAds[i].unitId === adUnitId) {
|
|
296
|
-
this.oppoBannerAds[i].ad.hide();
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
createInterstitialAd() {
|
|
302
|
-
this.destroyInterstitialAd();
|
|
303
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "createInterstitialAd() adUnitId=" + this.oppoInterstitialAd.unitId);
|
|
304
|
-
let interstitialAd = window["qg"].createInterstitialAd({
|
|
305
|
-
adUnitId: this.oppoInterstitialAd.unitId
|
|
306
|
-
});
|
|
307
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "qg.createInterstitialAd() " + (interstitialAd !== null ? "success" : "fail"));
|
|
308
|
-
LogUtils.Instance.log("", interstitialAd);
|
|
309
|
-
if (!interstitialAd) {
|
|
310
|
-
this.oppoInterstitialAd.status = InterstitialAdStatus.Status_Error;
|
|
311
|
-
this.oppoInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
this.oppoInterstitialAd.ad = interstitialAd;
|
|
315
|
-
this.oppoInterstitialAd.status = InterstitialAdStatus.Status_Init;
|
|
316
|
-
this.oppoInterstitialAd.errorListener = (err) => {
|
|
317
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.onError()");
|
|
318
|
-
if (err) {
|
|
319
|
-
LogUtils.Instance.log("", err);
|
|
320
|
-
}
|
|
321
|
-
if (this.oppoInterstitialAd.status !== InterstitialAdStatus.Status_Watching) {
|
|
322
|
-
this.oppoInterstitialAd.status = InterstitialAdStatus.Status_Error;
|
|
323
|
-
this.oppoInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
this.oppoInterstitialAd.ad.onError(this.oppoInterstitialAd.errorListener);
|
|
327
|
-
this.oppoInterstitialAd.loadListener = () => {
|
|
328
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.onLoad()");
|
|
329
|
-
this.oppoInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
|
|
330
|
-
if (this.oppoInterstitialAd.isShowImmediately) {
|
|
331
|
-
this.oppoInterstitialAd.isShowImmediately = false;
|
|
332
|
-
this._showInterstitialAd();
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
this.oppoInterstitialAd.ad.onLoad(this.oppoInterstitialAd.loadListener);
|
|
336
|
-
this.oppoInterstitialAd.closeListener = () => {
|
|
337
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.onClose()");
|
|
338
|
-
this.oppoInterstitialAd.status = InterstitialAdStatus.Status_Watched;
|
|
339
|
-
this.oppoInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Close);
|
|
340
|
-
this.scheduleOnce(() => {
|
|
341
|
-
if (this.oppoInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
|
|
342
|
-
this._loadInterstitialAd(false);
|
|
343
|
-
}
|
|
344
|
-
}, 2);
|
|
345
|
-
};
|
|
346
|
-
this.oppoInterstitialAd.ad.onClose(this.oppoInterstitialAd.closeListener);
|
|
347
|
-
this.scheduleOnce(() => {
|
|
348
|
-
if (this.oppoInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
|
|
349
|
-
this._loadInterstitialAd(false);
|
|
350
|
-
}
|
|
351
|
-
}, 2);
|
|
352
|
-
}
|
|
353
|
-
showInterstitialAd() {
|
|
354
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "showInterstitialAd()");
|
|
355
|
-
if (this.oppoInterstitialAd.ad === null) {
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.status=" + InterstitialAdStatus[this.oppoInterstitialAd.status]);
|
|
359
|
-
switch (this.oppoInterstitialAd.status) {
|
|
360
|
-
case InterstitialAdStatus.Status_Destroyed:
|
|
361
|
-
case InterstitialAdStatus.Status_Watching:
|
|
362
|
-
case InterstitialAdStatus.Status_StartToWatch:
|
|
363
|
-
break;
|
|
364
|
-
case InterstitialAdStatus.Status_Loaded:
|
|
365
|
-
this._showInterstitialAd();
|
|
366
|
-
break;
|
|
367
|
-
case InterstitialAdStatus.Status_Watched:
|
|
368
|
-
case InterstitialAdStatus.Status_Init:
|
|
369
|
-
case InterstitialAdStatus.Status_Error:
|
|
370
|
-
this._loadInterstitialAd(true);
|
|
371
|
-
break;
|
|
372
|
-
default:
|
|
373
|
-
break;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
destroyInterstitialAd() {
|
|
377
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "destroyInterstitialAd()");
|
|
378
|
-
this.oppoInterstitialAd.destroy();
|
|
379
|
-
}
|
|
380
|
-
isIntersititialAdShowing() {
|
|
381
|
-
if (this.oppoInterstitialAd.ad === null) {
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
384
|
-
if (this.oppoInterstitialAd.status === InterstitialAdStatus.Status_Watching) {
|
|
385
|
-
return true;
|
|
386
|
-
}
|
|
387
|
-
return false;
|
|
388
|
-
}
|
|
389
|
-
_loadInterstitialAd(isShowImmediately) {
|
|
390
|
-
this.oppoInterstitialAd.isShowImmediately = isShowImmediately;
|
|
391
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.load()");
|
|
392
|
-
this.oppoInterstitialAd.ad.load()
|
|
393
|
-
.then(() => {
|
|
394
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.load() success");
|
|
395
|
-
}).catch((err) => {
|
|
396
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.load() error");
|
|
397
|
-
if (err) {
|
|
398
|
-
LogUtils.Instance.log("", err);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
_showInterstitialAd() {
|
|
403
|
-
if (this.oppoInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
this.oppoInterstitialAd.status = InterstitialAdStatus.Status_StartToWatch;
|
|
407
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.show()");
|
|
408
|
-
this.oppoInterstitialAd.ad.show()
|
|
409
|
-
.then(() => {
|
|
410
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.show() success");
|
|
411
|
-
if (this.oppoInterstitialAd.status === InterstitialAdStatus.Status_StartToWatch) {
|
|
412
|
-
this.oppoInterstitialAd.status = InterstitialAdStatus.Status_Watching;
|
|
413
|
-
this.oppoInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Watching);
|
|
414
|
-
}
|
|
415
|
-
}).catch((err) => {
|
|
416
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoInterstitialAd.ad.show() error");
|
|
417
|
-
if (err) {
|
|
418
|
-
LogUtils.Instance.log("", err);
|
|
419
|
-
}
|
|
420
|
-
if (this.oppoInterstitialAd.status === InterstitialAdStatus.Status_StartToWatch) {
|
|
421
|
-
this.oppoInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
createRewardedVideoAd() {
|
|
426
|
-
this.destroyRewardedVideoAd();
|
|
427
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "createRewardedVideoAd() adUnitId=" + this.oppoRewardedVideoAd.unitId);
|
|
428
|
-
let rewardedVideoAd = window["qg"].createRewardedVideoAd({
|
|
429
|
-
adUnitId: this.oppoRewardedVideoAd.unitId
|
|
430
|
-
});
|
|
431
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "qg.createRewardedVideoAd() " + (rewardedVideoAd !== null ? "success" : "fail"));
|
|
432
|
-
LogUtils.Instance.log("", rewardedVideoAd);
|
|
433
|
-
if (!rewardedVideoAd) {
|
|
434
|
-
this.oppoRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
|
|
435
|
-
this.oppoRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
this.oppoRewardedVideoAd.ad = rewardedVideoAd;
|
|
439
|
-
this.oppoRewardedVideoAd.status = RewardedVideoAdStatus.Status_Init;
|
|
440
|
-
this.oppoRewardedVideoAd.errorListener = (err) => {
|
|
441
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.onError()");
|
|
442
|
-
if (err) {
|
|
443
|
-
LogUtils.Instance.log("", err);
|
|
444
|
-
}
|
|
445
|
-
if (this.oppoRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Watching) {
|
|
446
|
-
this.oppoRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
|
|
447
|
-
this.oppoRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
this.oppoRewardedVideoAd.ad.onError(this.oppoRewardedVideoAd.errorListener);
|
|
451
|
-
this.oppoRewardedVideoAd.loadListener = () => {
|
|
452
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.onLoad()");
|
|
453
|
-
this.oppoRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
|
|
454
|
-
if (this.oppoRewardedVideoAd.isShowImmediately) {
|
|
455
|
-
this.oppoRewardedVideoAd.isShowImmediately = false;
|
|
456
|
-
this._showRewardedVideoAd();
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
this.oppoRewardedVideoAd.ad.onLoad(this.oppoRewardedVideoAd.loadListener);
|
|
460
|
-
this.oppoRewardedVideoAd.closeListener = (res) => {
|
|
461
|
-
let isEnded = (res !== null) ? res.isEnded : false;
|
|
462
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.onClose()");
|
|
463
|
-
LogUtils.Instance.log("", "isEnded=" + isEnded);
|
|
464
|
-
this.oppoRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watched;
|
|
465
|
-
if (isEnded) {
|
|
466
|
-
this.oppoRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Complete);
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
this.oppoRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Giveup);
|
|
470
|
-
}
|
|
471
|
-
this.scheduleOnce(() => {
|
|
472
|
-
if (this.oppoRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
473
|
-
this._loadRewardedVideoAd(false);
|
|
474
|
-
}
|
|
475
|
-
}, 2);
|
|
476
|
-
};
|
|
477
|
-
this.oppoRewardedVideoAd.ad.onClose(this.oppoRewardedVideoAd.closeListener);
|
|
478
|
-
this.scheduleOnce(() => {
|
|
479
|
-
if (this.oppoRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
480
|
-
this._loadRewardedVideoAd(false);
|
|
481
|
-
}
|
|
482
|
-
}, 2);
|
|
483
|
-
}
|
|
484
|
-
showRewardedVideoAd() {
|
|
485
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "showRewardedVideoAd()");
|
|
486
|
-
if (this.oppoRewardedVideoAd.ad === null) {
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.status=" + RewardedVideoAdStatus[this.oppoRewardedVideoAd.status]);
|
|
490
|
-
switch (this.oppoRewardedVideoAd.status) {
|
|
491
|
-
case RewardedVideoAdStatus.Status_Destroyed:
|
|
492
|
-
case RewardedVideoAdStatus.Status_StartToWatch:
|
|
493
|
-
case RewardedVideoAdStatus.Status_Watching:
|
|
494
|
-
break;
|
|
495
|
-
case RewardedVideoAdStatus.Status_Loaded:
|
|
496
|
-
this._showRewardedVideoAd();
|
|
497
|
-
break;
|
|
498
|
-
case RewardedVideoAdStatus.Status_Watched:
|
|
499
|
-
case RewardedVideoAdStatus.Status_Init:
|
|
500
|
-
case RewardedVideoAdStatus.Status_Error:
|
|
501
|
-
this._loadRewardedVideoAd(true);
|
|
502
|
-
break;
|
|
503
|
-
default:
|
|
504
|
-
break;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
destroyRewardedVideoAd() {
|
|
508
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "destroyRewardedVideoAd()");
|
|
509
|
-
this.oppoRewardedVideoAd.destroy();
|
|
510
|
-
}
|
|
511
|
-
isRewardedVideoAdLoaded() {
|
|
512
|
-
if (this.oppoRewardedVideoAd.ad === null) {
|
|
513
|
-
return false;
|
|
514
|
-
}
|
|
515
|
-
if (this.oppoRewardedVideoAd.status === RewardedVideoAdStatus.Status_Loaded) {
|
|
516
|
-
return true;
|
|
517
|
-
}
|
|
518
|
-
return false;
|
|
519
|
-
}
|
|
520
|
-
isRewardedVideoAdShowing() {
|
|
521
|
-
if (this.oppoRewardedVideoAd.ad === null) {
|
|
522
|
-
return false;
|
|
523
|
-
}
|
|
524
|
-
if (this.oppoRewardedVideoAd.status === RewardedVideoAdStatus.Status_Watching) {
|
|
525
|
-
return true;
|
|
526
|
-
}
|
|
527
|
-
return false;
|
|
528
|
-
}
|
|
529
|
-
_loadRewardedVideoAd(isShowImmediately) {
|
|
530
|
-
this.oppoRewardedVideoAd.isShowImmediately = isShowImmediately;
|
|
531
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.load()");
|
|
532
|
-
this.oppoRewardedVideoAd.ad.load()
|
|
533
|
-
.then(() => {
|
|
534
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.load() success");
|
|
535
|
-
}).catch((err) => {
|
|
536
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.load() error");
|
|
537
|
-
if (err) {
|
|
538
|
-
LogUtils.Instance.log("", err);
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
_showRewardedVideoAd() {
|
|
543
|
-
if (this.oppoRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
this.oppoRewardedVideoAd.status = RewardedVideoAdStatus.Status_StartToWatch;
|
|
547
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.show()");
|
|
548
|
-
this.oppoRewardedVideoAd.ad.show()
|
|
549
|
-
.then(() => {
|
|
550
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.show() success");
|
|
551
|
-
if (this.oppoRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
|
|
552
|
-
this.oppoRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watching;
|
|
553
|
-
this.oppoRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Watching);
|
|
554
|
-
}
|
|
555
|
-
}).catch((err) => {
|
|
556
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoRewardedVideoAd.ad.show() error");
|
|
557
|
-
if (err) {
|
|
558
|
-
LogUtils.Instance.log("", err);
|
|
559
|
-
}
|
|
560
|
-
if (this.oppoRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
|
|
561
|
-
this.oppoRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
createCustomAd(adUnitId) {
|
|
566
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "createCustomAd()");
|
|
567
|
-
let isFirstLoad = true;
|
|
568
|
-
for (let i = 0; i < this.oppoCustomAds.length; i++) {
|
|
569
|
-
if (this.oppoCustomAds[i].unitId === adUnitId) {
|
|
570
|
-
isFirstLoad = this.oppoCustomAds[i].isFirstLoad;
|
|
571
|
-
break;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
this.destroyCustomAd(adUnitId);
|
|
575
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "createCustomAd() adUnitId=" + adUnitId);
|
|
576
|
-
let customAdInfo = AdDefinition.AdInfoConfig.CustomAd_Info;
|
|
577
|
-
if (customAdInfo === null || !customAdInfo.shouldShow) {
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
let customAdPlatformInfo = AdDefinition.CustomAdStyleConfig.get(PlatformID.ID_QuickGame_Oppo);
|
|
581
|
-
if (customAdPlatformInfo === null) {
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
let customAdPosition = this.calcCustomAdPosition(customAdInfo, customAdPlatformInfo);
|
|
585
|
-
let customAdParam = {
|
|
586
|
-
adUnitId: adUnitId,
|
|
587
|
-
style: {
|
|
588
|
-
left: customAdPosition.left,
|
|
589
|
-
top: customAdPosition.top,
|
|
590
|
-
orientation: "horizontal",
|
|
591
|
-
},
|
|
592
|
-
};
|
|
593
|
-
if (customAdPlatformInfo.canAutoRefresh) {
|
|
594
|
-
customAdParam.adIntervals = customAdPlatformInfo.refreshInterval;
|
|
595
|
-
}
|
|
596
|
-
let customAd = window["qg"].createGameBannerAd(customAdParam);
|
|
597
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "qg.createGameBannerAd() " + (customAd !== null ? "success" : "fail"));
|
|
598
|
-
LogUtils.Instance.log("", customAd);
|
|
599
|
-
if (!customAd) {
|
|
600
|
-
return false;
|
|
601
|
-
}
|
|
602
|
-
let oppoCustomAd = new OppoCustomAd(adUnitId, customAd, isFirstLoad);
|
|
603
|
-
this.oppoCustomAds.push(oppoCustomAd);
|
|
604
|
-
oppoCustomAd.errorListener = (err) => {
|
|
605
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoCustomAd.ad.onError()");
|
|
606
|
-
if (err) {
|
|
607
|
-
LogUtils.Instance.log("", err);
|
|
608
|
-
}
|
|
609
|
-
if (!oppoCustomAd.isRecreating) {
|
|
610
|
-
oppoCustomAd.isRecreating = true;
|
|
611
|
-
this.scheduleOnce(() => {
|
|
612
|
-
oppoCustomAd.isRecreating = false;
|
|
613
|
-
this.createCustomAd(adUnitId);
|
|
614
|
-
}, 15);
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
oppoCustomAd.ad.onError(oppoCustomAd.errorListener);
|
|
618
|
-
oppoCustomAd.loadListener = () => {
|
|
619
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoCustomAd.ad.onLoad()");
|
|
620
|
-
if (oppoCustomAd.isFirstLoad) {
|
|
621
|
-
oppoCustomAd.isFirstLoad = false;
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
oppoCustomAd.ad.onLoad(oppoCustomAd.loadListener);
|
|
625
|
-
if (!customAdPlatformInfo.canAutoRefresh) {
|
|
626
|
-
if (!oppoCustomAd.isRecreating) {
|
|
627
|
-
oppoCustomAd.isRecreating = true;
|
|
628
|
-
this.scheduleOnce(() => {
|
|
629
|
-
oppoCustomAd.isRecreating = false;
|
|
630
|
-
this.createCustomAd(adUnitId);
|
|
631
|
-
}, customAdPlatformInfo.refreshInterval);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
if (this.adMgr.isPermanentAdShowing()) {
|
|
635
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoCustomAd.ad.show()");
|
|
636
|
-
oppoCustomAd.ad.show()
|
|
637
|
-
.then(() => {
|
|
638
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoCustomAd.ad.show() success");
|
|
639
|
-
}).catch((err) => {
|
|
640
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoCustomAd.ad.show() fail");
|
|
641
|
-
if (err) {
|
|
642
|
-
LogUtils.Instance.log("", err);
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
return true;
|
|
647
|
-
}
|
|
648
|
-
destroyCustomAd(adUnitId) {
|
|
649
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "destroyCustomAd(): adUnitId=" + adUnitId);
|
|
650
|
-
let index = -1;
|
|
651
|
-
for (let i = 0; i < this.oppoCustomAds.length; i++) {
|
|
652
|
-
if (this.oppoCustomAds[i].unitId === adUnitId) {
|
|
653
|
-
index = i;
|
|
654
|
-
break;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
if (index >= 0) {
|
|
658
|
-
this.oppoCustomAds[index].destroy();
|
|
659
|
-
this.oppoCustomAds.splice(index, 1);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
showCustomAd(adUnitId) {
|
|
663
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "showCustomAd(): adUnitId=" + adUnitId);
|
|
664
|
-
for (let i = 0; i < this.oppoCustomAds.length; i++) {
|
|
665
|
-
if (this.oppoCustomAds[i].unitId === adUnitId) {
|
|
666
|
-
this.oppoCustomAds[i].ad.show();
|
|
667
|
-
break;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
hideCustomAd(adUnitId) {
|
|
672
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "hideCustomAd(): adUnitId=" + adUnitId);
|
|
673
|
-
for (let i = 0; i < this.oppoCustomAds.length; i++) {
|
|
674
|
-
if (this.oppoCustomAds[i].unitId === adUnitId) {
|
|
675
|
-
this.oppoCustomAds[i].ad.hide();
|
|
676
|
-
break;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
createPortalAd(adUnitId) {
|
|
681
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "createPortalAd()");
|
|
682
|
-
this.destroyPortalAd(adUnitId);
|
|
683
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "createPortalAd() adUnitId=" + adUnitId);
|
|
684
|
-
let portalAdPlatformInfo = AdDefinition.PortalAdStyleConfig.get(PlatformID.ID_QuickGame_Oppo);
|
|
685
|
-
if (portalAdPlatformInfo === null) {
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
let portalAdParam = {
|
|
689
|
-
adUnitId: adUnitId,
|
|
690
|
-
};
|
|
691
|
-
let portalAd = window["qg"].createGamePortalAd(portalAdParam);
|
|
692
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "qg.createGamePortalAd() " + (portalAd !== null ? "success" : "fail"));
|
|
693
|
-
LogUtils.Instance.log("", portalAd);
|
|
694
|
-
if (!portalAd) {
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
let oppoPortalAd = new OppoPortalAd(adUnitId, portalAd);
|
|
698
|
-
this.oppoPortalAds.push(oppoPortalAd);
|
|
699
|
-
oppoPortalAd.errorListener = (err) => {
|
|
700
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoPortalAd.ad.onError()");
|
|
701
|
-
if (err) {
|
|
702
|
-
LogUtils.Instance.log("", err);
|
|
703
|
-
}
|
|
704
|
-
if (!oppoPortalAd.isRecreating) {
|
|
705
|
-
oppoPortalAd.isRecreating = true;
|
|
706
|
-
this.scheduleOnce(() => {
|
|
707
|
-
oppoPortalAd.isRecreating = false;
|
|
708
|
-
this.createPortalAd(adUnitId);
|
|
709
|
-
}, 15);
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
oppoPortalAd.ad.onError(oppoPortalAd.errorListener);
|
|
713
|
-
oppoPortalAd.loadListener = () => {
|
|
714
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoPortalAd.ad.onLoad()");
|
|
715
|
-
oppoPortalAd.isLoaded = true;
|
|
716
|
-
};
|
|
717
|
-
oppoPortalAd.ad.onLoad(oppoPortalAd.loadListener);
|
|
718
|
-
oppoPortalAd.showListener = () => {
|
|
719
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoPortalAd.ad.onShow()");
|
|
720
|
-
oppoPortalAd.isShowing = true;
|
|
721
|
-
};
|
|
722
|
-
oppoPortalAd.ad.onShow(oppoPortalAd.showListener);
|
|
723
|
-
oppoPortalAd.closeListener = () => {
|
|
724
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "oppoPortalAd.ad.onClose()");
|
|
725
|
-
oppoPortalAd.ad.load();
|
|
726
|
-
};
|
|
727
|
-
oppoPortalAd.ad.onClose(oppoPortalAd.closeListener);
|
|
728
|
-
}
|
|
729
|
-
destroyPortalAd(adUnitId) {
|
|
730
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "destroyPortalAd(): adUnitId=" + adUnitId);
|
|
731
|
-
let index = -1;
|
|
732
|
-
for (let i = 0; i < this.oppoPortalAds.length; i++) {
|
|
733
|
-
if (this.oppoPortalAds[i].unitId === adUnitId) {
|
|
734
|
-
index = i;
|
|
735
|
-
break;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
if (index >= 0) {
|
|
739
|
-
this.oppoPortalAds[index].destroy();
|
|
740
|
-
this.oppoPortalAds.splice(index, 1);
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
showPortalAd(adUnitId) {
|
|
744
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "showPortalAd(): adUnitId=" + adUnitId);
|
|
745
|
-
for (let i = 0; i < this.oppoPortalAds.length; i++) {
|
|
746
|
-
if (this.oppoPortalAds[i].unitId === adUnitId) {
|
|
747
|
-
let portalAd = this.oppoPortalAds[i];
|
|
748
|
-
if (portalAd.isLoaded) {
|
|
749
|
-
portalAd.isLoaded = false;
|
|
750
|
-
portalAd.ad.show();
|
|
751
|
-
}
|
|
752
|
-
break;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
hidePortalAd(adUnitId) {
|
|
757
|
-
LogUtils.Instance.log(AdAdapterOppo.TAG, "hidePortalAd(): adUnitId=" + adUnitId);
|
|
758
|
-
for (let i = 0; i < this.oppoPortalAds.length; i++) {
|
|
759
|
-
if (this.oppoPortalAds[i].unitId === adUnitId) {
|
|
760
|
-
let portalAd = this.oppoPortalAds[i];
|
|
761
|
-
if (portalAd.isShowing) {
|
|
762
|
-
portalAd.isShowing = false;
|
|
763
|
-
portalAd.ad.hide();
|
|
764
|
-
}
|
|
765
|
-
break;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
AdAdapterOppo.TAG = "AdAdapterOppo";
|