完成基础的角度修改

This commit is contained in:
董宏宇
2020-12-14 18:35:49 +08:00
parent 41fc698cc6
commit 0aed6c0301
11 changed files with 188 additions and 31 deletions

View File

@@ -1,12 +0,0 @@
package com.mogo.module.small.map;
import com.mogo.service.module.IMogoModuleProvider;
/**
* @author donghongyu
* @date 12/10/20 1:36 PM
*/
public interface IMogoSmallMapProvider extends IMogoModuleProvider {
String path = "/small_map/api";
}

View File

@@ -0,0 +1,64 @@
package com.mogo.module.small.map;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.mogo.module.common.view.RoundLayout;
/**
* 小地图的方向View
*
* @author donghongyu
* @date 12/14/20 4:40 PM
*/
public class SmallMapDirectionView extends RoundLayout {
private ImageView mIvMapBorder;
public SmallMapDirectionView(Context context) {
this(context, null);
}
public SmallMapDirectionView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public SmallMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView(context);
}
private void initView(Context context) {
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
mIvMapBorder = findViewById(R.id.ivMapBorder);
}
/**
* 修改角度
*
* @param angle 角度 0 - 359度旋转,相对于自身中心位置
*/
public void changeAngle(int angle) {
Animation mRotateAnimation = new RotateAnimation(
0, angle,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
//设置线性插值,可以解决旋转一圈后卡顿问题
mRotateAnimation.setInterpolator(new DecelerateInterpolator());
//设置旋转一圈时间
mRotateAnimation.setDuration(1000);
//控件动画结束时是否保持动画最后的状态
mRotateAnimation.setFillAfter(true);
mIvMapBorder.startAnimation(mRotateAnimation);
}
}

View File

@@ -24,7 +24,7 @@ public class SmallMapService extends Service {
private IBinder mBinder;
private WindowManagerView mWindowManagerView;
private SmallMapView mMapView;
private SmallMapDirectionView mSmallMapDirectionView;
@Override
public void onCreate() {
@@ -69,20 +69,30 @@ public class SmallMapService extends Service {
private void addMachineVisionMapView() {
Logger.d(TAG, "addMachineVisionMapView");
mWindowManagerView = new WindowManagerView.Builder(getApplicationContext())
.contentView(R.layout.module_small_map_view)
.contentView(R.layout.module_small_map_direction_view)
.size(
WindowManager.LayoutParams.WRAP_CONTENT,
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_mvision_view_x),
getResources().getDimensionPixelOffset(R.dimen.module_mvision_view_y)
)
.gravity(Gravity.TOP | Gravity.LEFT)
.showInWindowManager();
mWindowManagerView.show();
mSmallMapDirectionView = mWindowManagerView.findViewById(R.id.smallMapDirectionView);
mSmallMapDirectionView.postDelayed(new Runnable() {
@Override
public void run() {
mSmallMapDirectionView.changeAngle(-60);
}
}, 1000);
}

View File

@@ -11,17 +11,23 @@ import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.map.IMogoSmallMapProvider;
import com.mogo.service.module.ModuleType;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
/**
* @author donghongyu
* @date 12/10/20 1:34 PM
*/
@Route(path = IMogoSmallMapProvider.path)
public class SmallVisionProvider implements IMogoSmallMapProvider {
@Route(path = MogoServicePaths.PATH_SMALL_MAP)
public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener {
private final String TAG = "SmallVisionProvider";
private Intent mSmallMapServiceIntent;
private Context mContext;
@Override
public Fragment createFragment(Context context, Bundle data) {
@@ -47,15 +53,55 @@ public class SmallVisionProvider implements IMogoSmallMapProvider {
@Override
public void init(Context context) {
Log.d(TAG, "小地图模块初始化……");
mSmallMapServiceIntent = new Intent(context, SmallMapService.class);
context.startService(mSmallMapServiceIntent);
mContext = context;
MogoApisHandler.getInstance()
.getApis()
.getStatusManagerApi()
.registerStatusChangedListener(
MogoServicePaths.PATH_SMALL_MAP,
StatusDescriptor.VR_MODE,
this);
}
@Override
public void onDestroy() {
Log.d(TAG, "小地图模块销毁……");
hidePanel();
}
@Override
public void showPanel() {
Log.d(TAG, "小地图模块触发展示……");
mSmallMapServiceIntent = new Intent(mContext, SmallMapService.class);
mContext.startService(mSmallMapServiceIntent);
}
@Override
public void hidePanel() {
Log.d(TAG, "小地图模块触发隐藏……");
if (mSmallMapServiceIntent != null) {
AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent);
}
}
@Override
public void changeAngle(double angle) {
}
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
Log.d(TAG, "onStatusChanged……descriptor=" + descriptor + "isTrue=" + isTrue);
if (descriptor == StatusDescriptor.VR_MODE) {
if (isTrue) {
showPanel();
} else {
hidePanel();
}
}
}
}