add dispatch remind dialog and UI changes
This commit is contained in:
@@ -3,15 +3,21 @@ package com.mogo.module.adas;
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.module.adas.entity.AdasAutoPilotLocReceiverBean;
|
||||
import com.mogo.module.adas.view.DispatchRemindDialog;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilotLocReceiverBean> {
|
||||
//todo 自动驾驶车辆状态上报,路线上报,监听自动驾驶状态,结束置空 autoPilotLocReceiverBean
|
||||
public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilotLocReceiverBean>, DispatchRemindDialog.IDispatchRemindClickListener {
|
||||
|
||||
private static final String TAG = "AdasAutoPilotManager";
|
||||
private static volatile AdasAutoPilotManager instance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
private static final int MSG_SOCKET_TYPE = 1;
|
||||
private Context mContext;
|
||||
private DispatchRemindDialog dispatchRemindDialog;
|
||||
private AdasAutoPilotLocReceiverBean autoPilotLocReceiverBean;
|
||||
|
||||
private AdasAutoPilotManager() {
|
||||
|
||||
@@ -33,6 +39,8 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getSocketManagerApi(mContext).registerOnMessageListener(MSG_SOCKET_TYPE, this);
|
||||
dispatchRemindDialog = new DispatchRemindDialog(context);
|
||||
dispatchRemindDialog.addIDispatchRemindListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +53,24 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
if (adasAutoPilotLocReceiverBean != null
|
||||
&& adasAutoPilotLocReceiverBean.getLat() != 0.0
|
||||
&& adasAutoPilotLocReceiverBean.getLon() != 0.0) {
|
||||
|
||||
if (this.autoPilotLocReceiverBean != null) {
|
||||
Logger.d(TAG, "onMsgReceived 上次下发调度还未确认完");
|
||||
return;
|
||||
}
|
||||
this.autoPilotLocReceiverBean = adasAutoPilotLocReceiverBean;
|
||||
dispatchRemindDialog.show(adasAutoPilotLocReceiverBean.getPoiAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void affirm() {
|
||||
//todo 网络请求
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
//todo 网络请求
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,88 @@
|
||||
package com.mogo.module.adas.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.module.adas.R;
|
||||
import com.mogo.module.common.dialog.BaseFloatDialog;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
|
||||
public class DispatchRemindDialog extends BaseFloatDialog {
|
||||
|
||||
private static final String TAG = "DispatchRemindDialog";
|
||||
private static final int MSG_TYPE_TIMER = 0;
|
||||
private static int TIMER = 10;
|
||||
private IDispatchRemindClickListener mListener;
|
||||
|
||||
private TextView tvTimer;
|
||||
private TextView tvLoc;
|
||||
private TextView tvAffirm;
|
||||
private TextView tvCancel;
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_TYPE_TIMER) {
|
||||
if (TIMER >= 0) {
|
||||
TIMER--;
|
||||
tvTimer.setText(TIMER);
|
||||
handler.sendEmptyMessage(MSG_TYPE_TIMER);
|
||||
} else {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public DispatchRemindDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
setContentView(R.layout.dialog_adas_dispatch_remind);
|
||||
tvTimer = findViewById(R.id.module_adas_dispatch_remind_timer);
|
||||
tvLoc = findViewById(R.id.module_adas_dispatch_remind_loc);
|
||||
tvAffirm = findViewById(R.id.module_adas_dispatch_remind_affirm);
|
||||
tvCancel = findViewById(R.id.module_adas_dispatch_remind_cancel);
|
||||
tvTimer.setText(TIMER);
|
||||
tvAffirm.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.affirm();
|
||||
}
|
||||
});
|
||||
tvCancel.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void show(String locContent) {
|
||||
show();
|
||||
handler.sendEmptyMessage(MSG_TYPE_TIMER);
|
||||
tvLoc.setText(locContent);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
dismiss();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
public void addIDispatchRemindListener(IDispatchRemindClickListener listener) {
|
||||
if (listener != null) {
|
||||
Logger.d(TAG, "addIDispatchRemindListener has listener");
|
||||
return;
|
||||
}
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
public interface IDispatchRemindClickListener {
|
||||
|
||||
void affirm();
|
||||
|
||||
void cancel();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user