This commit is contained in:
zhongchao
2022-03-22 10:07:10 +08:00
parent 3a14b5e37d
commit a39f310331
42 changed files with 1317 additions and 201 deletions

View File

@@ -5,10 +5,10 @@ import android.content.Context;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.network.ParamsProvider;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
import com.mogo.eagle.core.network.RequestOptions;
import com.mogo.eagle.core.network.SubscribeImpl;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.HostConst;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.service.ServiceConst;
@@ -32,56 +32,56 @@ public class RefreshModel {
private final Context mContext;
private final RefreshApiService mRefreshApiService;
public RefreshModel( Context context ) {
public RefreshModel(Context context) {
this.mContext = context;
this.mRefreshApiService = MogoApisHandler.getInstance().getApis().getNetworkApi().create( RefreshApiService.class, HostConst.LAUNCHER_SNAPSHOT_HOST);
this.mRefreshApiService = MoGoRetrofitFactory.getInstance(HostConst.LAUNCHER_SNAPSHOT_HOST).create(RefreshApiService.class);
}
public RefreshApiService getRefreshApiService() {
return mRefreshApiService;
}
public void refreshExplorerWayData( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
if ( mRefreshApiService != null ) {
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
public void refreshExplorerWayData(MogoLatLng latLng, int radius, int limit, final RefreshCallback callback) {
if (mRefreshApiService != null) {
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
final RefreshBody refreshBody = new RefreshBody();
refreshBody.limit = limit;
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lon );
refreshBody.location = new RefreshBody.LatLon(latLng.lat, latLng.lon);
refreshBody.radius = radius;
refreshBody.viewPush = true;
refreshBody.dataType.add( ServiceConst.CARD_TYPE_ROAD_CONDITION );
refreshBody.dataType.add(ServiceConst.CARD_TYPE_ROAD_CONDITION);
String data = GsonUtil.jsonFromObject( refreshBody );
query.put( "data", data );
String data = GsonUtil.jsonFromObject(refreshBody);
query.put("data", data);
mRefreshApiService.refreshDataSync( query )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< MarkerResponse >( RequestOptions.create( mContext ) ) {
mRefreshApiService.refreshDataSync(query)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<MarkerResponse>(RequestOptions.create(mContext)) {
@Override
public void onSuccess( MarkerResponse o ) {
super.onSuccess( o );
if ( callback != null ) {
callback.onSuccess( o );
public void onSuccess(MarkerResponse o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError( Throwable e ) {
super.onError( e );
if ( callback != null ) {
public void onError(Throwable e) {
super.onError(e);
if (callback != null) {
callback.onFail();
}
}
@Override
public void onError( String message, int code ) {
super.onError( message, code );
if ( callback != null ) {
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
callback.onFail();
}
}
} );
});
}
}
@@ -95,56 +95,56 @@ public class RefreshModel {
* @param callback
* @param onlyRealUser 是否只查询真实用户
*/
public void queryOnLineCarWithRoute( MogoLatLng latLng,
boolean onlyFocus,
boolean onlySameCity,
int radius,
int limit,
boolean onlyRealUser,
final RefreshCallback callback ) {
if ( mRefreshApiService != null ) {
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
public void queryOnLineCarWithRoute(MogoLatLng latLng,
boolean onlyFocus,
boolean onlySameCity,
int radius,
int limit,
boolean onlyRealUser,
final RefreshCallback callback) {
if (mRefreshApiService != null) {
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
final RefreshBody refreshBody = new RefreshBody();
refreshBody.sn = MoGoAiCloudClientConfig.getInstance().getSn();
if ( limit > 0 ) {
if (limit > 0) {
refreshBody.limit = limit;
}
refreshBody.radius = radius;
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lon );
refreshBody.location = new RefreshBody.LatLon(latLng.lat, latLng.lon);
refreshBody.onlyFocus = onlyFocus;
refreshBody.onlySameCity = onlySameCity;
refreshBody.onlyRealUser = onlyRealUser;
refreshBody.dataType.add( ServiceConst.CARD_TYPE_USER_DATA );
refreshBody.dataType.add(ServiceConst.CARD_TYPE_USER_DATA);
query.put( "data", GsonUtil.jsonFromObject( refreshBody ) );
mRefreshApiService.queryOnLineCarWithRoute( query )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< MarkerResponse >( RequestOptions.create( mContext ) ) {
query.put("data", GsonUtil.jsonFromObject(refreshBody));
mRefreshApiService.queryOnLineCarWithRoute(query)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<MarkerResponse>(RequestOptions.create(mContext)) {
@Override
public void onSuccess( MarkerResponse o ) {
super.onSuccess( o );
if ( callback != null ) {
callback.onSuccess( o );
public void onSuccess(MarkerResponse o) {
super.onSuccess(o);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError( Throwable e ) {
super.onError( e );
if ( callback != null ) {
public void onError(Throwable e) {
super.onError(e);
if (callback != null) {
callback.onFail();
}
}
@Override
public void onError( String message, int code ) {
super.onError( message, code );
if ( callback != null ) {
public void onError(String message, int code) {
super.onError(message, code);
if (callback != null) {
callback.onFail();
}
}
} );
});
}
}

View File

@@ -3,8 +3,9 @@ package com.mogo.module.service.network;
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.module.common.constants.HostConst;
import com.mogo.eagle.core.data.constants.MogoServicePaths;
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
import com.mogo.module.common.constants.HostConst;
import com.mogo.service.network.IMogoNetwork;
@@ -20,9 +21,9 @@ public class ZhidaoRefreshModel {
private final ZhidaoApiService mRefreshApiService;
public ZhidaoRefreshModel( Context context ) {
IMogoNetwork network = ( IMogoNetwork ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_NETWORK ).navigation( context );
this.mRefreshApiService = network.create( ZhidaoApiService.class, HostConst.CARLIFE_HOST);
public ZhidaoRefreshModel(Context context) {
IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(context);
this.mRefreshApiService = MoGoRetrofitFactory.getInstance(HostConst.CARLIFE_HOST).create(ZhidaoApiService.class);
}
public ZhidaoApiService getRefreshApiService() {