重构AD部分
This commit is contained in:
parent
41732c8e51
commit
0d2989117f
|
|
@ -56,7 +56,7 @@ public class ADStateUtils {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (switchRequestListener != null) {
|
if (switchRequestListener != null) {
|
||||||
switchRequestListener.onSwitchRequestChanged(false);
|
switchRequestListener.onSwitchRequestChanged();
|
||||||
switchRequestListener = null;
|
switchRequestListener = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +64,7 @@ public class ADStateUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface SwitchRequestListener {
|
public interface SwitchRequestListener {
|
||||||
void onSwitchRequestChanged(boolean isRequested);
|
void onSwitchRequestChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class SplashUtils {
|
||||||
public void run() {
|
public void run() {
|
||||||
long time = DateUtils.currentTimeStamp() - ADConstants.request_splash_time;
|
long time = DateUtils.currentTimeStamp() - ADConstants.request_splash_time;
|
||||||
if (!AdAppUtil.isRunningForeground(mActivity)) {//前台
|
if (!AdAppUtil.isRunningForeground(mActivity)) {//前台
|
||||||
LogAd.e("APP处于前台状态");
|
// LogAd.e("APP处于前台状态");
|
||||||
// LogAd.e("相差time=" + time);
|
// LogAd.e("相差time=" + time);
|
||||||
if (DateUtils.currentTimeStamp() - ADConstants.request_splash_time >= 20) {
|
if (DateUtils.currentTimeStamp() - ADConstants.request_splash_time >= 20) {
|
||||||
LogAd.e("应当开启开屏页");
|
LogAd.e("应当开启开屏页");
|
||||||
|
|
|
||||||
82
README.md
82
README.md
|
|
@ -1,32 +1,50 @@
|
||||||
com.xxx.xxx.xxx.app
|
# 广告模块集成指南
|
||||||
├── core/ # 核心基础模块
|
## 基础配置(必填项)
|
||||||
│ ├── constants/ # 常量(如路由、API地址等)
|
.addSlot(AD_CODE_SPLASH, "splash_id") // 开屏广告位
|
||||||
│ ├── enums/ # 枚举类
|
.addSlot(AD_CODE_REWARD, "reward_id") // 激励视频广告位
|
||||||
│ ├── extensions/ # Kotlin扩展函数
|
.addSlot(AD_CODE_FEED, "feed_id") // 信息流广告位
|
||||||
│ ├── utils/ # 工具类(可分日期、文件、屏幕工具等子包)
|
.addSlot(AD_CODE_BANNER, "banner_id") // Banner广告位
|
||||||
│ └── di/ # 核心依赖注入
|
|
||||||
│
|
.addSlot(AD_APPID, "app_id") // APPID
|
||||||
├── network/ # 网络通信模块
|
.addSlot(AD_CSJID, "csj_id") // CSJID
|
||||||
│ ├── api/ # 后端接口定义(按业务线分文件)
|
.addSlot(AD_CODE_SPLASH, "splash_id") // 添加横幅广告位
|
||||||
│ ├── model/ # 网络实体类
|
.addSlot(AD_CODE_REWARD, "reward_id") // 激励视频广告位
|
||||||
│ ├── interceptor/ # 拦截器(Token刷新、日志等)
|
.addSlot(AD_CODE_FEED1, "feed1_id") // 信息流1广告位
|
||||||
│ └── retrofit/ # Retrofit配置
|
.addSlot(AD_CODE_FEED2, "feed2_id") // 信息流2广告位
|
||||||
│
|
.addSlot(AD_CODE_FEED3, "feed3_id") // 信息流3广告位
|
||||||
├── feature_home/ # 首页功能模块(示例)
|
.addSlot(AD_CODE_BANNER, "banner_id") // banner广告位
|
||||||
│ ├── ui/ # 表现层
|
.addSlot(AD_CODE_Draw, "draw_id") // draw广告位
|
||||||
│ │ ├── HomeActivity.kt
|
|
||||||
│ │ ├── HomeFragment.kt
|
| 参数 | 类型 | 必填 | 说明 |
|
||||||
│ │ └── HomeViewModel.kt
|
|-----------|---------|------|----------|
|
||||||
│ │
|
| context | Context | ✓ | 应用上下文 |
|
||||||
│ ├── domain/ # 领域层(可选)
|
| APP_NAME | String | ✓ | 应用名称 |
|
||||||
│ └── data/ # 数据层(模块专属仓库)
|
| CHANNEL | String | ✓ | 渠道 |
|
||||||
│
|
| AppSplash | int | ✓ | 启动页id |
|
||||||
├── feature_auth/ # 认证模块(示例)
|
| APPID | String | ✕ | appid |
|
||||||
│ ├── ui/
|
| CSJID | String | ✕ | csjid |
|
||||||
│ ├── domain/
|
| AD_CODE_* | String | ✕ | 各类型广告位id |
|
||||||
│ └── data/
|
|
||||||
│
|
## 调试模式
|
||||||
└── shared/ # 共享模块
|
// 开发阶段开启(正式环境需关闭)
|
||||||
├── components/ # 公共UI组件(Dialog、自定义View等)
|
LogAd.setDebug(true);
|
||||||
├── model/ # 跨模块共享的领域模型
|
|
||||||
└── resources/ # 公共资源(如字符串常量)
|
## 最佳实践
|
||||||
|
初始化时机:在Application.onCreate()中完成初始化
|
||||||
|
隐私合规:确保用户已同意隐私政策
|
||||||
|
版本兼容:最低支持Android 7.0(API 24)
|
||||||
|
|
||||||
|
## 初始化失败监听-->重新请求广告开关
|
||||||
|
ADStateUtils.setSwitchRequestListener(new ADStateUtils.SwitchRequestListener() {
|
||||||
|
@Override
|
||||||
|
public void onSwitchRequestChanged() {
|
||||||
|
AdUtils.getAdvFlag();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
#### ⚠️ 正式发布前确认:
|
||||||
|
已关闭调试日志6
|
||||||
|
所有广告位ID已测试通过
|
||||||
|
符合广告平台政策要求
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue