预警弹框显示和默认3s消失

This commit is contained in:
liujing
2021-03-26 15:11:20 +08:00
parent ed9a5c2e37
commit f7a2d16bda
4 changed files with 121 additions and 10 deletions

View File

@@ -105,6 +105,7 @@ public class MogoApplication extends AbsMogoApplication {
// 小地图模块 // 小地图模块
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SMALL_MAP, "IMogoSmallMapProvider" ) ); MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SMALL_MAP, "IMogoSmallMapProvider" ) );
//前方碰撞预警
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_V2X_FRONT_CRASH_WARNING, "IV2XManagerProvider" ) ); MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_V2X_FRONT_CRASH_WARNING, "IV2XManagerProvider" ) );
MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_GLOBAL_UNWAKE, "GlobalUnwake" ) ); MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_GLOBAL_UNWAKE, "GlobalUnwake" ) );

View File

@@ -3,47 +3,86 @@ package com.mogo.module.v2x.scenario.scene.warning;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.V2XMessageEntity; import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.service.MarkerServiceHandler; import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.MogoServices; import com.mogo.module.service.MogoServices;
import com.mogo.module.service.receiver.MogoReceiver; import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario; import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
import com.mogo.module.v2x.utils.ADASUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.MogoServicePaths; import com.mogo.service.MogoServicePaths;
import com.mogo.service.impl.MogoServiceApis; import com.mogo.service.impl.MogoServiceApis;
import com.mogo.service.impl.v2x.V2XManager; import com.mogo.service.impl.v2x.V2XManager;
import com.mogo.service.v2x.IV2XListener; import com.mogo.service.v2x.IV2XListener;
import com.mogo.service.v2x.IV2XProvider; import com.mogo.service.v2x.IV2XProvider;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
import java.util.List;
/** /**
* @author liujing * @author liujing
* @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警 * @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警
* @since: 2021/3/24 * @since: 2021/3/24
*/ */
public class V2XFrontWarningScenario extends AbsV2XScenario { public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener {
private int type; private int type;
private IV2XListener mIV2XListener; private IV2XListener mIV2XListener;
private List<V2XSpecialCarRes.V2XMarkerEntity> mMarkerEntity;
private V2XPushMessageEntity mV2XPushMessageEntity;
public V2XFrontWarningScenario() {
setV2XWindow(new V2XWarningWindow());
}
@Override @Override
public void init(@Nullable V2XMessageEntity v2XMessageEntity) { public void init(@Nullable V2XMessageEntity v2XMessageEntity) {
type = v2XMessageEntity.getType(); type = v2XMessageEntity.getType();
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithType(type, MogoReceiver.ACTION_V2X_FRONT_WARNING); MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithType(type, MogoReceiver.ACTION_V2X_FRONT_WARNING);
try {
if (V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
if (getV2XMessageEntity() != null &&
!V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpWindowShow()) {
show();
}
}
} catch (Exception e) {
e.printStackTrace();
}
show(); show();
} }
@Override @Override
public void show() { public void show() {
showWindow(); showWindow();
Log.d(TAG, "show");
} }
@Override @Override
public void showWindow() { public void showWindow() {
// if (getV2XWindow() != null && mMarkerEntity != null) {
View view = getV2XWindow().getView();
//Logger.d(MODULE_NAME, "添加window= " + view);
ViewGroup.LayoutParams layoutParams =
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_fatigue_driving_window_height_ground));
V2XServiceManager
.getMogoTopViewManager()
.addView(getV2XWindow().getView(), layoutParams, this);
getV2XWindow().show(mV2XPushMessageEntity);
// }
} }
@Override @Override
@@ -71,4 +110,23 @@ public class V2XFrontWarningScenario extends AbsV2XScenario {
} }
@Override
public void onViewAdded(View view) {
}
@Override
public void onViewRemoved(View view) {
}
@Override
public void beforeViewAddAnim(View view) {
}
@Override
public void beforeViewRemoveAnim(View view) {
}
} }

View File

@@ -1,12 +1,19 @@
package com.mogo.module.v2x.scenario.scene.warning; package com.mogo.module.v2x.scenario.scene.warning;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.listener.V2XWindowStatusListener; import com.mogo.module.v2x.listener.V2XWindowStatusListener;
import com.mogo.module.v2x.scenario.scene.V2XBasWindow; import com.mogo.module.v2x.scenario.scene.V2XBasWindow;
import com.mogo.module.v2x.scenario.view.IV2XWindow; import com.mogo.module.v2x.scenario.view.IV2XWindow;
import com.mogo.utils.logger.Logger;
/** /**
* @author liujing * @author liujing
@@ -15,12 +22,23 @@ import com.mogo.module.v2x.scenario.view.IV2XWindow;
*/ */
public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow { public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
public V2XWarningWindow(Context context) { private ImageView typeImage;
super(context); private TextView warningTextView;
private TextView distance;
//倒计时3s弹框取消
private static Handler handlerV2XEvent = new Handler();
private static Runnable runnableV2XEvent;
private static final int COUNT_DOWN_TIMER = 1_000;
private static final int ALL_EXPIRE_TIMER = 3_000;
private static int EXPIRE_TIMER = ALL_EXPIRE_TIMER;
public V2XWarningWindow() {
this(V2XServiceManager.getContext(), null);
} }
public V2XWarningWindow(Context context, AttributeSet attrs) { public V2XWarningWindow(Context context, AttributeSet attrs) {
super(context, attrs); this(context, attrs, 0);
} }
public V2XWarningWindow(Context context, AttributeSet attrs, int defStyleAttr) { public V2XWarningWindow(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -29,26 +47,58 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
} }
private void initView(Context context) { private void initView(Context context) {
LayoutInflater.from(context).inflate(R.layout.v2x_road_front_warning_vr, this);
typeImage = findViewById(R.id.warning_type_image);
warningTextView = findViewById(R.id.warning_content_text);
distance = findViewById(R.id.warning_distance);
} }
@Override @Override
public void show(Object entity) { public void show(Object entity) {
if (entity != null) {
}
if (runnableV2XEvent == null) {
runnableV2XEvent = () -> {
EXPIRE_TIMER = EXPIRE_TIMER - COUNT_DOWN_TIMER;
if (EXPIRE_TIMER > 0) {
handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
} else {
stopCountDown();
}
};
} else {
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
}
handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
} }
@Override @Override
public void close() { public void close() {
stopCountDown();
} }
@Override @Override
public View getView() { public View getView() {
return null; return this;
} }
@Override @Override
public void setWindowStatusListener(V2XWindowStatusListener listener) { public void setWindowStatusListener(V2XWindowStatusListener listener) {
} }
private void stopCountDown() {
if (handlerV2XEvent != null && runnableV2XEvent != null) {
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
runnableV2XEvent = null;
EXPIRE_TIMER = ALL_EXPIRE_TIMER;
}
//移除窗体
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
} }

View File

@@ -2,7 +2,9 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_470" android:layout_width="@dimen/dp_470"
android:layout_height="@dimen/dp_140" android:layout_height="@dimen/dp_140"
android:background="@drawable/v2x_front_warning_bg"> android:layout_marginLeft="@dimen/dp_190"
android:background="@drawable/v2x_front_warning_bg"
android:layout_marginTop="@dimen/dp_20">
<ImageView <ImageView
android:id="@+id/warning_type_image" android:id="@+id/warning_type_image"