From e4b574c0e122ae1d4089f3b34f943903a26b122d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Wed, 23 Dec 2020 11:48:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8D=95=E8=B0=83=E6=95=B4=E5=B0=8F?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/small/map/SmallMapDirectionView.java | 14 ++++++++------ .../com/mogo/module/small/map/SmallMapService.java | 7 +++++-- .../src/main/res/layout/module_small_map_view.xml | 6 ++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java index 9e131500ea..23f444ea9c 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java @@ -7,6 +7,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.animation.LinearInterpolator; import android.widget.ImageView; +import android.widget.RelativeLayout; import androidx.annotation.Nullable; @@ -17,7 +18,6 @@ import com.amap.api.maps.UiSettings; import com.amap.api.maps.model.CameraPosition; import com.amap.api.navi.AMapNaviView; import com.amap.api.navi.AMapNaviViewOptions; -import com.mogo.module.common.view.RoundLayout; import com.mogo.module.small.map.animation.DirectionRotateAnimation; import com.mogo.utils.FileUtils; @@ -30,11 +30,11 @@ import java.io.IOException; * @author donghongyu * @date 12/14/20 4:40 PM */ -public class SmallMapDirectionView extends RoundLayout { +public class SmallMapDirectionView extends RelativeLayout { + private String styleFilePath = "/mnt/sdcard/amap/small_map_style.data"; private ImageView mIvMapBorder; private AMapNaviView mAMapNaviView; - private DirectionRotateAnimation mRotateAnimation; private int lastAngle = 0; @@ -48,12 +48,14 @@ public class SmallMapDirectionView extends RoundLayout { public SmallMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - initView(context); + try { + initView(context); + } catch (Exception e) { + e.printStackTrace(); + } } private void initView(Context context) { - String styleFilePath = "/mnt/sdcard/amap/small_map_style.data"; - mRotateAnimation = new DirectionRotateAnimation(context, null); LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this); 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 4a8a3c0fbe..1b566a3a78 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 @@ -72,8 +72,12 @@ public class SmallMapService extends Service { */ private void addSmallMapView() { Logger.d(TAG, "addSmallMapView"); + + // 初始化小地图控件 + mSmallMapDirectionView = new SmallMapDirectionView(getApplicationContext()); + mWindowManagerView = new WindowManagerView.Builder(getApplicationContext()) - .contentView(R.layout.module_small_map_direction_view) + .contentView(mSmallMapDirectionView) .size( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT @@ -85,7 +89,6 @@ public class SmallMapService extends Service { .gravity(Gravity.TOP | Gravity.LEFT) .showInWindowManager(); mWindowManagerView.show(); - mSmallMapDirectionView = mWindowManagerView.findViewById(R.id.smallMapDirectionView); } 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 d86de24931..dd0630dcfc 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,8 +1,10 @@ - @@ -33,4 +35,4 @@ android:layout_centerInParent="true" android:src="@drawable/module_small_map_view_border" /> - \ No newline at end of file + \ No newline at end of file