+ * 描述
+ */
+public class OnlineCarMarkerView implements IMarkerView {
+
+ private static Map< String, SoftReference< Bitmap > > sRef = new HashMap<>();
+
+ private OnlineCarMarkerView(){
+ // private constructor
+ }
+
+ private static final class InstanceHolder{
+ private static final OnlineCarMarkerView INSTANCE = new OnlineCarMarkerView();
+ }
+
+ public static OnlineCarMarkerView getInstance(){
+ return InstanceHolder.INSTANCE;
+ }
+
+ private Object readResolve(){
+ // 阻止反序列化,必须实现 Serializable 接口
+ return InstanceHolder.INSTANCE;
+ }
+
+ @Override
+ public View getView() {
+ return null;
+ }
+
+ @Override
+ public Bitmap getBitmap() {
+ if ( sRef.get( ModuleNames.CARD_TYPE_USER_DATA ) == null || sRef.get( ModuleNames.CARD_TYPE_USER_DATA ).get() == null
+ || sRef.get( ModuleNames.CARD_TYPE_USER_DATA ).get().isRecycled() ) {
+ sRef.put( ModuleNames.CARD_TYPE_USER_DATA, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray ) ) );
+ }
+ return sRef.get( ModuleNames.CARD_TYPE_USER_DATA ).get();
+ }
+
+ @Override
+ public void setMarker( IMogoMarker marker ) {
+
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/UserDataMarkerInfoWindowAdapter.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/UserDataMarkerInfoWindowAdapter.java
index dcba9a1ec9..31768b6763 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/UserDataMarkerInfoWindowAdapter.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/UserDataMarkerInfoWindowAdapter.java
@@ -8,6 +8,8 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.commons.network.SubscribeImpl;
import com.mogo.map.marker.IMogoInfoWindowAdapter;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.entity.MarkerLocation;
@@ -16,15 +18,25 @@ import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.MarkerUserInfo;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
+import com.mogo.module.service.network.RefreshApiService;
+import com.mogo.module.service.network.RefreshModel;
+import com.mogo.module.service.network.bean.DemoUserInfoEntity;
+import com.mogo.service.MogoServicePaths;
import com.mogo.service.imageloader.MogoImageView;
+import com.mogo.service.network.IMogoNetwork;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.WindowUtils;
import com.mogo.utils.logger.Logger;
+import com.mogo.utils.network.RequestOptions;
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+
/**
* @author congtaowang
* @since 2020-04-27
@@ -37,6 +49,7 @@ public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter {
private static volatile UserDataMarkerInfoWindowAdapter sInstance;
private final Context mContext;
+ private static RefreshApiService sRefreshApiService;
private View mInfoWindowView = null;
@@ -47,6 +60,8 @@ public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter {
private UserDataMarkerInfoWindowAdapter( Context context ) {
this.mContext = context;
+ IMogoNetwork network = MarkerServiceHandler.getApis().getNetworkApi();
+ sRefreshApiService = network.create( RefreshApiService.class, RefreshModel.getNetHost() );
}
public static UserDataMarkerInfoWindowAdapter getInstance( Context context ) {
@@ -95,23 +110,21 @@ public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter {
}
mCall.setOnClickListener( view -> {
if ( markerShowEntity.getBindObj() instanceof MarkerOnlineCar ) {
- Map< String, String > params = new HashMap<>();
- MarkerUserInfo userInfo = ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getUserInfo();
- if ( userInfo != null ) {
- params.put( CallChattingProviderConstant.CCPROVIDER_SN, userInfo.getSn() );
- params.put( CallChattingProviderConstant.CCPROVIDER_USER_IMG, userInfo.getUserHead() );
- params.put( CallChattingProviderConstant.CCPROVIDER_USER_AGE, userInfo.getAgeNumber() + "" );
- params.put( CallChattingProviderConstant.CCPROVIDER_NICK_NAME, userInfo.getUserName() );
- params.put( CallChattingProviderConstant.CCPROVIDER_USER_SEX, userInfo.getGender() + "" );
- }
- MarkerLocation location = ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getLocation();
- if ( location != null ) {
- params.put( CallChattingProviderConstant.CCPROVIDER_ADDRESS, location.getAddress() );
- params.put( CallChattingProviderConstant.CCPROVIDER_LAT, location.getLat() + "" );
- params.put( CallChattingProviderConstant.CCPROVIDER_LON, location.getLon() + "" );
- }
- Logger.d( TAG, "call parameters: %s", params );
- MarkerServiceHandler.getCarChatting().call( params );
+ sRefreshApiService.getMockUsers().subscribeOn( Schedulers.io() )
+ .observeOn( AndroidSchedulers.mainThread() )
+ .subscribe( new SubscribeImpl< DemoUserInfoEntity >( RequestOptions.create( mContext ) ) {
+ @Override
+ public void onSuccess( DemoUserInfoEntity o ) {
+ super.onSuccess( o );
+ callToDemoUser( markerShowEntity, o );
+ }
+
+ @Override
+ public void onError( String message, int code ) {
+ super.onError( message, code );
+ callToFactUser( markerShowEntity );
+ }
+ } );
}
} );
} catch ( Exception e ) {
@@ -121,6 +134,58 @@ public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter {
return mInfoWindowView;
}
+ private void callToDemoUser( MarkerShowEntity factUser, DemoUserInfoEntity demoUser ) {
+ if ( demoUser == null
+ || demoUser.getResult() == null
+ || demoUser.getResult().getUserList() == null
+ || demoUser.getResult().getUserList().isEmpty() ) {
+ callToFactUser( factUser );
+ return;
+ }
+ List< DemoUserInfoEntity.ResultBean.UserListBean > users = demoUser.getResult().getUserList();
+ for ( DemoUserInfoEntity.ResultBean.UserListBean user : users ) {
+ if ( user == null ) {
+ continue;
+ }
+ if ( TextUtils.equals( "1", user.getSceneType() ) ) {
+ try {
+ ( ( MarkerOnlineCar ) factUser.getBindObj() ).getUserInfo().setSn( user.getUserInfo().getSn() );
+ callToFactUser( factUser );
+ return;
+ } catch ( Exception e ) {
+ }
+ }
+ }
+ callToFactUser( factUser );
+ }
+
+ private void callToFactUser( MarkerShowEntity factUser ) {
+ if ( factUser == null ) {
+ return;
+ }
+ Map< String, String > params = new HashMap<>();
+ MarkerUserInfo userInfo = ( ( MarkerOnlineCar ) factUser.getBindObj() ).getUserInfo();
+ if ( userInfo != null ) {
+ params.put( CallChattingProviderConstant.CCPROVIDER_SN, userInfo.getSn() );
+ params.put( CallChattingProviderConstant.CCPROVIDER_USER_IMG, userInfo.getUserHead() );
+ params.put( CallChattingProviderConstant.CCPROVIDER_USER_AGE, userInfo.getAgeNumber() + "" );
+ params.put( CallChattingProviderConstant.CCPROVIDER_NICK_NAME, userInfo.getUserName() );
+ params.put( CallChattingProviderConstant.CCPROVIDER_USER_SEX, userInfo.getGender() + "" );
+ }
+ MarkerLocation location = ( ( MarkerOnlineCar ) factUser.getBindObj() ).getLocation();
+ if ( location != null ) {
+ params.put( CallChattingProviderConstant.CCPROVIDER_ADDRESS, location.getAddress() );
+ params.put( CallChattingProviderConstant.CCPROVIDER_LAT, location.getLat() + "" );
+ params.put( CallChattingProviderConstant.CCPROVIDER_LON, location.getLon() + "" );
+ }
+ Logger.d( TAG, "call parameters: %s", params );
+ if ( MarkerServiceHandler.getApis().getStatusManagerApi().isADASShow() ) {
+ MarkerServiceHandler.getCarChatting().callShowWindow( params );
+ } else {
+ MarkerServiceHandler.getCarChatting().call( params );
+ }
+ }
+
protected void loadImageHeader( final MarkerShowEntity markerShowEntity ) {
if ( Looper.myLooper() != Looper.getMainLooper() ) {
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
index 722b7cfa29..ab6e8ff02d 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
@@ -2,6 +2,7 @@ package com.mogo.module.service.network;
import com.mogo.commons.data.BaseData;
import com.mogo.module.common.entity.MarkerResponse;
+import com.mogo.module.service.network.bean.DemoUserInfoEntity;
import java.util.Map;
@@ -29,4 +30,10 @@ public interface RefreshApiService {
@POST( "/yycp-launcherSnapshot/user/queryOnLineCarWithRoute" )
Observable