添加部分adas车辆模型list接口实现
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -77,6 +77,7 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -9,13 +9,16 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.bean.CommonConfig;
|
||||
import com.mogo.module.extensions.bean.CommonConfigResponse;
|
||||
import com.mogo.module.extensions.net.DztHttpConstant;
|
||||
import com.mogo.module.extensions.net.GetConfigApiServices;
|
||||
import com.mogo.module.extensions.net.UserInfoNetApiServices;
|
||||
import com.mogo.module.extensions.userinfo.CarModelListResponse;
|
||||
import com.mogo.module.extensions.userinfo.UserInfo;
|
||||
import com.mogo.module.extensions.userinfo.UserInfoConstant;
|
||||
import com.mogo.module.extensions.userinfo.UserInfoResponse;
|
||||
@@ -23,12 +26,15 @@ import com.mogo.module.extensions.weather.Phenomena;
|
||||
import com.mogo.module.extensions.weather.WeatherCallback;
|
||||
import com.mogo.module.extensions.weather.WeatherInfo;
|
||||
import com.mogo.module.extensions.weather.WeatherModel;
|
||||
import com.mogo.module.share.constant.HttpConstant;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.service.statusmanager.IMogoMsgCenter;
|
||||
import com.mogo.service.statusmanager.IMogoMsgCenterListener;
|
||||
import com.mogo.utils.digest.DigestUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -56,73 +62,80 @@ public class EntrancePresenter extends Presenter<EntranceView> implements Weathe
|
||||
|
||||
private IMogoNetwork mNetWork;
|
||||
|
||||
private Context context;
|
||||
|
||||
private boolean isResumed = false;
|
||||
|
||||
public EntrancePresenter(Context context, EntranceView view) {
|
||||
super(view);
|
||||
mWeatherModel = new WeatherModel( getContext() );
|
||||
this.context = context;
|
||||
mWeatherModel = new WeatherModel(getContext());
|
||||
mNetWork = MogoApisHandler.getInstance().getApis().getNetworkApi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NonNull LifecycleOwner owner) {
|
||||
super.onCreate(owner);
|
||||
mWeatherModel.init( this );
|
||||
mWeatherModel.init(this);
|
||||
mWeatherModel.queryWeatherInformation();
|
||||
mMsgCenter = ( IMogoMsgCenter ) ARouter.getInstance().build( MogoServicePaths.PATH_MSG_CENTER ).navigation();
|
||||
mMsgCenter.registerMsgCenterListener( this );
|
||||
mMsgCenter =
|
||||
(IMogoMsgCenter) ARouter.getInstance().build(MogoServicePaths.PATH_MSG_CENTER).navigation();
|
||||
mMsgCenter.registerMsgCenterListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWeatherLoaded( WeatherInfo weatherInfo ) {
|
||||
if ( weatherInfo == null ) {
|
||||
public void onWeatherLoaded(WeatherInfo weatherInfo) {
|
||||
if (weatherInfo == null) {
|
||||
return;
|
||||
}
|
||||
Phenomena phenomena = Phenomena.getById( weatherInfo.getPhenomena() );
|
||||
if ( phenomena == null ) {
|
||||
Phenomena phenomena = Phenomena.getById(weatherInfo.getPhenomena());
|
||||
if (phenomena == null) {
|
||||
return;
|
||||
}
|
||||
String temp = getContext().getResources().getString( R.string.module_ext_str_weather_temp_format, weatherInfo.getTemperature() );
|
||||
String temp =
|
||||
getContext().getResources().getString(R.string.module_ext_str_weather_temp_format
|
||||
, weatherInfo.getTemperature());
|
||||
String desc = phenomena.nameCn;
|
||||
int resId = phenomena.resId;
|
||||
mView.renderWeatherInfo( temp, desc, resId );
|
||||
mView.renderWeatherInfo(temp, desc, resId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgChanged( boolean hasMsg, int amount ) {
|
||||
if ( mView != null ) {
|
||||
mView.renderMsgInfo( hasMsg, amount );
|
||||
public void onMsgChanged(boolean hasMsg, int amount) {
|
||||
if (mView != null) {
|
||||
mView.renderMsgInfo(hasMsg, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume( @NonNull LifecycleOwner owner ) {
|
||||
super.onResume( owner );
|
||||
public void onResume(@NonNull LifecycleOwner owner) {
|
||||
super.onResume(owner);
|
||||
isResumed = true;
|
||||
if (userInfo != null) {
|
||||
mView.renderUserInfo(userInfo);
|
||||
}
|
||||
if( DebugConfig.isNeedRequestUserInfo()){
|
||||
if (DebugConfig.isNeedRequestUserInfo()) {
|
||||
// 相当于每次onResume都会请求一下个人信息,目的是能够相对及时的同步手机端的个人信息修改
|
||||
requestUserInfo();
|
||||
}
|
||||
requestCarModelList();
|
||||
getCommonConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause( @NonNull LifecycleOwner owner ) {
|
||||
super.onPause( owner );
|
||||
public void onPause(@NonNull LifecycleOwner owner) {
|
||||
super.onPause(owner);
|
||||
isResumed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
if ( mWeatherModel != null ) {
|
||||
public void onDestroy(@NonNull LifecycleOwner owner) {
|
||||
super.onDestroy(owner);
|
||||
if (mWeatherModel != null) {
|
||||
mWeatherModel.destroy();
|
||||
}
|
||||
if ( mMsgCenter != null ) {
|
||||
mMsgCenter.unregisterMsgCenterListener( this );
|
||||
if (mMsgCenter != null) {
|
||||
mMsgCenter.unregisterMsgCenterListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,44 +147,48 @@ public class EntrancePresenter extends Presenter<EntranceView> implements Weathe
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SingleObserver<CommonConfigResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(CommonConfigResponse config) {
|
||||
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 ");
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(CommonConfigResponse config) {
|
||||
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 ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
e.printStackTrace();
|
||||
Logger.e(TAG,"getCommonConfig onError ---> e = " + e);
|
||||
}
|
||||
});
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
e.printStackTrace();
|
||||
Logger.e(TAG, "getCommonConfig onError ---> e = " + e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private UserInfo userInfo;
|
||||
|
||||
public void requestUserInfo() {
|
||||
Map<String, String> params = new ArrayMap<>();
|
||||
params.put("sn", Utils.getSn());
|
||||
@@ -186,7 +203,7 @@ public class EntrancePresenter extends Presenter<EntranceView> implements Weathe
|
||||
@Override
|
||||
public void onSuccess(UserInfoResponse userInfoBaseResponse) {
|
||||
userInfo = userInfoBaseResponse.getResult();
|
||||
if(isResumed) {
|
||||
if (isResumed) {
|
||||
if (userInfo != null) {
|
||||
Logger.d(TAG, "获取个人信息成功: " + userInfo);
|
||||
mView.renderUserInfo(userInfo);
|
||||
@@ -222,4 +239,32 @@ public class EntrancePresenter extends Presenter<EntranceView> implements Weathe
|
||||
}
|
||||
}
|
||||
|
||||
private void requestCarModelList() {
|
||||
mNetWork.create(UserInfoNetApiServices.class, DztHttpConstant.getBaseUrl()).
|
||||
requestCarModelList().
|
||||
subscribeOn(Schedulers.io()).
|
||||
observeOn(Schedulers.io()).
|
||||
subscribe(new SubscribeImpl<CarModelListResponse>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(CarModelListResponse o) {
|
||||
super.onSuccess(o);
|
||||
// todo 保存到sp中
|
||||
SharedPrefsMgr.getInstance(context).putString("CAR_MODEL_LIST",
|
||||
GsonUtil.jsonFromObject(o.getResult()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.e(TAG, e, "请求自车模型失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
Logger.e(TAG, "请求自车模型失败: " + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.module.extensions.net;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
|
||||
/**
|
||||
* dzt base url
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class DztHttpConstant {
|
||||
public static final String HOST_DEV = "http://dzt-test.zhidaohulian.com";
|
||||
public static final String HOST_TEST = "http://dzt-test.zhidaohulian.com";
|
||||
public static final String HOST_DEMO = "http://dzt-show.zhidaohulian.com";
|
||||
public static final String HOST_PRODUCT = "https://dzt.zhidaohulian.com";
|
||||
|
||||
public static String getBaseUrl(){
|
||||
switch ( DebugConfig.getNetMode() ) {
|
||||
case DebugConfig.NET_MODE_DEV:
|
||||
return HOST_DEV;
|
||||
case DebugConfig.NET_MODE_QA:
|
||||
return HOST_TEST;
|
||||
case DebugConfig.NET_MODE_DEMO:
|
||||
return HOST_DEMO;
|
||||
default:
|
||||
return HOST_PRODUCT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.mogo.module.extensions.net;
|
||||
|
||||
import com.mogo.module.extensions.userinfo.CarModelListResponse;
|
||||
import com.mogo.module.extensions.userinfo.UserInfoResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
@@ -21,4 +23,7 @@ public interface UserInfoNetApiServices {
|
||||
*/
|
||||
@GET("carlife/carMachine/getAccountInfo")
|
||||
Single<UserInfoResponse> requestUserInfo(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("")
|
||||
Observable<CarModelListResponse> requestCarModelList();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mogo.module.extensions.userinfo;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.module.common.entity.OwnCarModelEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请求根据热心指数获取自车图标列表的响应类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class CarModelListResponse extends BaseData {
|
||||
private List<OwnCarModelEntity> result;
|
||||
|
||||
public List<OwnCarModelEntity> getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(List<OwnCarModelEntity> result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.mogo.service.impl.adas;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.context.ContextHolderUtil;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
@@ -115,9 +112,9 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@Override
|
||||
public void requestGetCarModelListInfo() {
|
||||
// todo 向adas发送车模list
|
||||
// 图标列表,
|
||||
// AutopilotServiceManage.getInstance().settingCarModelListInfo();
|
||||
// 向adas发送车模list
|
||||
AutopilotServiceManage.getInstance().settingCarModelListInfo(SharedPrefsMgr.getInstance(ContextHolderUtil.getContext()).getString(
|
||||
"CAR_MODEL_LIST", ""));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user