diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java index d459d17428..20095d285f 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java @@ -9,7 +9,9 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.location.Location; import android.os.Bundle; +import android.os.Handler; import android.os.Looper; +import android.os.Message; import android.os.SystemClock; import android.os.Trace; import android.view.LayoutInflater; @@ -85,7 +87,8 @@ public class AMapNaviViewWrapper implements IMogoMapView, AMapNaviViewListener, AMapMessageListener, AMap.OnCameraChangeListener, - AMap.OnMyLocationChangeListener { + AMap.OnMyLocationChangeListener, + Handler.Callback{ private static final String TAG = "AMapNaviViewWrapper"; @@ -568,6 +571,14 @@ public class AMapNaviViewWrapper implements IMogoMapView, } } + private boolean isInEmphasizeAnim = false; + + @Override + public void emphasizeMyLocation() { + isInEmphasizeAnim = true; + setCarCursorOption(null); + } + @Override public void showMyLocation( View view ) { if ( NaviClient.getInstance( getContext() ).isNaviing() ) { @@ -936,9 +947,11 @@ public class AMapNaviViewWrapper implements IMogoMapView, "MY_LOCATION_CONFIG", ""); if (myLocationConfigCache == null || !myLocationConfigCache.equals(myLocationConfig)) { // 内存缓存的地址为空,或者内存缓存的地址和sp保存的config不一致,那得重新获取bitmap - myLocationConfigCache = myLocationConfig; loadMyLocationIcon(myLocationConfig); + } else if (isInEmphasizeAnim) { + DEFAULT_OPTION.setCarCursorBmp(inflateMyLocation(myLocationBitmap)); } + } @Override @@ -1043,6 +1056,8 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition< ? super Bitmap > transition ) { if (isUseDefaultOption) { + myLocationConfigCache = url; + myLocationBitmap = resource; DEFAULT_OPTION.setCarCursorBmp(inflateMyLocation(resource)); setCarCursorOption(null); } @@ -1063,11 +1078,50 @@ public class AMapNaviViewWrapper implements IMogoMapView, } } + private float emphasizeAnimOffset = 1f; + private Bitmap inflateMyLocation(Bitmap res) { + if (res == null) { + throw new IllegalArgumentException("inflate myLocation bitmap can not be null!"); + } View root = LayoutInflater.from(getContext()).inflate(R.layout.module_map_amap_my_location, null, false); ImageView iv = root.findViewById(R.id.module_map_amap_my_location_iv); iv.setImageBitmap(res); + if (isInEmphasizeAnim) { + iv.setScaleX(emphasizeAnimOffset); + iv.setScaleY(emphasizeAnimOffset); + handler.sendEmptyMessageDelayed(MSG_CONTINUE_EMPHASIZE_ANIM, EMPHASIZE_ANIM_DELAY); + } return BitmapDescriptorFactory.fromView(root).getBitmap(); } + + /** + * 目前仅用于强调动画 + */ + private Handler handler = new Handler(this); + private static final int MSG_CONTINUE_EMPHASIZE_ANIM = 1001; + private static final long EMPHASIZE_ANIM_DELAY = 80; + private int emphasizeAnimProgress = 0; + private Bitmap myLocationBitmap; + + @Override + public boolean handleMessage(Message msg) { + if (msg.what == MSG_CONTINUE_EMPHASIZE_ANIM) { + if (emphasizeAnimProgress < 5) { + emphasizeAnimOffset += 0.1; + emphasizeAnimProgress++; + }else if(emphasizeAnimProgress<10){ + emphasizeAnimOffset -= 0.1; + emphasizeAnimProgress++; + } else if (emphasizeAnimProgress == 10) { + isInEmphasizeAnim = false; + emphasizeAnimProgress = 0; + emphasizeAnimOffset = 1; + } + setCarCursorOption(null); + return true; + } + return false; + } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java index f081517786..6beedf3fc1 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java @@ -426,6 +426,11 @@ public class AMapViewWrapper implements IMogoMapView, } } + @Override + public void emphasizeMyLocation() { + // 空实现 + } + @Override public void showMyLocation( View view ) { if ( NaviClient.getInstance( getContext() ).isNaviing() ) { diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java index 113abe60f0..68a8f2fd5d 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java @@ -99,6 +99,13 @@ public class AMapUIController implements IMogoMapUIController { } } + @Override + public void emphasizeMyLocation() { + if ( mClient != null ) { + mClient.emphasizeMyLocation(); + } + } + @Override public void showMyLocation( View view ) { if ( mClient != null ) { diff --git a/libraries/map-amap/src/main/res/drawable-xhdpi/module_map_amap_my_location_icon.png b/libraries/map-amap/src/main/res/drawable-xhdpi/module_map_amap_my_location_icon.png new file mode 100644 index 0000000000..b71e0a3b1d Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable-xhdpi/module_map_amap_my_location_icon.png differ diff --git a/libraries/map-amap/src/main/res/layout/module_map_amap_my_location.xml b/libraries/map-amap/src/main/res/layout/module_map_amap_my_location.xml index 2035f69746..690f7b6c48 100644 --- a/libraries/map-amap/src/main/res/layout/module_map_amap_my_location.xml +++ b/libraries/map-amap/src/main/res/layout/module_map_amap_my_location.xml @@ -1,9 +1,15 @@ - + + android:layout_width="@dimen/module_map_amap_my_location_icon_width" + android:layout_height="@dimen/module_map_amap_my_location_icon_height" + android:layout_gravity="center" + android:src="@drawable/module_map_amap_my_location_icon"/> \ No newline at end of file diff --git a/libraries/map-amap/src/main/res/values-xhdpi/dimens.xml b/libraries/map-amap/src/main/res/values-xhdpi/dimens.xml index 7e2a7bc299..9c08d26451 100644 --- a/libraries/map-amap/src/main/res/values-xhdpi/dimens.xml +++ b/libraries/map-amap/src/main/res/values-xhdpi/dimens.xml @@ -1,4 +1,6 @@ - 370px + 370px + 78px + 120px \ No newline at end of file diff --git a/libraries/map-amap/src/main/res/values/dimens.xml b/libraries/map-amap/src/main/res/values/dimens.xml index 9e52b0f936..6898799649 100644 --- a/libraries/map-amap/src/main/res/values/dimens.xml +++ b/libraries/map-amap/src/main/res/values/dimens.xml @@ -1,5 +1,7 @@ 60px - 146px + 78px + 120px + 146px \ No newline at end of file diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java index 419f4cc00a..6cfa109ab9 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java @@ -71,6 +71,11 @@ public interface IMogoMapUIController { */ void showMyLocation( View view ); + /** + * 强调自车位置,加个动画突显一下自车位置 + */ + void emphasizeMyLocation(); + /** * 以外部定位的方式改变当前位置 * diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java index f4642f2440..8ba96d4333 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java @@ -92,6 +92,13 @@ public class MogoMapUIController implements IMogoMapUIController { } } + @Override + public void emphasizeMyLocation() { + if ( mDelegate != null ) { + mDelegate.emphasizeMyLocation(); + } + } + @Override public void showMyLocation( View view ) { if ( mDelegate != null ) { diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java index a01330099d..52e86d3716 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java @@ -832,50 +832,62 @@ public class EntranceFragment extends MvpFragment { - if (!toggle) { - TopViewAnimHelper.getInstance().showNaviView(); - } else { - TopViewAnimHelper.getInstance().hideNaviView(); - } - toggle = !toggle; + SharedPrefsMgr.getInstance(getContext()).putString("MY_LOCATION_CONFIG", "https" + + "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705236512" + + "&di=50620661ded7035fb84899a408f9f27e&imgtype=0&src=http%3A%2F%2Fb-ssl" + + ".duitang.com%2Fuploads%2Fitem%2F201409%2F11%2F20140911211243_3rT4u.jpeg"); + MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().setCarCursorOption(null); +// if (!toggle) { +// TopViewAnimHelper.getInstance().showNaviView(); +// } else { +// TopViewAnimHelper.getInstance().hideNaviView(); +// } +// toggle = !toggle; }); findViewById(R.id.btnDebugCtrlSubView).setOnClickListener(view -> { - View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null); - TextView tv = v.findViewById(R.id.tvIndex); - tv.setText("sub view height: " + currentHeight + ": " + v); - mApis.getTopViewManager().addSubView(v, new IMogoTopViewStatusListener() { - @Override - public void onViewAdded(View view) { - Logger.d(TAG, "onSubViewAdded: " + view); - } - - @Override - public void onViewRemoved(View view) { - Logger.d(TAG, "onSubViewRemoved: " + view); - } - - @Override - public void beforeViewAddAnim(View view) { - Logger.d(TAG, "beforeSubViewAddAnim: " + view); - } - - @Override - public void beforeViewRemoveAnim(View view) { - Logger.d(TAG, "beforeSubViewRemoveAnim: " + view); - } - }); + MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().emphasizeMyLocation(); +// View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null); +// TextView tv = v.findViewById(R.id.tvIndex); +// tv.setText("sub view height: " + currentHeight + ": " + v); +// mApis.getTopViewManager().addSubView(v, new IMogoTopViewStatusListener() { +// @Override +// public void onViewAdded(View view) { +// Logger.d(TAG, "onSubViewAdded: " + view); +// } +// +// @Override +// public void onViewRemoved(View view) { +// Logger.d(TAG, "onSubViewRemoved: " + view); +// } +// +// @Override +// public void beforeViewAddAnim(View view) { +// Logger.d(TAG, "beforeSubViewAddAnim: " + view); +// } +// +// @Override +// public void beforeViewRemoveAnim(View view) { +// Logger.d(TAG, "beforeSubViewRemoveAnim: " + view); +// } +// }); }); findViewById(R.id.btnDebugCtrlTopView).setOnClickListener(view -> { - View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null); - TextView tv = v.findViewById(R.id.tvIndex); - Random random = new Random(); - currentHeight = heights[random.nextInt(3)]; - tv.setText(" height: " + currentHeight + ": " + v); - ViewGroup.LayoutParams params = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, currentHeight); - mApis.getEntranceButtonController().addLeftFeatureView(v); + SharedPrefsMgr.getInstance(getContext()).putString("MY_LOCATION_CONFIG", "https" + + "://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605705508574" + + "&di=339d3259ad21f5f48c8abcd1bafff324&imgtype=0&src=http%3A%2F%2Fc-ssl" + + ".duitang.com%2Fuploads%2Fitem%2F202004%2F23%2F20200423111550_4AJLr.thumb" + + ".1000_0.jpeg"); + MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().emphasizeMyLocation(); +// View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null); +// TextView tv = v.findViewById(R.id.tvIndex); +// Random random = new Random(); +// currentHeight = heights[random.nextInt(3)]; +// tv.setText(" height: " + currentHeight + ": " + v); +// ViewGroup.LayoutParams params = +// new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, currentHeight); +// mApis.getEntranceButtonController().addLeftFeatureView(v); // mApis.getTopViewManager().addView(v, params, new IMogoTopViewStatusListener() { // @Override