Commit 60de44cc authored by mengcuiguang2's avatar mengcuiguang2

Merge branch 'dev_ad' into dev_xiaoman

parents 881070da a28b8294
...@@ -15,8 +15,8 @@ android { ...@@ -15,8 +15,8 @@ android {
applicationId "com.mints.goodmoney" applicationId "com.mints.goodmoney"
minSdkVersion rootProject.ext.androidMinSdkVersion minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 33 versionCode 35
versionName "1.3.3" versionName "1.3.5"
flavorDimensions "default" flavorDimensions "default"
// dex突破65535的限制 // dex突破65535的限制
......
...@@ -258,6 +258,9 @@ ...@@ -258,6 +258,9 @@
<activity <activity
android:name=".ui.activitys.ShaiziActivity" android:name=".ui.activitys.ShaiziActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.SplashGroMoreBackgroundActivity"
android:screenOrientation="portrait" />
<service <service
android:name=".service.UpdateService" android:name=".service.UpdateService"
......
...@@ -142,6 +142,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback { ...@@ -142,6 +142,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
vo["ecpm"] = ttNativeAd.preEcpm vo["ecpm"] = ttNativeAd.preEcpm
vo["adSource"] = ttNativeAd.adNetworkPlatformId vo["adSource"] = ttNativeAd.adNetworkPlatformId
vo["adType"] = Constant.GRO_MORE_ADTYPE1 vo["adType"] = Constant.GRO_MORE_ADTYPE1
vo["adid"] =CsjGroMoreManager.AD_UNIT_EXPRESS_ID
TrackManager.getInstance().cmtGroMoreInfo(vo) TrackManager.getInstance().cmtGroMoreInfo(vo)
} }
} }
......
...@@ -138,6 +138,7 @@ class GroMoreExpressManager : TTSettingConfigCallback { ...@@ -138,6 +138,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
vo["ecpm"] = ttNativeAd.getPreEcpm() vo["ecpm"] = ttNativeAd.getPreEcpm()
vo["adSource"] = ttNativeAd.getAdNetworkPlatformId() vo["adSource"] = ttNativeAd.getAdNetworkPlatformId()
vo["adType"] = Constant.GRO_MORE_ADTYPE1 vo["adType"] = Constant.GRO_MORE_ADTYPE1
vo["adid"] =CsjGroMoreManager.AD_UNIT_EXPRESS_ID
TrackManager.getInstance().cmtGroMoreInfo(vo) TrackManager.getInstance().cmtGroMoreInfo(vo)
// sAdFrameLayout.addView(createAdView(ads[0])) // sAdFrameLayout.addView(createAdView(ads[0]))
} }
......
...@@ -47,6 +47,7 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd { ...@@ -47,6 +47,7 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
private int curCoin; private int curCoin;
private String extraId; private String extraId;
private String carrierType; private String carrierType;
private String appSetId;
private VideoAdStatusListener videoAdStatusListener; private VideoAdStatusListener videoAdStatusListener;
private TTRewardAd mttRewardAd; private TTRewardAd mttRewardAd;
...@@ -94,11 +95,13 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd { ...@@ -94,11 +95,13 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
this.curCoin = curCoin; this.curCoin = curCoin;
this.extraId = extraId; this.extraId = extraId;
this.carrierType = carrierType; this.carrierType = carrierType;
appSetId = MD5.GetMD5Code(System.currentTimeMillis() + UserManager.getInstance().getUserID());
/** /**
* 判断当前是否存在config 配置 ,如果存在直接加载广告 ,如果不存在则注册config加载回调 * 判断当前是否存在config 配置 ,如果存在直接加载广告 ,如果不存在则注册config加载回调
*/ */
if (TTMediationAdSdk.configLoadSuccess()) { if (TTMediationAdSdk.configLoadSuccess()) {
loadAd(CsjGroMoreManager.AD_UNIT_VIDEO_ID, TTAdConstant.VERTICAL); loadAd(CsjGroMoreManager.INSTANCE.getAD_UNIT_VIDEO_ID(), TTAdConstant.VERTICAL);
} else { } else {
TTMediationAdSdk.registerConfigCallback(mSettingConfigCallback); //不用使用内部类,否则在ondestory中无法移除该回调 TTMediationAdSdk.registerConfigCallback(mSettingConfigCallback); //不用使用内部类,否则在ondestory中无法移除该回调
} }
...@@ -110,7 +113,7 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd { ...@@ -110,7 +113,7 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
private TTSettingConfigCallback mSettingConfigCallback = new TTSettingConfigCallback() { private TTSettingConfigCallback mSettingConfigCallback = new TTSettingConfigCallback() {
@Override @Override
public void configLoad() { public void configLoad() {
loadAd(CsjGroMoreManager.AD_UNIT_VIDEO_ID, TTAdConstant.VERTICAL); loadAd(CsjGroMoreManager.INSTANCE.getAD_UNIT_VIDEO_ID(), TTAdConstant.VERTICAL);
} }
}; };
...@@ -203,6 +206,10 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd { ...@@ -203,6 +206,10 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
public void onRewardClick() { public void onRewardClick() {
LogUtil.d(TAG, "onRewardClick"); LogUtil.d(TAG, "onRewardClick");
HashMap<String, Object> vo = new HashMap<>();
vo.put("appSetId", appSetId);
TrackManager.getInstance().reportGromoreAdClick(vo);
if (AppConfig.needReportClickAdEvent) { if (AppConfig.needReportClickAdEvent) {
TrackManager.getInstance().reportClickAdEvent(); TrackManager.getInstance().reportClickAdEvent();
} }
...@@ -266,6 +273,8 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd { ...@@ -266,6 +273,8 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
vo.put("ecpm", mttRewardAd.getPreEcpm()); vo.put("ecpm", mttRewardAd.getPreEcpm());
vo.put("adSource", mttRewardAd.getAdNetworkPlatformId()); vo.put("adSource", mttRewardAd.getAdNetworkPlatformId());
vo.put("adType", Constant.GRO_MORE_ADTYPE2); vo.put("adType", Constant.GRO_MORE_ADTYPE2);
vo.put("adid", CsjGroMoreManager.INSTANCE.getAD_UNIT_VIDEO_ID());
vo.put("appSetId", appSetId);
TrackManager.getInstance().cmtGroMoreInfo(vo); TrackManager.getInstance().cmtGroMoreInfo(vo);
} }
......
package com.mints.goodmoney.manager package com.mints.goodmoney.manager
import com.mints.goodmoney.mvp.model.AdcodeBean import com.mints.goodmoney.mvp.model.AdcodeBean
import com.mints.goodmoney.mvp.model.UserMsgBean
/** /**
* 渠道管理 * 渠道管理
......
package com.mints.goodmoney.manager package com.mints.goodmoney.manager
import android.text.TextUtils
import com.mints.goodmoney.MintsApplication import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.mvp.model.AdcodeBean
import com.mints.goodmoney.mvp.model.GroAdcodeBean
/**
* 穿山甲GroMore
*/
object CsjGroMoreManager { object CsjGroMoreManager {
const val AD_UNIT_EXPRESS_ID = "946167770" var AD_UNIT_EXPRESS_ID = "946167770" // 信息流
const val AD_UNIT_SPLASH_ID = "887459392" var AD_UNIT_SPLASH_ID = "887459392" // 开屏
const val AD_UNIT_VIDEO_ID = "946018378" var AD_UNIT_VIDEO_ID = "946018378" // 激励视频
fun init(application: MintsApplication) { fun init(application: MintsApplication) {
TTGroMoreAdManagerHolder.init(application) TTGroMoreAdManagerHolder.init(application)
} }
/**
* 更新代码位
*/
fun updataIdByChannel(idBean: GroAdcodeBean?) {
// 渠道对象不为空
if (idBean != null) {
if (!TextUtils.isEmpty(idBean.groExpress)) {
AD_UNIT_EXPRESS_ID = idBean.groExpress
}
if (!TextUtils.isEmpty(idBean.groSplash)) {
AD_UNIT_SPLASH_ID = idBean.groSplash
}
if (!TextUtils.isEmpty(idBean.groVideo)) {
AD_UNIT_VIDEO_ID = idBean.groVideo
}
}
}
} }
\ No newline at end of file
...@@ -155,4 +155,10 @@ public class TrackManager { ...@@ -155,4 +155,10 @@ public class TrackManager {
trackPresenter.cmtExceptionInfo(vo); trackPresenter.cmtExceptionInfo(vo);
} }
} }
public void reportGromoreAdClick(HashMap<String, Object> vo) {
if (trackPresenter != null && !TextUtils.isEmpty(UserManager.getInstance().getUserID())) {
trackPresenter.reportGromoreAdClick(vo);
}
}
} }
...@@ -21,6 +21,7 @@ public class TtCsjAdManager { ...@@ -21,6 +21,7 @@ public class TtCsjAdManager {
/*splash*/ /*splash*/
public static String TT_AD_SPLASH = "887441594";// 开屏 public static String TT_AD_SPLASH = "887441594";// 开屏
public static String TT_AD_GRO_SPLASH = "887486105";// gro兜底开屏
/*banner*/ /*banner*/
public static String TT_AD_BANNER_MY = "945661050";// 个人中心 public static String TT_AD_BANNER_MY = "945661050";// 个人中心
......
...@@ -14,13 +14,6 @@ public class AdcodeBean implements Serializable { ...@@ -14,13 +14,6 @@ public class AdcodeBean implements Serializable {
private String ylhv1;//开屏 private String ylhv1;//开屏
private String ylhv2;//激励 private String ylhv2;//激励
private String shareylhv1;
private String shareylhv2;
private String shareylhv3;
private String sharecsjv1;
private String sharecsjv2;
private String sharecsjv3;
private String key; private String key;
...@@ -48,30 +41,6 @@ public class AdcodeBean implements Serializable { ...@@ -48,30 +41,6 @@ public class AdcodeBean implements Serializable {
return ylhv2; return ylhv2;
} }
public String getShareylhv1() {
return shareylhv1;
}
public String getShareylhv2() {
return shareylhv2;
}
public String getShareylhv3() {
return shareylhv3;
}
public String getSharecsjv1() {
return sharecsjv1;
}
public String getSharecsjv2() {
return sharecsjv2;
}
public String getSharecsjv3() {
return sharecsjv3;
}
public String getKey() { public String getKey() {
return key; return key;
} }
......
package com.mints.goodmoney.mvp.model;
import java.io.Serializable;
/**
* 用户渠道对应代码位
*/
public class GroAdcodeBean implements Serializable {
private String groExpress;
private String groSplash;
private String groVideo;
public String getGroExpress() {
return groExpress;
}
public String getGroSplash() {
return groSplash;
}
public String getGroVideo() {
return groVideo;
}
}
...@@ -12,9 +12,12 @@ public class UserTaskMsgBean implements Serializable { ...@@ -12,9 +12,12 @@ public class UserTaskMsgBean implements Serializable {
private BlessingBigMsgBean blessingBigMsg; private BlessingBigMsgBean blessingBigMsg;
private UserRiskAppsBean userRiskApps; private UserRiskAppsBean userRiskApps;
private AdcodeBean adcode_v1 = null; private AdcodeBean adcode_v1 = null;
private GroAdcodeBean gromoreAdcodes = null;
private FlowAdRulesBean flowAdRules; private FlowAdRulesBean flowAdRules;
private HighRatePlanBean highRatePlan; private HighRatePlanBean highRatePlan;
private String ip; private String ip;
private String channel; private String channel;
...@@ -141,6 +144,10 @@ public class UserTaskMsgBean implements Serializable { ...@@ -141,6 +144,10 @@ public class UserTaskMsgBean implements Serializable {
return highRatePlan; return highRatePlan;
} }
public GroAdcodeBean getGromoreAdcodes() {
return gromoreAdcodes;
}
public void setHighRatePlan(HighRatePlanBean highRatePlan) { public void setHighRatePlan(HighRatePlanBean highRatePlan) {
this.highRatePlan = highRatePlan; this.highRatePlan = highRatePlan;
} }
......
...@@ -9,6 +9,7 @@ import com.mints.goodmoney.common.AppConfig; ...@@ -9,6 +9,7 @@ import com.mints.goodmoney.common.AppConfig;
import com.mints.goodmoney.common.Constant; import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.common.DeviceInfo; import com.mints.goodmoney.common.DeviceInfo;
import com.mints.goodmoney.manager.AppHttpManager; import com.mints.goodmoney.manager.AppHttpManager;
import com.mints.goodmoney.manager.CsjGroMoreManager;
import com.mints.goodmoney.manager.SimulatorManager; import com.mints.goodmoney.manager.SimulatorManager;
import com.mints.goodmoney.manager.UserWeight; import com.mints.goodmoney.manager.UserWeight;
import com.mints.goodmoney.mvp.model.BaseResponse; import com.mints.goodmoney.mvp.model.BaseResponse;
...@@ -334,6 +335,7 @@ public class TrackPresenter extends BaseTrackPresenter { ...@@ -334,6 +335,7 @@ public class TrackPresenter extends BaseTrackPresenter {
@Override @Override
public void onNext(BaseResponse<UserTaskMsgBean> baseResponse) { public void onNext(BaseResponse<UserTaskMsgBean> baseResponse) {
UserWeight.INSTANCE.initAdWeight(baseResponse.getData()); UserWeight.INSTANCE.initAdWeight(baseResponse.getData());
CsjGroMoreManager.INSTANCE.updataIdByChannel(baseResponse.getData().getGromoreAdcodes());
} }
}); });
} }
...@@ -438,4 +440,23 @@ public class TrackPresenter extends BaseTrackPresenter { ...@@ -438,4 +440,23 @@ public class TrackPresenter extends BaseTrackPresenter {
} }
}); });
} }
public void reportGromoreAdClick(HashMap<String, Object> vo) {
AppHttpManager.getInstance(loanApplication)
.call(loanService.reportGromoreAdClick(vo),
new BaseSubscriber<BaseResponse<Object>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(BaseResponse<Object> baseResponse) {
}
});
}
} }
...@@ -671,7 +671,13 @@ public interface LoanService { ...@@ -671,7 +671,13 @@ public interface LoanService {
@POST("api/reportError") @POST("api/reportError")
Observable<BaseResponse<Object>> reportError(@Body Map<String, Object> vo); Observable<BaseResponse<Object>> reportError(@Body Map<String, Object> vo);
/**
* groMore点击广告
*
* @return
*/
@POST("api/reporGromeClickWithAppSetId")
Observable<BaseResponse<Object>> reportGromoreAdClick(@Body Map<String, Object> vo);
/** /**
* 默认http工厂 * 默认http工厂
......
...@@ -84,7 +84,7 @@ public class SplashGroMoreActivity extends BaseActivity { ...@@ -84,7 +84,7 @@ public class SplashGroMoreActivity extends BaseActivity {
* 注:每次加载开屏广告的时候需要新建一个TTSplashAd,否则可能会出现广告填充问题 * 注:每次加载开屏广告的时候需要新建一个TTSplashAd,否则可能会出现广告填充问题
* ( 例如:mTTSplashAd = new TTSplashAd(this, mAdUnitId);) * ( 例如:mTTSplashAd = new TTSplashAd(this, mAdUnitId);)
*/ */
mTTSplashAd = new TTSplashAd(this, CsjGroMoreManager.AD_UNIT_SPLASH_ID); mTTSplashAd = new TTSplashAd(this, CsjGroMoreManager.INSTANCE.getAD_UNIT_SPLASH_ID());
mTTSplashAd.setTTAdSplashListener(mSplashAdListener); mTTSplashAd.setTTAdSplashListener(mSplashAdListener);
//step3:创建开屏广告请求参数AdSlot,具体参数含义参考文档 //step3:创建开屏广告请求参数AdSlot,具体参数含义参考文档
...@@ -95,9 +95,9 @@ public class SplashGroMoreActivity extends BaseActivity { ...@@ -95,9 +95,9 @@ public class SplashGroMoreActivity extends BaseActivity {
//自定义兜底方案 选择使用 //自定义兜底方案 选择使用
TTNetworkRequestInfo ttNetworkRequestInfo; TTNetworkRequestInfo ttNetworkRequestInfo;
//穿山甲兜底 //穿山甲兜底
// ttNetworkRequestInfo = new PangleNetworkRequestInfo(TtCsjAdManager.TT_AD_APPID, "887483103"); ttNetworkRequestInfo = new PangleNetworkRequestInfo(TtCsjAdManager.TT_AD_APPID, TtCsjAdManager.TT_AD_GRO_SPLASH);
//gdt兜底 //gdt兜底
ttNetworkRequestInfo = new GdtNetworkRequestInfo(YlhAdManager.YLH_AD_APPID, "2001697222975737"); // ttNetworkRequestInfo = new GdtNetworkRequestInfo(YlhAdManager.YLH_AD_APPID, "2001697222975737");
//ks兜底 //ks兜底
// ttNetworkRequestInfo = new KsNetworkRequestInfo("90009", "4000000042"); // ttNetworkRequestInfo = new KsNetworkRequestInfo("90009", "4000000042");
//百度兜底 //百度兜底
...@@ -106,6 +106,7 @@ public class SplashGroMoreActivity extends BaseActivity { ...@@ -106,6 +106,7 @@ public class SplashGroMoreActivity extends BaseActivity {
//step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理 //step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理
mTTSplashAd.loadAd(adSlot, ttNetworkRequestInfo, new TTSplashAdLoadCallback() { mTTSplashAd.loadAd(adSlot, ttNetworkRequestInfo, new TTSplashAdLoadCallback() {
// mTTSplashAd.loadAd(adSlot, new TTSplashAdLoadCallback() {
@Override @Override
public void onSplashAdLoadFail(AdError adError) { public void onSplashAdLoadFail(AdError adError) {
LogUtil.d(TAG, adError.message); LogUtil.d(TAG, adError.message);
...@@ -125,14 +126,13 @@ public class SplashGroMoreActivity extends BaseActivity { ...@@ -125,14 +126,13 @@ public class SplashGroMoreActivity extends BaseActivity {
// 获取本次waterfall加载中,加载失败的adn错误信息。 // 获取本次waterfall加载中,加载失败的adn错误信息。
if (mTTSplashAd != null) { HashMap<String, Object> vo = new HashMap<>();
HashMap<String, Object> vo = new HashMap<>(); vo.put("adcode", mTTSplashAd.getAdNetworkRitId());
vo.put("adcode",mTTSplashAd.getAdNetworkRitId()); vo.put("ecpm", mTTSplashAd.getPreEcpm());
vo.put("ecpm",mTTSplashAd.getPreEcpm()); vo.put("adSource", mTTSplashAd.getAdNetworkPlatformId());
vo.put("adSource",mTTSplashAd.getAdNetworkPlatformId()); vo.put("adType", Constant.GRO_MORE_ADTYPE0);
vo.put("adType",Constant.GRO_MORE_ADTYPE0); vo.put("adid", CsjGroMoreManager.INSTANCE.getAD_UNIT_SPLASH_ID());
TrackManager.getInstance().cmtGroMoreInfo(vo); TrackManager.getInstance().cmtGroMoreInfo(vo);
}
} }
Log.e(TAG, "load splash ad success "); Log.e(TAG, "load splash ad success ");
} }
......
package com.mints.goodmoney.ui.activitys;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.FrameLayout;
import com.bytedance.msdk.adapter.pangle.PangleNetworkRequestInfo;
import com.bytedance.msdk.api.AdError;
import com.bytedance.msdk.api.AdSlot;
import com.bytedance.msdk.api.NetworkPlatformConst;
import com.bytedance.msdk.api.TTNetworkRequestInfo;
import com.bytedance.msdk.api.splash.TTSplashAd;
import com.bytedance.msdk.api.splash.TTSplashAdListener;
import com.bytedance.msdk.api.splash.TTSplashAdLoadCallback;
import com.mints.goodmoney.R;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.CsjGroMoreManager;
import com.mints.goodmoney.manager.TrackManager;
import com.mints.goodmoney.manager.TtCsjAdManager;
import com.mints.goodmoney.ui.activitys.base.BaseActivity;
import com.mints.goodmoney.utils.LogUtil;
import java.util.HashMap;
/**
* GroMore开屏广告Activity示例
*/
public class SplashGroMoreBackgroundActivity extends BaseActivity {
private static final String TAG = "SplashGroMoreActivity";
private TTSplashAd mTTSplashAd;
private FrameLayout mSplashContainer;
//是否强制跳转到主页面
private boolean mForceGoMain;
//开屏广告加载超时时间,建议大于1000,这里为了冷启动第一次加载到广告并且展示,示例设置了2000ms
private static final int AD_TIME_OUT = 4000;
private static final int MSG_GO_MAIN = 1;
//开屏广告是否已经加载
private boolean mHasLoaded;
// 百度开屏广告点击跳转落地页后倒计时不暂停,即使在看落地页,倒计时结束后仍然会强制跳转,需要特殊处理:
// 检测到广告被点击,且走了activity的onPaused证明跳转到了落地页,这时候onAdDismiss回调中不进行跳转,而是在activity的onResume中跳转。
private boolean isBaiduSplashAd = false;
private boolean baiduSplashAdClicked = false;
private boolean onPaused = false;
@Override
protected int getContentViewLayoutID() {
return R.layout.activity_splash_gromore_back;
}
@Override
protected void initViewsAndEvents() {
try {
mSplashContainer = findViewById(R.id.splash_container);
//加载开屏广告
loadSplashAd();
} catch (Exception e) {
goToMainActivity();
}
}
/**
* 加载开屏广告
*/
private void loadSplashAd() {
/**
* 注:每次加载开屏广告的时候需要新建一个TTSplashAd,否则可能会出现广告填充问题
* ( 例如:mTTSplashAd = new TTSplashAd(this, mAdUnitId);)
*/
mTTSplashAd = new TTSplashAd(this, CsjGroMoreManager.INSTANCE.getAD_UNIT_SPLASH_ID());
mTTSplashAd.setTTAdSplashListener(mSplashAdListener);
//step3:创建开屏广告请求参数AdSlot,具体参数含义参考文档
AdSlot adSlot = new AdSlot.Builder()
.setImageAdSize(1080, 1920) // 既适用于原生类型,也适用于模版类型。
.build();
//自定义兜底方案 选择使用
TTNetworkRequestInfo ttNetworkRequestInfo;
//穿山甲兜底
ttNetworkRequestInfo = new PangleNetworkRequestInfo(TtCsjAdManager.TT_AD_APPID, TtCsjAdManager.TT_AD_GRO_SPLASH);
//gdt兜底
// ttNetworkRequestInfo = new GdtNetworkRequestInfo(YlhAdManager.YLH_AD_APPID, "2001697222975737");
//ks兜底
// ttNetworkRequestInfo = new KsNetworkRequestInfo("90009", "4000000042");
//百度兜底
// ttNetworkRequestInfo = new BaiduNetworkRequestInfo("e866cfb0", "2058622");
//step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理
mTTSplashAd.loadAd(adSlot, ttNetworkRequestInfo, new TTSplashAdLoadCallback() {
// mTTSplashAd.loadAd(adSlot, new TTSplashAdLoadCallback() {
@Override
public void onSplashAdLoadFail(AdError adError) {
LogUtil.d(TAG, adError.message);
mHasLoaded = true;
Log.e(TAG, "load splash ad error : " + adError.code + ", " + adError.message);
// 获取本次waterfall加载中,加载失败的adn错误信息。
if (mTTSplashAd != null)
LogUtil.d(TAG, "ad load infos: " + mTTSplashAd.getAdLoadInfoList());
goToMainActivity();
}
@Override
public void onSplashAdLoadSuccess() {
if (mTTSplashAd != null) {
mTTSplashAd.showAd(mSplashContainer);
isBaiduSplashAd = mTTSplashAd.getAdNetworkPlatformId() == NetworkPlatformConst.SDK_NAME_BAIDU;
// 获取本次waterfall加载中,加载失败的adn错误信息。
HashMap<String, Object> vo = new HashMap<>();
vo.put("adcode", mTTSplashAd.getAdNetworkRitId());
vo.put("ecpm", mTTSplashAd.getPreEcpm());
vo.put("adSource", mTTSplashAd.getAdNetworkPlatformId());
vo.put("adType", Constant.GRO_MORE_ADTYPE0);
vo.put("adid", CsjGroMoreManager.INSTANCE.getAD_UNIT_SPLASH_ID());
TrackManager.getInstance().cmtGroMoreInfo(vo);
}
Log.e(TAG, "load splash ad success ");
}
@Override
public void onAdLoadTimeout() {
mHasLoaded = true;
Log.i(TAG, "开屏广告加载超时.......");
// 获取本次waterfall加载中,加载失败的adn错误信息。
if (mTTSplashAd != null)
LogUtil.d(TAG, "ad load infos: " + mTTSplashAd.getAdLoadInfoList());
goToMainActivity();
}
}, AD_TIME_OUT);
}
TTSplashAdListener mSplashAdListener = new TTSplashAdListener() {
@Override
public void onAdClicked() {
baiduSplashAdClicked = true;
LogUtil.d(TAG, "onAdClicked");
}
@Override
public void onAdShow() {
LogUtil.d(TAG, "onAdShow");
}
@Override
public void onAdSkip() {
LogUtil.d(TAG, "onAdSkip");
goToMainActivity();
}
@Override
public void onAdDismiss() {
LogUtil.d(TAG, "onAdDismiss");
if (isBaiduSplashAd && onPaused && baiduSplashAdClicked) {
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要在onResume中跳转主页。
return;
}
goToMainActivity();
}
};
@Override
protected void onResume() {
//判断是否该跳转到主页面
if (mForceGoMain) {
goToMainActivity();
}
if (isBaiduSplashAd && onPaused && baiduSplashAdClicked) {
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要自己在onResume中跳转主页。
goToMainActivity();
}
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
onPaused = true;
}
@Override
protected void onStop() {
super.onStop();
mForceGoMain = true;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mTTSplashAd != null) {
mTTSplashAd.destroy();
}
}
@Override
protected boolean isApplyKitKatTranslucency() {
return false;
}
/**
* 跳转到主页面
*/
private void goToMainActivity() {
finish();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
}
return super.onKeyDown(keyCode, event);
}
}
...@@ -248,6 +248,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener { ...@@ -248,6 +248,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
AppConfig.user_channel_ad = data.adcode.key AppConfig.user_channel_ad = data.adcode.key
} }
ChannelManager.updataCodeIdForRegisterChannel(data.adcode) ChannelManager.updataCodeIdForRegisterChannel(data.adcode)
CsjGroMoreManager.updataIdByChannel(data.gromoreAdcodes)
// 新人福利 放到个人中心展示 防止首页红包转动异常 // 新人福利 放到个人中心展示 防止首页红包转动异常
......
...@@ -355,6 +355,7 @@ class MyFragment : BaseFragment(), ...@@ -355,6 +355,7 @@ class MyFragment : BaseFragment(),
AppConfig.user_channel_ad = data.adcode.key AppConfig.user_channel_ad = data.adcode.key
} }
ChannelManager.updataCodeIdForRegisterChannel(data.adcode) ChannelManager.updataCodeIdForRegisterChannel(data.adcode)
CsjGroMoreManager.updataIdByChannel(data.gromoreAdcodes)
// 是否上报点击广告 // 是否上报点击广告
AppConfig.needReportClickAdEvent = data.isNeedReportClickAdEvent AppConfig.needReportClickAdEvent = data.isNeedReportClickAdEvent
......
package com.mints.goodmoney.ui.fragment
import android.Manifest
import android.os.Bundle
import android.text.TextUtils
import android.webkit.WebChromeClient
import com.component.dly.xzzq_ywsdk.YwSDK_WebActivity
import com.github.lzyzsd.jsbridge.CallBackFunction
import com.github.lzyzsd.jsbridge.DefaultHandler
import com.mints.goodmoney.BuildConfig
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.MokuManager
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.manager.YwhzManager
import com.mints.goodmoney.mvp.model.PanActionInfo
import com.mints.goodmoney.mvp.model.TurntableBean
import com.mints.goodmoney.mvp.presenters.PanPresenter
import com.mints.goodmoney.mvp.views.PanView
import com.mints.goodmoney.ui.activitys.*
import com.mints.goodmoney.ui.fragment.base.BaseFragment
import com.mints.library.utils.json.JsonUtil
import com.tbruyelle.rxpermissions.RxPermissions
import kotlinx.android.synthetic.main.fragment_main_pan.*
import net.grandcentrix.tray.AppPreferences
/**
* 描述:大转盘
* 作者:孟崔广
* 时间:2020/9/20 17:30
*/
class PanFragment : BaseFragment(), PanView {
private val panPresenter by lazy { PanPresenter() }
private val userManager by lazy { UserManager.getInstance() }
private val carrierType = Constant.CARRIER_CHALLENGE_TURN
private val ps by lazy { AppPreferences(context) }
override fun getContentViewLayoutID() = R.layout.fragment_main_pan
override fun initViewsAndEvents() {
panPresenter.attachView(this)
if (!TextUtils.isEmpty(userManager.userID)) {
// 登录成功的用户初始化鱼丸盒子
// if (userManager.userIsLogin()) {
// YwhzManager.init(baseApplication)
// }
if (!TextUtils.isEmpty(MintsApplication.OAID)) {
MokuManager.initOaid(MintsApplication.OAID)
}
}
}
override fun onHiddenChanged(hidden: Boolean) {
if (hidden) { // 不在最前端界面显示
onPause()
} else { // 重新显示到最前端中
onResume()
}
super.onHiddenChanged(hidden)
}
override fun onResume() {
super.onResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_THREE) {
if (TextUtils.isEmpty(userManager?.userID)) {
// 游客登录
panPresenter.userLogin()
} else {
loadTurnUrl()
}
}
}
override fun onDestroy() {
super.onDestroy()
panPresenter.detachView()
}
override fun loginSuc() {
loadTurnUrl()
}
/**
* 加载转盘url
*/
private fun loadTurnUrl() {
getTurnUrl()
// blTurntableWebview.setOnTouchListener { _, event -> event.action == MotionEvent.ACTION_MOVE }
blTurntableWebview.setDefaultHandler(DefaultHandler())
blTurntableWebview.webChromeClient = WebChromeClient()
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// blTurntableWebview.setOnScrollChangeListener(
// object : View.OnScrollChangeListener {
// override fun onScrollChange(v: View?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
// blTurntableWebview.scrollTo(0,scrollY)
// }
// })
// }
blTurntableWebview.setOnLongClickListener { true }
//注册监听方法当js中调用callHandler方法时会调用此方法(handlerName必须和js中相同)
blTurntableWebview.registerHandler("getTurnResult") { data, _ ->
val turntableBean: TurntableBean = JsonUtil.parseJson(data, TurntableBean::class.java)
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, turntableBean.coin)
bundle.putString(Constant.MAIN_CARRIER_TYPE, carrierType)
bundle.putString(Constant.MAIN_EXTRA_ID, turntableBean.key)
readyGo(AwardActivity::class.java, bundle)
androidCallJsReferse()
}
blTurntableWebview.registerHandler("actionPageForType") { data, _ ->
actionPageForType(data)
}
blTurntableWebview.setDefaultHandler(object : DefaultHandler() {
override fun handler(data: String, function: CallBackFunction) {
showToast(data)
}
})
}
private fun actionPageForType(data: String?) {
if (TextUtils.isEmpty(data)) return
val panActionInfo: PanActionInfo = JsonUtil.parseJson(data, PanActionInfo::class.java)
//0-微转,1-珊瑚下载,2-分红,3-鱼丸盒子,4-每日任务
when (panActionInfo.actionType) {
0 -> {
if (!userManager.userIsLogin()) {
readyGo(WxLoginActivity::class.java)
return
}
shareArticle(panActionInfo.coin)
}
1 -> {
if (!userManager.userIsLogin()) {
readyGo(WxLoginActivity::class.java)
return
}
readyGo(TaskCpdActivity::class.java)
}
2 -> {
if (!userManager.userIsLogin()) {
readyGo(WxLoginActivity::class.java)
return
}
val bundle = Bundle()
bundle.putInt(Constant.WRAPPER_TYPE, Constant.WRAPPER_TYPE_FRIENDS)
readyGo(WrapperActivity::class.java, bundle)
}
3 -> {
// if (!userManager.userIsLogin()) {
// readyGo(WxLoginActivity::class.java)
// return
// }
//
// try {
// activity?.let { YwSDK_WebActivity.open(it) }
// } catch (e: Exception) {
// e.printStackTrace()
// showToast("请重新退出账号登录")
// }
gotoMoku()
}
4 -> {
val activity: MainActivity? = activity as MainActivity?
activity?.let {
it.turnDayTask()
}
}
}
}
/**
* 获取转盘url
*/
private fun getTurnUrl() {
val tokenID = userManager.tokenID
val url: String = BuildConfig.MainIp + "turn/turnWithInner.html?carrierType=" + carrierType + "&token=" + tokenID
blTurntableWebview.loadUrl(url)
}
/**
* 奖励成功刷新js界面
*/
private fun androidCallJsReferse() {
// 调用js中的方法(必须和js中的handlerName想同)
blTurntableWebview.callHandler("refreshTurnTable", "") {
}
}
/**
* 分享文章
*/
private fun shareArticle(coin: Int) {
val bundle = Bundle()
bundle.putInt(Constant.WRAPPER_TYPE, Constant.WRAPPER_TYPE_WZ)
readyGo(WrapperActivity::class.java, bundle)
}
private fun gotoMoku() {
RxPermissions(requireActivity())
.request(Manifest.permission.READ_PHONE_STATE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe { granted: Boolean ->
if (granted) {
MokuManager.gotoMoku(requireContext())
if (ps.getBoolean(Constant.MOKU_FLAG_GUIDE, true)) {
readyGo(MokuGuideActivity::class.java)
ps.put(Constant.MOKU_FLAG_GUIDE, false)
}
} else {
showMissingPermissionDialog("设备,存储")
}
}
}
}
\ No newline at end of file
...@@ -123,7 +123,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick ...@@ -123,7 +123,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
turnTableView.setRotateListener(null)
turnTablePresenter.detachView() turnTablePresenter.detachView()
} }
...@@ -170,8 +169,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick ...@@ -170,8 +169,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
return return
} }
LogUtil.d("initTurnView", "initTurnView")
turnTableData = data turnTableData = data
if (data.configs.size == 0) { if (data.configs.size == 0) {
...@@ -236,11 +233,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick ...@@ -236,11 +233,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
override fun rotating(valueAnimator: ValueAnimator) {} override fun rotating(valueAnimator: ValueAnimator) {}
override fun rotateBefore(goImg: ImageView) { override fun rotateBefore(goImg: ImageView) {
if (!NetUtils.isNetworkConnected(context)) {
showToast("网络异常,请检测网络")
return
}
if (data.surplus <= 0) { if (data.surplus <= 0) {
showToast("抽奖次数已用完") showToast("抽奖次数已用完")
return return
......
...@@ -12,6 +12,7 @@ import com.mints.goodmoney.mvp.presenters.VersionUpdatePresenter; ...@@ -12,6 +12,7 @@ import com.mints.goodmoney.mvp.presenters.VersionUpdatePresenter;
import com.mints.goodmoney.ui.activitys.SplashADActivity; import com.mints.goodmoney.ui.activitys.SplashADActivity;
import com.mints.goodmoney.ui.activitys.SplashCsjADActivity; import com.mints.goodmoney.ui.activitys.SplashCsjADActivity;
import com.mints.goodmoney.ui.activitys.SplashGroMoreActivity; import com.mints.goodmoney.ui.activitys.SplashGroMoreActivity;
import com.mints.goodmoney.ui.activitys.SplashGroMoreBackgroundActivity;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
...@@ -106,11 +107,11 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall ...@@ -106,11 +107,11 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
if (count == 0) { if (count == 0) {
// LogUtil.d("ForegroundOrBackground", System.currentTimeMillis() - leaveTime + " onActivityStarted"); // LogUtil.d("ForegroundOrBackground", System.currentTimeMillis() - leaveTime + " onActivityStarted");
// 60秒后打开应用 显示开屏广告 // 60秒后打开应用 显示开屏广告
if (System.currentTimeMillis() - leaveTime >= 60000) { if (System.currentTimeMillis() - leaveTime >= 30000) {
// if (AppConfig.groMoreVideoAdCount > 0) { // if (AppConfig.groMoreVideoAdCount > 0) {
if (groIntent == null) { if (groIntent == null) {
groIntent = new Intent(activity, SplashGroMoreActivity.class); groIntent = new Intent(activity, SplashGroMoreBackgroundActivity.class);
} }
activity.startActivity(groIntent); activity.startActivity(groIntent);
// } else { // } else {
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<!-- 广点通开屏广告支持“半屏/全屏”展示,开发者可以把Logo区域放在屏幕底部,然后在Logo上方提供一个容器来放置半开屏广告,请注意此容器高度不得小于400dp -->
<!-- 1.Logo区域:展示半开屏广告时使用,如果想展示全开屏广告,可以不需要这个Logo区域 -->
<!-- 注意:如需要这个Logo区域,建议开发者使用自己的Logo资源,而不是联盟的Logo资源@drawable/gdt_splash_logo,资源规格可参照@drawable/gdt_splash_logo -->
<ImageView
android:id="@+id/app_logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:src="@drawable/splash_bg" />
<!-- 2.预设开屏图片区域: -->
<!-- 开发者可以把自家App设计开屏图片摆放在这里,本示例中放置了一张静态图片。!-->
<!-- 注意1:直接将此图放在广告容器的下面即可,始终不要将广告容器splash_container的设为invisible,否则将不会展示广告无法计费,返回错误码600。-->
<!-- 注意2:建议开发者使用自己的开屏图片资源,而不是联盟的@drawable/splash_holder,资源规格可参照@drawable/splash_holder -->
<!-- 3.开屏广告容器区域:-->
<!-- 注意:该区域高度不得小于400dp。在本示例中没有写死splash_container的高度值,是因为第1部分的app_logo区域是一个高度很小的图片。 -->
<FrameLayout
android:id="@+id/splash_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/app_logo" />
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment