Commit 38ed9a02 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 510351f4
......@@ -3,6 +3,7 @@ package com.mints.goodmoney.ad.express
import android.text.TextUtils
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import com.bumptech.glide.Glide
......@@ -10,14 +11,14 @@ import com.bytedance.msdk.api.*
import com.bytedance.msdk.api.nativeAd.*
import com.mints.goodmoney.MintsApplication
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.ui.widgets.seekbar.BubbleUtils
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.ToastUtil
import com.mints.goodmoney.utils.UIUtils
import com.mints.goodmoney.utils.VideoOptionUtil
import java.util.*
import android.view.View
private val TAG = GroMoreExpressManager::class.java.simpleName
......@@ -129,7 +130,13 @@ class GroMoreExpressManager : TTSettingConfigCallback {
if (ads.size > 0) {
mADLoadSuccessListener?.onGMAdLoadSuc(ads[0])
val ttNativeAd = ads[0]
val vo = HashMap<String, Any>()
vo["adcode"] = ttNativeAd.getAdNetworkRitId()
vo["ecpm"] = ttNativeAd.getPreEcpm()
vo["adSource"] = ttNativeAd.getAdNetworkPlatformId()
vo["adType"] = Constant.GRO_MORE_ADTYPE1
TrackManager.getInstance().cmtGroMoreInfo(vo)
// sAdFrameLayout.addView(createAdView(ads[0]))
}
}
......@@ -177,7 +184,6 @@ class GroMoreExpressManager : TTSettingConfigCallback {
return getVideoView(ad)
}
else -> {
ToastUtil.show(MintsApplication.getContext(), "图片展示样式错误")
return null
}
}
......@@ -203,12 +209,10 @@ class GroMoreExpressManager : TTSettingConfigCallback {
// if (ad.hasDislike()) {
// ad.setDislikeCallback(MintsApplication.getContext() as Activity?, object : TTDislikeCallback {
// override fun onSelected(position: Int, value: String) {
// ToastUtil.show(MintsApplication.getContext(), "点击 $value")
// //用户选择不喜欢原因后,移除广告展示
// }
//
// override fun onCancel() {
// ToastUtil.show(MintsApplication.getContext(), "dislike 点击了取消")
// LogUtil.d(TAG, "dislike 点击了取消")
// }
//
......@@ -224,16 +228,13 @@ class GroMoreExpressManager : TTSettingConfigCallback {
ad.setTTNativeAdListener(object : TTNativeExpressAdListener {
override fun onAdClick() {
LogUtil.d(TAG, "onAdClick")
ToastUtil.show(MintsApplication.getContext(), "模板广告被点击")
}
override fun onAdShow() {
LogUtil.d(TAG, "onAdShow")
ToastUtil.show(MintsApplication.getContext(), "模板广告show")
}
override fun onRenderFail(view: View, msg: String, code: Int) {
ToastUtil.show(MintsApplication.getContext(), "模板广告渲染失败code=$code,msg=$msg")
LogUtil.d(TAG, "onRenderFail code=$code,msg=$msg")
}
......@@ -241,7 +242,6 @@ class GroMoreExpressManager : TTSettingConfigCallback {
// 另外,不要直接使用参数view,而是通过ad.getExpressView()来获取广告view。
override fun onRenderSuccess(view: View, width: Float, height: Float) {
LogUtil.d(TAG, "onRenderSuccess")
ToastUtil.show(MintsApplication.getContext(), "模板广告渲染成功:width=$width,height=$height")
//回调渲染成功后将模板布局添加的父View中
if (adViewHolder.mAdContainerView != null) {
//获取视频播放view,该view SDK内部渲染,在媒体平台可配置视频是否自动播放等设置。
......@@ -270,27 +270,22 @@ class GroMoreExpressManager : TTSettingConfigCallback {
//视频广告设置播放状态回调(可选)
ad.setTTVideoListener(object : TTVideoListener {
override fun onVideoStart() {
ToastUtil.show(MintsApplication.getContext(), "模板广告视频开始播放")
LogUtil.d(TAG, "onVideoStart")
}
override fun onVideoPause() {
ToastUtil.show(MintsApplication.getContext(), "模板广告视频暂停")
LogUtil.d(TAG, "onVideoPause")
}
override fun onVideoResume() {
ToastUtil.show(MintsApplication.getContext(), "模板广告视频继续播放")
LogUtil.d(TAG, "onVideoResume")
}
override fun onVideoCompleted() {
ToastUtil.show(MintsApplication.getContext(), "模板播放完成")
LogUtil.d(TAG, "onVideoCompleted")
}
override fun onVideoError(adError: AdError) {
ToastUtil.show(MintsApplication.getContext(), "模板广告视频播放出错")
LogUtil.d(TAG, "onVideoError")
}
})
......@@ -366,27 +361,22 @@ class GroMoreExpressManager : TTSettingConfigCallback {
//视频广告设置播放状态回调(可选)
ad.setTTVideoListener(object : TTVideoListener {
override fun onVideoStart() {
ToastUtil.show(MintsApplication.getContext(), "广告视频开始播放")
LogUtil.d(TAG, "onVideoStart")
}
override fun onVideoPause() {
ToastUtil.show(MintsApplication.getContext(), "广告视频暂停")
LogUtil.d(TAG, "onVideoPause")
}
override fun onVideoResume() {
ToastUtil.show(MintsApplication.getContext(), "广告视频继续播放")
LogUtil.d(TAG, "onVideoResume")
}
override fun onVideoCompleted() {
ToastUtil.show(MintsApplication.getContext(), "广告播放完成")
LogUtil.d(TAG, "onVideoCompleted")
}
override fun onVideoError(adError: AdError) {
ToastUtil.show(MintsApplication.getContext(), "广告视频播放出错")
LogUtil.d(TAG, "onVideoError")
}
})
......@@ -577,7 +567,6 @@ class GroMoreExpressManager : TTSettingConfigCallback {
}
else -> {
adCreativeButton?.visibility = View.GONE
ToastUtil.show(MintsApplication.getContext(), "交互类型异常")
}
}
}
......@@ -622,12 +611,10 @@ class GroMoreExpressManager : TTSettingConfigCallback {
private var mTTNativeAdListener: TTNativeAdListener = object : TTNativeAdListener {
override fun onAdClick() {
LogUtil.d(TAG, "onAdClick")
ToastUtil.show(MintsApplication.getContext(), "自渲染广告被点击")
}
override fun onAdShow() {
LogUtil.d(TAG, "onAdShow")
ToastUtil.show(MintsApplication.getContext(), "广告展示")
}
}
......
package com.mints.goodmoney.ad.express
class TTPreGromoreExpressManager {
}
\ No newline at end of file
......@@ -52,7 +52,7 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
private Activity activity;
private String adUnitId="946018378"; //代码位
private String adUnitId = "946018378"; //代码位
private boolean isClickScreen = true; // 是否点击屏幕跳转广告
......@@ -126,10 +126,10 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
.setAdmobAppVolume(0f)//配合Admob的声音大小设置[0-1]
.build();
Map<String, String> customData = new HashMap<>();
customData.put(com.bytedance.msdk.api.AdSlot.CUSTOM_DATA_KEY_PANGLE, "pangle media_extra");
customData.put(com.bytedance.msdk.api.AdSlot.CUSTOM_DATA_KEY_GDT, "gdt custom data");
customData.put(com.bytedance.msdk.api.AdSlot.CUSTOM_DATA_KEY_KS, "ks custom data");
// Map<String, String> customData = new HashMap<>();
// customData.put(com.bytedance.msdk.api.AdSlot.CUSTOM_DATA_KEY_PANGLE, "pangle media_extra");
// customData.put(com.bytedance.msdk.api.AdSlot.CUSTOM_DATA_KEY_GDT, "gdt custom data");
// customData.put(com.bytedance.msdk.api.AdSlot.CUSTOM_DATA_KEY_KS, "ks custom data");
// 其他需要透传给adn的数据。
//创建广告请求参数AdSlot,具体参数含义参考文档
......@@ -229,6 +229,17 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
TrackManager.getInstance().reportAddCoinMsg(activity, getAdMapVO(carrierType, Constant.AD_SOURCE_GROMORE, extraId, curCoin));
if (mttRewardAd != null) {
// LogUtil.d(TAG, "adNetworkPlatformId: " + mttRewardAd.getAdNetworkPlatformId()); //获取展示广告对应的adn的值 具体值见NetworkPlatformConst类 -3: 无权限 -2: 暂无数据
// LogUtil.d(TAG, "adNetworkRitId:" + mttRewardAd.getAdNetworkRitId()); //获取展示广告对应的代码位 具体值见NetworkPlatformConst类 "-3": 无权限 "-2"
// LogUtil.d(TAG, "preEcpm: " + mttRewardAd.getPreEcpm()); //获取展示广告预估ecpm价格,单位是分 具体值见NetworkPlatformConst类 "-3": 无权限 "-2": 暂无数据 "-1":平台未有填写的预估ecpm价格
HashMap<String, Object> vo = new HashMap<>();
vo.put("adcode",mttRewardAd.getAdNetworkRitId());
vo.put("ecpm",mttRewardAd.getPreEcpm());
vo.put("adSource",mttRewardAd.getAdNetworkPlatformId());
vo.put("adType",Constant.GRO_MORE_ADTYPE2);
TrackManager.getInstance().cmtGroMoreInfo(vo);
}
if (videoAdStatusListener != null) {
videoAdStatusListener.adSuccess();
......
......@@ -308,6 +308,11 @@ public class VideoAdingManager {
weightList.clear();
}
int weight = 0;
if (AppConfig.groMoreVideoAdCount > 0) {
weightList.add(new WeightBean(groMoreWeight, Constant.GROMORE_VEDIO_AD));
weight = weight + groMoreWeight;
LogUtil.d(TAG, "权重值:groMoreWeight:" + groMoreWeight);
}
// 若没有视频完成数,不加入权重计算范围内
// 穿山甲>优量汇>快手>oneway>闪电盒子>穿山甲全屏>珊瑚>枫岚(兜底)
if (AppConfig.csjVideoAdCount > 0) {
......
......@@ -268,4 +268,9 @@ object Constant {
//page
const val ACTIVITY_ID = "activity_id"
const val ACTIVITY_TITLE = "activity_title"
//0-开屏,1-信息流,2-激励视频
const val GRO_MORE_ADTYPE0 = "0"
const val GRO_MORE_ADTYPE1 = "1"
const val GRO_MORE_ADTYPE2 = "2"
}
......@@ -4,7 +4,10 @@ import android.app.Application
import com.bytedance.applog.AppLog
import com.bytedance.applog.InitConfig
import com.bytedance.applog.util.UriConstants
import com.bytedance.hume.readapk.HumeSDK
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.utils.LogUtil
import com.mints.library.utils.CommonUtils
private val TAG = CsjAppLogManager::class.java.simpleName
......@@ -12,7 +15,7 @@ object CsjAppLogManager {
fun init(application: Application) {
/* 初始化开始 */
val config = InitConfig("your_appid", "your_channel") // appid和渠道,appid如不清楚请联系对接同学
val config = InitConfig(TtCsjAdManager.TT_AD_APPID, CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME") + HumeSDK.getChannel(MintsApplication.getContext())) // appid和渠道,appid如不清楚请联系对接同学
//上报域名只支持中国
config.setUriConfig(UriConstants.DEFAULT)
......
......@@ -143,4 +143,10 @@ public class TrackManager {
trackPresenter.riskinfo();
}
}
public void cmtGroMoreInfo(HashMap<String, Object> vo) {
if (trackPresenter != null && !TextUtils.isEmpty(UserManager.getInstance().getUserID())) {
trackPresenter.cmtGroMoreInfo(vo);
}
}
}
......@@ -400,4 +400,23 @@ public class TrackPresenter extends BaseTrackPresenter {
}
});
}
public void cmtGroMoreInfo(HashMap<String, Object> vo) {
AppHttpManager.getInstance(loanApplication)
.call(loanService.reportErrornterface(vo),
new BaseSubscriber<BaseResponse<JsonObject>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(BaseResponse<JsonObject> baseResponse) {
}
});
}
}
package com.mints.goodmoney.ui.activitys;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.FrameLayout;
import com.bytedance.msdk.adapter.pangle.PangleNetworkRequestInfo;
import com.bytedance.msdk.adapter.util.Logger;
import com.bytedance.msdk.api.AdError;
import com.bytedance.msdk.api.AdSlot;
import com.bytedance.msdk.api.NetworkPlatformConst;
......@@ -31,6 +27,8 @@ import com.yilan.sdk.ui.little.YLLittleVideoFragment;
import net.grandcentrix.tray.AppPreferences;
import java.util.HashMap;
/**
* GroMore开屏广告Activity示例
......@@ -124,8 +122,16 @@ public class SplashGroMoreActivity extends BaseActivity {
mTTSplashAd.showAd(mSplashContainer);
isBaiduSplashAd = mTTSplashAd.getAdNetworkPlatformId() == NetworkPlatformConst.SDK_NAME_BAIDU;
// 获取本次waterfall加载中,加载失败的adn错误信息。
if (mTTSplashAd != null)
LogUtil.d(TAG, "ad load infos: " + mTTSplashAd.getAdLoadInfoList());
if (mTTSplashAd != null) {
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);
TrackManager.getInstance().cmtGroMoreInfo(vo);
}
}
Log.e(TAG, "load splash ad success ");
}
......@@ -133,7 +139,6 @@ public class SplashGroMoreActivity extends BaseActivity {
@Override
public void onAdLoadTimeout() {
mHasLoaded = true;
showToast("开屏广告加载超时");
Log.i(TAG, "开屏广告加载超时.......");
// 获取本次waterfall加载中,加载失败的adn错误信息。
if (mTTSplashAd != null)
......@@ -148,19 +153,16 @@ public class SplashGroMoreActivity extends BaseActivity {
@Override
public void onAdClicked() {
baiduSplashAdClicked = true;
showToast("开屏广告被点击");
LogUtil.d(TAG, "onAdClicked");
}
@Override
public void onAdShow() {
showToast("开屏广告展示");
LogUtil.d(TAG, "onAdShow");
}
@Override
public void onAdSkip() {
showToast("开屏广告点击跳过按钮");
LogUtil.d(TAG, "onAdSkip");
goToMainActivity();
......@@ -168,7 +170,6 @@ public class SplashGroMoreActivity extends BaseActivity {
@Override
public void onAdDismiss() {
showToast("开屏广告倒计时结束关闭");
LogUtil.d(TAG, "onAdDismiss");
if (isBaiduSplashAd && onPaused && baiduSplashAdClicked) {
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要在onResume中跳转主页。
......
......@@ -10,6 +10,7 @@ import com.mints.goodmoney.manager.TrackManager;
import com.mints.goodmoney.mvp.presenters.VersionUpdatePresenter;
import com.mints.goodmoney.ui.activitys.SplashADActivity;
import com.mints.goodmoney.ui.activitys.SplashCsjADActivity;
import com.mints.goodmoney.ui.activitys.SplashGroMoreActivity;
import java.lang.ref.WeakReference;
......@@ -32,7 +33,7 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
private VersionUpdatePresenter vup;
private WeakReference<Activity> reference;
private Intent ylhIntent;
// private Intent ksIntent;
private Intent ksIntent;
private Intent csjIntent;
public static ForegroundOrBackground init(Application application) {
......@@ -106,30 +107,33 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
// 60秒后打开应用 显示开屏广告
if (System.currentTimeMillis() - leaveTime >= 60000) {
if (isYlhSplash) {
isYlhSplash = false;
if (ylhIntent == null) {
// 优量汇广告
ylhIntent = new Intent(activity, SplashADActivity.class);
}
activity.startActivity(ylhIntent);
} else {
isYlhSplash = true;
if (csjIntent == null) {
// 快手广告
csjIntent = new Intent(activity, SplashCsjADActivity.class);
}
activity.startActivity(csjIntent);
// if (ksIntent == null) {
// if (isYlhSplash) {
// isYlhSplash = false;
//
// if (ylhIntent == null) {
// // 优量汇广告
// ylhIntent = new Intent(activity, SplashADActivity.class);
// }
// activity.startActivity(ylhIntent);
// } else {
// isYlhSplash = true;
//
// if (csjIntent == null) {
// // 快手广告
// ksIntent = new Intent(activity, SplashKsADActivity.class);
// csjIntent = new Intent(activity, SplashCsjADActivity.class);
// }
// activity.startActivity(ksIntent);
// activity.startActivity(csjIntent);
//
//// if (ksIntent == null) {
//// // 快手广告
//// ksIntent = new Intent(activity, SplashKsADActivity.class);
//// }
//// activity.startActivity(ksIntent);
// }
if (ksIntent == null) {
ksIntent = new Intent(activity, SplashGroMoreActivity.class);
}
activity.startActivity(ksIntent);
}
}
count++;
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
#org.gradle.jvmargs=-Xmx2048m
org.gradle.jvmargs=-Xmx2048m
android.injected.testOnly=false
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......@@ -46,12 +46,3 @@ RELEASE_JPUSH_KEY=d1fc227e2d3ec3c7a8cafa69
android.useAndroidX=true
android.enableJetifier=true
\ No newline at end of file
#### 守护进程(复用每个gradle进程)
org.gradle.daemon=true
#### 增加jvm的内存
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -Dfile.encoding=UTF-8
#### 多个moudule 任务并行
org.gradle.parallel=true
#### 开启孵化模式
org.gradle.configureondemand=true
\ 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