From 7da4d64630b0e63997e07ea2c041c4ffbc994516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Mon, 14 Dec 2020 21:06:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E8=87=AA=E7=A0=94?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=A1=AB=E5=85=85=E5=B0=8F=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E6=98=AF=E5=9C=86=E5=BD=A2=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/codeStyles/Project.xml | 15 ++++- .../small/map/SmallMapDelegateFactory.java | 66 +++++++++++++++++++ .../module/small/map/SmallMapService.java | 4 +- .../mogo/module/small/map/SmallMapView.java | 51 ++++++++++++++ .../main/res/layout/module_small_map_view.xml | 27 ++++++-- .../src/main/res/values-xhdpi/dimens.xml | 19 +++--- 6 files changed, 163 insertions(+), 19 deletions(-) create mode 100644 modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDelegateFactory.java diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 663459aa50..0d156937bb 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -3,9 +3,18 @@ + diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDelegateFactory.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDelegateFactory.java new file mode 100644 index 0000000000..962be7d52f --- /dev/null +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDelegateFactory.java @@ -0,0 +1,66 @@ +package com.mogo.module.small.map; + +import android.content.Context; + +import com.alibaba.android.arouter.launcher.ARouter; +import com.mogo.commons.debug.DebugConfig; +import com.mogo.map.IMogoMapApiBuilder; +import com.mogo.map.IMogoMapView; +import com.mogo.map.impl.automap.navi.AutoNaviClient; +import com.mogo.map.location.IMogoLocationClient; +import com.mogo.map.navi.IMogoAimless; +import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.search.drive.IMogoRoadSearch; +import com.mogo.map.search.geo.IMogoGeoSearch; +import com.mogo.map.search.inputtips.IMogoInputtipsSearch; +import com.mogo.map.search.inputtips.query.MogoInputtipsQuery; +import com.mogo.map.search.poisearch.IMogoPoiSearch; +import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery; +import com.mogo.map.search.traffic.IMogoTrafficSearch; +import com.mogo.map.uicontroller.IMogoMapUIController; +import com.mogo.utils.AppUtils; + +/** + * @author donghongyu + * @since 2020/12/14 + *

+ * 描述 + */ +class SmallMapDelegateFactory { + + private static final String TAG = "MogoMapDelegateFactory"; + + private static IMogoMapApiBuilder sApiBuilder; + + private static IMogoMapApiBuilder getApiBuilder() { + if ( sApiBuilder == null ) { + synchronized ( SmallMapDelegateFactory.class ) { + if ( sApiBuilder == null ) { + sApiBuilder = ARouter.getInstance().navigation( IMogoMapApiBuilder.class ); + } + } + } + return sApiBuilder; + } + + + public static IMogoAimless getAimless( Context context ) { + return getApiBuilder().getAimless( context ); + } + + public static void createMapViewInstance( Context context ) { + getApiBuilder().createMapView( context ); + } + + public static void destroy() { + getApiBuilder().destroy(); + } + + public static IMogoMapView getMapView(Context context ) { + return getApiBuilder().getMapView( context ); + } + + public static IMogoTrafficSearch getTrafficSearch() { + return getApiBuilder().getTrafficSearch(); + } +} diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java index de26ba6776..bdf5c46fa9 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java @@ -79,8 +79,8 @@ public class SmallMapService extends Service { WindowManager.LayoutParams.WRAP_CONTENT ) .position( - getResources().getDimensionPixelOffset(R.dimen.module_mvision_view_x), - getResources().getDimensionPixelOffset(R.dimen.module_mvision_view_y) + getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_x), + getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_y) ) .gravity(Gravity.TOP | Gravity.LEFT) .showInWindowManager(); diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java index 62e75cdc07..139eb28c22 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java @@ -1,7 +1,11 @@ package com.mogo.module.small.map; import android.content.Context; +import android.os.Bundle; import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; import androidx.annotation.Nullable; @@ -31,5 +35,52 @@ public class SmallMapView extends MogoBaseMapView { @Override protected void addMapView(Context context) { Logger.d(TAG, "addMapView"); + mMapView = SmallMapDelegateFactory.getMapView(context); + if (mMapView != null) { + final View mapView = mMapView.getMapView(); + if (mapView != null) { + addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + } else { + Logger.e(TAG, "create MapView instance failed."); + } + } else { + Logger.e(TAG, "create IMogoMapView instance failed."); + } } + + + @Override + public void onCreate( Bundle bundle ) { + super.onCreate( bundle ); + Logger.d( TAG, "onCreate" ); + } + + @Override + public void onResume() { + super.onResume(); + Logger.d( TAG, "onResume" ); + } + + @Override + public void onPause() { + super.onPause(); + Logger.d( TAG, "onPause" ); + } + + @Override + public void onDestroy() { + super.onDestroy(); + Logger.d( TAG, "onDestroy" ); + } + + @Override + public void onSaveInstanceState( Bundle outState ) { + super.onSaveInstanceState( outState ); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + } + } \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml index e5d1dbfe79..346805d461 100644 --- a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml +++ b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml @@ -1,16 +1,31 @@ + + + + + + - \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml index 9910274622..41d38e65b4 100644 --- a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml @@ -1,12 +1,15 @@ - 400px - 400px - 1490px - 650px + 400px + 400px - 0px - 0px - 1920px - 1080px + 300px + 300px + 1490px + 650px + + 0px + 0px + 1920px + 1080px \ No newline at end of file