diff --git a/modules/mogo-module-service/build.gradle b/modules/mogo-module-service/build.gradle index 57f5a280c7..6c15a6d379 100644 --- a/modules/mogo-module-service/build.gradle +++ b/modules/mogo-module-service/build.gradle @@ -45,6 +45,7 @@ dependencies { annotationProcessor rootProject.ext.dependencies.aroutercompiler implementation rootProject.ext.dependencies.rxjava implementation rootProject.ext.dependencies.rxandroid + implementation rootProject.ext.dependencies.carcallprovider if (Boolean.valueOf(RELEASE)) { api rootProject.ext.dependencies.mogomap diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java index 089851d54e..a1774a2d4a 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java @@ -7,6 +7,7 @@ import com.mogo.map.location.IMogoLocationClient; import com.mogo.map.marker.IMogoMarkerManager; import com.mogo.map.navi.IMogoNavi; import com.mogo.map.uicontroller.IMogoMapUIController; +import com.mogo.module.carchattingprovider.ICarsChattingProvider; import com.mogo.module.common.entity.MarkerResponse; import com.mogo.module.common.entity.MarkerShowEntity; import com.mogo.module.service.marker.MapMarkerManager; @@ -25,6 +26,7 @@ import com.mogo.service.map.IMogoMapService; import com.mogo.service.module.IMogoActionManager; import com.mogo.service.module.IMogoRegisterCenter; import com.mogo.service.statusmanager.IMogoStatusManager; +import com.zhidao.carchattingprovider.CallChattingProviderConstant; /** * author : donghongyu @@ -36,128 +38,136 @@ import com.mogo.service.statusmanager.IMogoStatusManager; public class MarkerServiceHandler { private static final String TAG = "MarkerServiceHandler"; - private static IMogoServiceApis mApis; + private static IMogoServiceApis sApis; - private static IMogoMapService mMapService; - private static IMogoMarkerManager mMarkerManager; - private static IMogoNavi mNavi; - private static IMogoMapUIController mMapUIController; - private static IMogoLocationClient mLocationClient; - private static IMogoStatusManager mMogoStatusManager; - private static IMogoImageloader mImageloader; - private static IMogoSocketManager mMogoSocketManager; - private static IMogoCardManager mMogoCardManager; - private static IMogoAnalytics mMogoAnalytics; - private static IMogoRegisterCenter mRegisterCenter; - private static IMogoActionManager mActionManager; - private static IMogoDataManager mDataManager; - private static IMogoIntentManager mIntentManager; - private static IMogoADASController mADASController; - private static IMogoLauncher mLauncher; - private static IMogoFragmentManager mFragmentManager; + private static IMogoMapService sMapService; + private static IMogoMarkerManager sMarkerManager; + private static IMogoNavi sNavi; + private static IMogoMapUIController sMapUIController; + private static IMogoLocationClient sLocationClient; + private static IMogoStatusManager sMogoStatusManager; + private static IMogoImageloader sImageloader; + private static IMogoSocketManager sMogoSocketManager; + private static IMogoCardManager sMogoCardManager; + private static IMogoAnalytics sMogoAnalytics; + private static IMogoRegisterCenter sRegisterCenter; + private static IMogoActionManager sActionManager; + private static IMogoDataManager sDataManager; + private static IMogoIntentManager sIntentManager; + private static IMogoADASController sADASController; + private static IMogoLauncher sLauncher; + private static IMogoFragmentManager sFragmentManager; + private static ICarsChattingProvider sCarChatting; - private static MapMarkerManager mMapMarkerManager; + private static MapMarkerManager sMapMarkerManager; public static void init( final Context context ) { - mApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( context ); - mMapService = mApis.getMapServiceApi(); - mImageloader = mApis.getImageLoaderApi(); - mMogoStatusManager = mApis.getStatusManagerApi(); - mMogoSocketManager = mApis.getSocketManagerApi( context ); - mMogoCardManager = mApis.getCardManagerApi(); - mMogoAnalytics = mApis.getAnalyticsApi(); - mMarkerManager = mMapService.getMarkerManager( context ); - mNavi = mMapService.getNavi( context ); - mMapUIController = mMapService.getMapUIController(); - mLocationClient = mMapService.getSingletonLocationClient( context ); - mRegisterCenter = mApis.getRegisterCenterApi(); - mActionManager = mApis.getActionManagerApi(); - mDataManager = mApis.getDataManagerApi(); - mIntentManager = mApis.getIntentManagerApi(); - mADASController = mApis.getAdasControllerApi(); - mLauncher = mApis.getLauncherApi(); - mFragmentManager = mApis.getFragmentManagerApi(); + sApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( context ); + sMapService = sApis.getMapServiceApi(); + sImageloader = sApis.getImageLoaderApi(); + sMogoStatusManager = sApis.getStatusManagerApi(); + sMogoSocketManager = sApis.getSocketManagerApi( context ); + sMogoCardManager = sApis.getCardManagerApi(); + sMogoAnalytics = sApis.getAnalyticsApi(); + sMarkerManager = sMapService.getMarkerManager( context ); + sNavi = sMapService.getNavi( context ); + sMapUIController = sMapService.getMapUIController(); + sLocationClient = sMapService.getSingletonLocationClient( context ); + sRegisterCenter = sApis.getRegisterCenterApi(); + sActionManager = sApis.getActionManagerApi(); + sDataManager = sApis.getDataManagerApi(); + sIntentManager = sApis.getIntentManagerApi(); + sADASController = sApis.getAdasControllerApi(); + sLauncher = sApis.getLauncherApi(); + sFragmentManager = sApis.getFragmentManagerApi(); - mMapMarkerManager = MapMarkerManager.getInstance(); - mMapMarkerManager.init( context ); + sCarChatting = (ICarsChattingProvider)ARouter.getInstance().build( CallChattingProviderConstant.CAR_CALL_PROVIDER ).navigation( context ); + + sMapMarkerManager = MapMarkerManager.getInstance(); + sMapMarkerManager.init( context ); } public static IMogoServiceApis getApis(){ - return mApis; + return sApis; } public static IMogoMapService getMapService() { - return mMapService; + return sMapService; } public static IMogoMarkerManager getMarkerManager() { - return mMarkerManager; + return sMarkerManager; } public static IMogoNavi getNavi() { - return mNavi; + return sNavi; } public static IMogoMapUIController getMapUIController() { - return mMapUIController; + return sMapUIController; } public static IMogoImageloader getImageloader() { - return mImageloader; + return sImageloader; } public static IMogoSocketManager getMogoSocketManager() { - return mMogoSocketManager; + return sMogoSocketManager; } public static IMogoStatusManager getMogoStatusManager() { - return mMogoStatusManager; + return sMogoStatusManager; } public static IMogoCardManager getMogoCardManager() { - return mMogoCardManager; + return sMogoCardManager; } public static IMogoAnalytics getMogoAnalytics() { - return mMogoAnalytics; + return sMogoAnalytics; } public static IMogoLocationClient getMogoLocationClient() { - return mLocationClient; + return sLocationClient; } public static MapMarkerManager getMapMarkerManager() { - return mMapMarkerManager; + return sMapMarkerManager; } public static IMogoRegisterCenter getRegisterCenter() { - return mRegisterCenter; + return sRegisterCenter; } public static IMogoActionManager getActionManager() { - return mActionManager; + return sActionManager; } public static IMogoIntentManager getIntentManager() { - return mIntentManager; + return sIntentManager; } public static IMogoADASController getADASController() { - return mADASController; + return sADASController; } public static IMogoLauncher getLauncher() { - return mLauncher; + return sLauncher; } public static IMogoFragmentManager getFragmentManager() { - return mFragmentManager; + return sFragmentManager; } public static IMogoDataManager getDataManager() { - return mDataManager; + return sDataManager; } + public static ICarsChattingProvider getCarChatting() { + return sCarChatting; + } + + //TODO -------------以下方法是临时过度使用的,后面统一使用,getMapMarkerManager进行调用 /** diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerBaseView.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerBaseView.java index c790f05e65..e46baeee29 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerBaseView.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerBaseView.java @@ -41,6 +41,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV protected MogoImageView ivUserHead; protected ImageView ivIcon; protected ImageView ivCar; + protected ConstraintLayout clMarkerTopView; protected IMogoMarker mMarker; public MapMarkerBaseView(Context context) { diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerView.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerView.java index 8ea5d8c389..7679c23839 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerView.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerView.java @@ -55,6 +55,7 @@ public class MapMarkerView extends MapMarkerBaseView { ivIcon = findViewById(R.id.ivIcon); ivCar = findViewById(R.id.ivCar); ivBg = findViewById(R.id.ivBg); + clMarkerTopView = findViewById(R.id.clMarkerTopView); } public void updateView(MarkerShowEntity markerShowEntity) { @@ -69,7 +70,7 @@ public class MapMarkerView extends MapMarkerBaseView { ivCar.setImageResource(R.drawable.icon_map_marker_car_gray); ivCar.setRotation((float) markerShowEntity.getMarkerLocation().getAngle()); // ivCar.setRotation(new Random().nextInt(360)); - + clMarkerTopView.setVisibility(View.GONE); if (bindObj instanceof MarkerOnlineCar) { if (((MarkerOnlineCar) bindObj).getUserInfo().getGenderValue() == 0) { ivBg.setImageResource(R.drawable.bg_map_marker_blue); 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 new file mode 100644 index 0000000000..dcba9a1ec9 --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/UserDataMarkerInfoWindowAdapter.java @@ -0,0 +1,145 @@ +package com.mogo.module.service.marker; + +import android.content.Context; +import android.os.Looper; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import com.mogo.map.marker.IMogoInfoWindowAdapter; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.module.common.entity.MarkerLocation; +import com.mogo.module.common.entity.MarkerOnlineCar; +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.service.imageloader.MogoImageView; +import com.mogo.utils.UiThreadHandler; +import com.mogo.utils.WindowUtils; +import com.mogo.utils.logger.Logger; +import com.zhidao.carchattingprovider.CallChattingProviderConstant; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author congtaowang + * @since 2020-04-27 + *

+ * 在线车辆点击后弹出的info window 样式 + */ +public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter { + + private static final String TAG = "UserDataMarkerInfoWindowAdapter"; + + private static volatile UserDataMarkerInfoWindowAdapter sInstance; + private final Context mContext; + + private View mInfoWindowView = null; + + private MogoImageView mUserHeader; + private TextView mContent; + private TextView mTag; + private ImageView mCall; + + private UserDataMarkerInfoWindowAdapter( Context context ) { + this.mContext = context; + } + + public static UserDataMarkerInfoWindowAdapter getInstance( Context context ) { + if ( sInstance == null ) { + synchronized ( UserDataMarkerInfoWindowAdapter.class ) { + if ( sInstance == null ) { + sInstance = new UserDataMarkerInfoWindowAdapter( context ); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + @Override + public View getInfoWindow( IMogoMarker marker ) { + return inflateView( marker ); + } + + private View inflateView( IMogoMarker marker ) { + if ( marker == null ) { + return null; + } + + if ( mInfoWindowView == null ) { + mInfoWindowView = LayoutInflater.from( mContext ).inflate( R.layout.view_map_data_user_info_window, null ); + mUserHeader = mInfoWindowView.findViewById( R.id.module_service_id_user_header ); + mContent = mInfoWindowView.findViewById( R.id.module_service_id_content ); + mTag = mInfoWindowView.findViewById( R.id.module_service_id_tag ); + mCall = mInfoWindowView.findViewById( R.id.module_service_id_call ); + } + + try { + MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) marker.getObject(); + mContent.setText( markerShowEntity.getTextContent() ); + loadImageHeader( markerShowEntity ); + if ( markerShowEntity.getBindObj() instanceof MarkerOnlineCar ) { + try { + mTag.setText( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getUserInfo().getSafeLabel() ); + } catch ( Exception e ) { + e.printStackTrace(); + } + } + 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 ); + } + } ); + } catch ( Exception e ) { + Logger.e( TAG, e, "error." ); + } + + return mInfoWindowView; + } + + protected void loadImageHeader( final MarkerShowEntity markerShowEntity ) { + + if ( Looper.myLooper() != Looper.getMainLooper() ) { + UiThreadHandler.post( () -> { + runOnUiThread( markerShowEntity ); + } ); + } else { + runOnUiThread( markerShowEntity ); + } + } + + private void runOnUiThread( final MarkerShowEntity markerShowEntity ) { + if ( !TextUtils.isEmpty( markerShowEntity.getIconUrl() ) ) { + MarkerServiceHandler.getImageloader().displayImage( markerShowEntity.getIconUrl(), + mUserHeader, + WindowUtils.dip2px( mContext, 50 ), WindowUtils.dip2px( mContext, 50 ), null ); + + } else { + mUserHeader.setBackgroundResource( R.drawable.icon_default_user_head ); + } + } +} diff --git a/modules/mogo-module-service/src/main/res/drawable-ldpi/module_service_ic_call.png b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_service_ic_call.png new file mode 100644 index 0000000000..89680bd182 Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-ldpi/module_service_ic_call.png differ diff --git a/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_service_ic_call.png b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_service_ic_call.png new file mode 100644 index 0000000000..3f90fd4af5 Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-xhdpi/module_service_ic_call.png differ diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_driver_blue_info.xml b/modules/mogo-module-service/src/main/res/drawable/module_services_driver_blue_info.xml new file mode 100644 index 0000000000..e71c897020 --- /dev/null +++ b/modules/mogo-module-service/src/main/res/drawable/module_services_driver_blue_info.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_blue_info.xml b/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_blue_info.xml new file mode 100644 index 0000000000..eefd1be813 --- /dev/null +++ b/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_blue_info.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_green_info.xml b/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_green_info.xml new file mode 100644 index 0000000000..d9d5e5dade --- /dev/null +++ b/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_green_info.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_red_info.xml b/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_red_info.xml new file mode 100644 index 0000000000..6c70c8805c --- /dev/null +++ b/modules/mogo-module-service/src/main/res/drawable/module_services_driver_type_red_info.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/res/layout/view_map_data_user_info_window.xml b/modules/mogo-module-service/src/main/res/layout/view_map_data_user_info_window.xml new file mode 100644 index 0000000000..5028bcbe89 --- /dev/null +++ b/modules/mogo-module-service/src/main/res/layout/view_map_data_user_info_window.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/res/layout/view_map_marker.xml b/modules/mogo-module-service/src/main/res/layout/view_map_marker.xml index b37be6dc5d..689fcee3f6 100644 --- a/modules/mogo-module-service/src/main/res/layout/view_map_marker.xml +++ b/modules/mogo-module-service/src/main/res/layout/view_map_marker.xml @@ -12,7 +12,8 @@ + android:layout_height="wrap_content" + android:id="@+id/clMarkerTopView">