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