|
@@ -54,9 +54,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
|
|
|
import static com.sheep.gamegroup.view.activity.helper.AdHelper.*;
|
|
import static com.sheep.gamegroup.view.activity.helper.AdHelper.*;
|
|
|
-import static com.tencent.klevin.base.okhttp.ErrorCode.KLSplashAdEvent_AdPlayCompletion;
|
|
|
|
|
-import static com.tencent.klevin.base.okhttp.ErrorCode.KLSplashAdEvent_AdShowFinish;
|
|
|
|
|
-import static com.tencent.klevin.base.okhttp.ErrorCode.KLSplashAdEvent_AdSkip;
|
|
|
|
|
|
|
+import static com.tencent.klevin.base.okhttp.ErrorCode.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Created by ljy on 2018/3/9.
|
|
* Created by ljy on 2018/3/9.
|
|
@@ -128,14 +126,14 @@ public class SplashAct extends BaseActivity {
|
|
|
boolean isNewSmallSheep = baseMessage.getData(Boolean.class);
|
|
boolean isNewSmallSheep = baseMessage.getData(Boolean.class);
|
|
|
DataUtil.getInstance().setIsNewSmallSheep(isNewSmallSheep);
|
|
DataUtil.getInstance().setIsNewSmallSheep(isNewSmallSheep);
|
|
|
if (SysAppUtil.isNewSmallSheep()) {//新版本只显示引导页面,不展示弹窗和开屏广告
|
|
if (SysAppUtil.isNewSmallSheep()) {//新版本只显示引导页面,不展示弹窗和开屏广告
|
|
|
- fetchAdvertisement(false);//只更新,不加载,下次加载上次的数据
|
|
|
|
|
|
|
+ fetchAdvertisement();//只更新,不加载,下次加载上次的数据
|
|
|
sendHandlerMessages(2000);
|
|
sendHandlerMessages(2000);
|
|
|
} else {
|
|
} else {
|
|
|
ad = DDProviderHelper.getInstance().getSheepAd(SheepAd.FORM_SPLASH);
|
|
ad = DDProviderHelper.getInstance().getSheepAd(SheepAd.FORM_SPLASH);
|
|
|
if (ad != null) {
|
|
if (ad != null) {
|
|
|
if (ad.getAd_type() == AD_TYPE_SHEEP) {
|
|
if (ad.getAd_type() == AD_TYPE_SHEEP) {
|
|
|
- //有自己的广告,展示自己的广告
|
|
|
|
|
- loadAdvertising();
|
|
|
|
|
|
|
+ //是自己的广告,展示自己的广告
|
|
|
|
|
+ loadSheepAdvertising();
|
|
|
} else {
|
|
} else {
|
|
|
//SDK的广告,展示SDK的广告,并拉取一次广告并保存
|
|
//SDK的广告,展示SDK的广告,并拉取一次广告并保存
|
|
|
initSdkAdvertising(ad.getAd_type());
|
|
initSdkAdvertising(ad.getAd_type());
|
|
@@ -144,7 +142,7 @@ public class SplashAct extends BaseActivity {
|
|
|
sendHandlerMessages(2000);
|
|
sendHandlerMessages(2000);
|
|
|
}
|
|
}
|
|
|
//拉一次广告,不加载,下次打开APP加载上次拉的数据
|
|
//拉一次广告,不加载,下次打开APP加载上次拉的数据
|
|
|
- fetchAdvertisement(false);
|
|
|
|
|
|
|
+ fetchAdvertisement();
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
.subscribe();
|
|
.subscribe();
|
|
@@ -156,103 +154,71 @@ public class SplashAct extends BaseActivity {
|
|
|
private void initSdkAdvertising(int adType) {
|
|
private void initSdkAdvertising(int adType) {
|
|
|
if (adType == AD_SPLASH_TYPE_YKY) {
|
|
if (adType == AD_SPLASH_TYPE_YKY) {
|
|
|
//游可盈
|
|
//游可盈
|
|
|
- initYKYAd();
|
|
|
|
|
|
|
+ launchYKYSplash();
|
|
|
} else if (adType == AD_SPLASH_TYPE_YT) {
|
|
} else if (adType == AD_SPLASH_TYPE_YT) {
|
|
|
//优投
|
|
//优投
|
|
|
- initYTAd();
|
|
|
|
|
|
|
+ launchYTSplash();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //加载游可盈广告
|
|
|
|
|
- private void initYKYAd() {
|
|
|
|
|
- //游可盈广告初始化
|
|
|
|
|
- KleinManager.getInstance().initKleinAdSDK(this,
|
|
|
|
|
- "{\"app_id\":" + Integer.parseInt(ad.getThird_app_id()) + ",\"app_bundle\":\"abc.kfzs.com\",\"app_version\":\"6.3.1\",\"is_debug\":" + BuildConfig.DEBUG + "}",
|
|
|
|
|
- new KleinResponseCallback() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onSuccess(int code) {
|
|
|
|
|
- if (BuildConfig.DEBUG)
|
|
|
|
|
- G.showToast("游可赢广告初始化:init onSuccess : " + code);
|
|
|
|
|
- //code:KLAdEvent_InitSuccess = 800; // 宿主初始化成功
|
|
|
|
|
- String data = "{\"placements\":[{\"pos_id\":" + ad.getThird_ad_id() + ",\"ad_count\":1}]}";
|
|
|
|
|
- //"{\"placements\":[{\"pos_id\":" + posId + ",\"ad_count\":1}]}";
|
|
|
|
|
- KleinManager.getInstance().prepareAD(
|
|
|
|
|
- getApplicationContext(),
|
|
|
|
|
- data,
|
|
|
|
|
- 5000,
|
|
|
|
|
- true,
|
|
|
|
|
- new KleinResponseCallback() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onSuccess(int i) {
|
|
|
|
|
- if (BuildConfig.DEBUG)
|
|
|
|
|
- Log.d("!!!!!Success", String.valueOf(i));
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onFail(int i) {
|
|
|
|
|
- if (BuildConfig.DEBUG)
|
|
|
|
|
- Log.d("!!!!!Fail", String.valueOf(i));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onEvent(int i) {
|
|
|
|
|
- if (BuildConfig.DEBUG)
|
|
|
|
|
- Log.d("!!!!!Event", String.valueOf(i));
|
|
|
|
|
- switch (i) {
|
|
|
|
|
- case KLSplashAdEvent_AdPlayCompletion:
|
|
|
|
|
- case KLSplashAdEvent_AdShowFinish:
|
|
|
|
|
- case KLSplashAdEvent_AdSkip:
|
|
|
|
|
- sendHandlerMessages(0);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ //展示游可盈广告
|
|
|
|
|
+ private void launchYKYSplash(){
|
|
|
|
|
+ String data = "{\"placements\":[{\"pos_id\":" + ad.getThird_ad_id() + ",\"ad_count\":1}]}";
|
|
|
|
|
+ //"{\"placements\":[{\"pos_id\":" + posId + ",\"ad_count\":1}]}";
|
|
|
|
|
+ KleinManager.getInstance().prepareAD(
|
|
|
|
|
+ getApplicationContext(),
|
|
|
|
|
+ data,
|
|
|
|
|
+ 5000,
|
|
|
|
|
+ true,
|
|
|
|
|
+ new KleinResponseCallback() {
|
|
|
@Override
|
|
@Override
|
|
|
- public void onFail(int code) {
|
|
|
|
|
|
|
+ public void onSuccess(int i) {
|
|
|
if (BuildConfig.DEBUG)
|
|
if (BuildConfig.DEBUG)
|
|
|
- G.showToast("游可赢广告初始化:init onFail : " + code);
|
|
|
|
|
- //code:KLAdEvent_InitError = 801; // 宿主初始化错误
|
|
|
|
|
|
|
+ Log.d("!!!!!Success", String.valueOf(i));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void onEvent(int code) {
|
|
|
|
|
- // 初始化不会回调
|
|
|
|
|
|
|
+ public void onFail(int i) {
|
|
|
if (BuildConfig.DEBUG)
|
|
if (BuildConfig.DEBUG)
|
|
|
- G.showToast("游可赢广告事件:init onSuccess : " + code);
|
|
|
|
|
|
|
+ Log.d("!!!!!Fail", String.valueOf(i));
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- //加载优投广告
|
|
|
|
|
- private void initYTAd() {
|
|
|
|
|
- JasmineEngine.getInstance(this).init(
|
|
|
|
|
- ad.getThird_app_id(),
|
|
|
|
|
- Integer.parseInt(ad.getThird_ad_id()),
|
|
|
|
|
- new JasmineEngine.InitCallBack() {
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void initSuccess() {
|
|
|
|
|
- LogUtils2.info("initSuccess");
|
|
|
|
|
- launchYTSplash();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void initFailed(String err) {
|
|
|
|
|
- LogUtils2.info("initFailed:" + err);
|
|
|
|
|
|
|
+ public void onEvent(int i) {
|
|
|
|
|
+ if (BuildConfig.DEBUG)
|
|
|
|
|
+ Log.d("!!!!!Event", String.valueOf(i));
|
|
|
|
|
+ switch (i) {
|
|
|
|
|
+ case KLSplashAdEvent_AdShowSucc:
|
|
|
|
|
+ if (!aded) {
|
|
|
|
|
+ AdHelper.stat(ad.getAd_id(), 1, ad.getAd_type());
|
|
|
|
|
+ aded = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case KLSplashAdEvent_AdTap:
|
|
|
|
|
+ AdHelper.stat(ad.getAd_id(), 2, ad.getAd_type());
|
|
|
|
|
+ break;
|
|
|
|
|
+ case KLSplashAdEvent_AdPlayCompletion:
|
|
|
|
|
+ case KLSplashAdEvent_AdShowFinish:
|
|
|
|
|
+ case KLSplashAdEvent_AdSkip:
|
|
|
|
|
+ sendHandlerMessages(0);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//展示优投开屏广告(新增boolean state:false----定值) 重要 mForceGoMain跳转主页 请参照此方法调用,否则可能导致广告展示链路断开 导致收益下降!!!
|
|
//展示优投开屏广告(新增boolean state:false----定值) 重要 mForceGoMain跳转主页 请参照此方法调用,否则可能导致广告展示链路断开 导致收益下降!!!
|
|
|
private void launchYTSplash() {
|
|
private void launchYTSplash() {
|
|
|
flSplashYT.setVisibility(View.VISIBLE);
|
|
flSplashYT.setVisibility(View.VISIBLE);
|
|
|
- new SplashEngine(SplashAct.this,false, new SplashEngine.SplashAdCallBack() {
|
|
|
|
|
|
|
+ new SplashEngine(SplashAct.this, false, new SplashEngine.SplashAdCallBack() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onSplashClick() {
|
|
public void onSplashClick() {
|
|
|
Log.i("jasmine-ad", "点击广告");
|
|
Log.i("jasmine-ad", "点击广告");
|
|
|
|
|
+ AdHelper.stat(ad.getAd_id(), 2, ad.getAd_type());
|
|
|
|
|
+ sendHandlerMessages(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -270,6 +236,10 @@ public class SplashAct extends BaseActivity {
|
|
|
@Override
|
|
@Override
|
|
|
public void onSplashShow() {
|
|
public void onSplashShow() {
|
|
|
Log.i("jasmine-ad", "展示广告");
|
|
Log.i("jasmine-ad", "展示广告");
|
|
|
|
|
+ if (!aded) {
|
|
|
|
|
+ AdHelper.stat(ad.getAd_id(), 1, ad.getAd_type());
|
|
|
|
|
+ aded = true;
|
|
|
|
|
+ }
|
|
|
//mHasLoaded = true;
|
|
//mHasLoaded = true;
|
|
|
mHandler.removeCallbacksAndMessages(null);
|
|
mHandler.removeCallbacksAndMessages(null);
|
|
|
}
|
|
}
|
|
@@ -291,28 +261,21 @@ public class SplashAct extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
|
|
|
//从服务端拉取广告信息
|
|
//从服务端拉取广告信息
|
|
|
- private void fetchAdvertisement(boolean shouldLoad) {
|
|
|
|
|
|
|
+ private void fetchAdvertisement() {
|
|
|
CommonUtil.getInstance().refreshAds((ret, list) -> {
|
|
CommonUtil.getInstance().refreshAds((ret, list) -> {
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- if (shouldLoad) {
|
|
|
|
|
- ad = DDProviderHelper.getInstance().getSheepAd(SheepAd.FORM_SPLASH);
|
|
|
|
|
- loadAdvertising();
|
|
|
|
|
- if (ad == null) sendHandlerMessages(2000);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- if (shouldLoad) sendHandlerMessages(2000);
|
|
|
|
|
|
|
+ ad = DDProviderHelper.getInstance().getSheepAd(SheepAd.FORM_SPLASH);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //加载广告
|
|
|
|
|
- private void loadAdvertising() {
|
|
|
|
|
|
|
+ //加载自己的广告
|
|
|
|
|
+ private void loadSheepAdvertising() {
|
|
|
if (this.isDestroyed()) return;
|
|
if (this.isDestroyed()) return;
|
|
|
if (!aded) {
|
|
if (!aded) {
|
|
|
AdHelper.stat(ad.getAd_id(), 1);
|
|
AdHelper.stat(ad.getAd_id(), 1);
|
|
|
aded = true;
|
|
aded = true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
if (ad.isImage()) {
|
|
if (ad.isImage()) {
|
|
|
Glide.with(this).load(ad.getAd_img()).into(splash_image_view);
|
|
Glide.with(this).load(ad.getAd_img()).into(splash_image_view);
|
|
|
ViewUtil.setVisibility(splash_video_view, View.GONE);
|
|
ViewUtil.setVisibility(splash_video_view, View.GONE);
|