add report switch

This commit is contained in:
lixiaopeng
2020-10-13 16:33:09 +08:00
parent 0713f3d89c
commit 4f81fa6001
3 changed files with 33 additions and 9 deletions

View File

@@ -12,11 +12,13 @@ public class CommonConfig {
public Active active;//活动配置
public Auth auth; //授权配置
public Speech speech; //语音播报次数
public ReportStrategy reportStrategy; //被动上报策略开关
public CommonConfig(Active active, Auth auth, Speech speech) {
public CommonConfig(Active active, Auth auth, Speech speech, ReportStrategy reportStrategy) {
this.active = active;
this.auth = auth;
this.speech = speech;
this.reportStrategy = reportStrategy;
}
public class Active{
@@ -47,4 +49,11 @@ public class CommonConfig {
this.isNeedAuth = isNeedAuth;
}
}
public class ReportStrategy {
public boolean open;
ReportStrategy(boolean open) {
this.open = open;
}
}
}

View File

@@ -130,7 +130,6 @@ public class EntrancePresenter extends Presenter<EntranceView> implements Weathe
public void getCommonConfig() {
Map<String, Object> params = new ArrayMap<>();
params.put("sn", Utils.getSn());
mNetWork.create(GetConfigApiServices.class, UserInfoConstant.getUserInfoBaseUrl())
.getConfig(params)
.subscribeOn(Schedulers.io())
@@ -145,12 +144,20 @@ public class EntrancePresenter extends Presenter<EntranceView> implements Weathe
Logger.d(TAG, "getCommonConfig onSuccess -----> ");
if (config != null && config.result != null) {
CommonConfig.Speech speech = config.result.speech;
CommonConfig.ReportStrategy strategy = config.result.reportStrategy;
if (speech != null) {
Logger.d(TAG, "getCommonConfig onSuccess speech.count = " + speech.count);
SharedPrefsMgr.getInstance(getContext()).putInt(KEY_SERVER_SHOW_DAY_COUNT, speech.count);
} else {
Logger.e(TAG, "getCommonConfig onSuccess speech == null ");
}
if (strategy != null) {
Logger.d(TAG, "getCommonConfig onSuccess strategy.open = " + strategy.open);
SharedPrefsMgr.getInstance(getContext()).putBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", strategy.open);
} else {
Logger.e(TAG, "getCommonConfig onSuccess strategy == null ");
}
} else {
Logger.e(TAG, "getCommonConfig onSuccess config == null");
}