add report switch
This commit is contained in:
@@ -11,10 +11,14 @@ import android.os.IBinder
|
||||
import android.util.Log
|
||||
import com.elegant.analytics.Analytics
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.mogo.utils.storage.SharedPrefsMgr
|
||||
import com.zhidao.cosupload.manager.CosUploadManagerImpl
|
||||
import com.zhidao.roadcondition.BuildConfig
|
||||
import com.zhidao.roadcondition.constant.*
|
||||
import com.zhidao.roadcondition.constant.DEFAULT_VIDEO_DURATION
|
||||
import com.zhidao.roadcondition.constant.TANLU_ROAD_CURRENT
|
||||
import com.zhidao.roadcondition.constant.UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO
|
||||
import com.zhidao.roadcondition.constant.UPLOAD_FROM_STRATEGY_BLOCK_AUTO
|
||||
import com.zhidao.roadcondition.event.GetImageSuccessEvent
|
||||
import com.zhidao.roadcondition.event.LatLngStickyEventBus
|
||||
import com.zhidao.roadcondition.util.*
|
||||
@@ -221,12 +225,16 @@ class MainService : Service() {
|
||||
//开始开始监听速度,只要超过一次5公里每小时则即开始获取策略进行本地上报 只有release才加此判断,qa环境方便测试
|
||||
LocationUtil.getInstance().setonSpeedlistenner(object : LocationUtil.SpeedListener {
|
||||
override fun onSpeedGet(speed: Float) {
|
||||
if (speed > (5 / 3.6f) && !isGetStrategies) {
|
||||
mainServiceHttpModel.initStrategies {
|
||||
handleReportStrategy()
|
||||
var isOpen = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp().applicationContext).getBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", false)
|
||||
Logger.d("EntrancePresenter", " -------- isOpen = $isOpen")
|
||||
if (isOpen) {
|
||||
if (speed > (5 / 3.6f) && !isGetStrategies) {
|
||||
mainServiceHttpModel.initStrategies {
|
||||
handleReportStrategy()
|
||||
}
|
||||
Log.d("MainService", "initLocationListener more than 5 start upload speed = $speed")
|
||||
isGetStrategies = true
|
||||
}
|
||||
Log.d("MainService", "initLocationListener more than 5 start upload speed = $speed")
|
||||
isGetStrategies = true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user