增加测试按钮
This commit is contained in:
@@ -14,9 +14,9 @@ import com.mogo.och.bus.bean.OchBusStation;
|
|||||||
import com.mogo.och.bus.constant.OchBusConst;
|
import com.mogo.och.bus.constant.OchBusConst;
|
||||||
import com.mogo.och.bus.presenter.OchBusPresenter;
|
import com.mogo.och.bus.presenter.OchBusPresenter;
|
||||||
import com.mogo.och.view.SlidePanelView;
|
import com.mogo.och.view.SlidePanelView;
|
||||||
|
import com.mogo.service.adas.IMogoAdasOCHCallback;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@@ -44,6 +44,22 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
|
|||||||
adapter = new OchBusStationAdapter(getContext());
|
adapter = new OchBusStationAdapter(getContext());
|
||||||
rvStationList.setAdapter(adapter);
|
rvStationList.setAdapter(adapter);
|
||||||
rvStationList.setLayoutManager(new LinearLayoutManager(getContext()));
|
rvStationList.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
|
switch (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus()) {
|
||||||
|
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE:
|
||||||
|
hideAutopilotBiz();
|
||||||
|
break;
|
||||||
|
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE:
|
||||||
|
showAutopilotBiz();
|
||||||
|
onAutopilotStatusChanged(false);
|
||||||
|
break;
|
||||||
|
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING:
|
||||||
|
showAutopilotBiz();
|
||||||
|
onAutopilotStatusChanged(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -112,15 +128,15 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo smoothMove
|
// todo smoothMove
|
||||||
int moveTo = currPos +1;
|
int moveTo = currPos + 1;
|
||||||
if (currPos < 3) {
|
if (currPos < 3) {
|
||||||
moveTo = 0;
|
moveTo = 0;
|
||||||
}
|
}
|
||||||
if (currPos >= stationList.size() - 3) {
|
if (currPos >= stationList.size() - 3) {
|
||||||
moveTo = stationList.size()-1;
|
moveTo = stationList.size() - 1;
|
||||||
}
|
}
|
||||||
if (moveTo >= stationList.size()) {
|
if (moveTo >= stationList.size()) {
|
||||||
moveTo = stationList.size()-1;
|
moveTo = stationList.size() - 1;
|
||||||
}
|
}
|
||||||
rvStationList.smoothScrollToPosition(moveTo);
|
rvStationList.smoothScrollToPosition(moveTo);
|
||||||
}
|
}
|
||||||
@@ -154,15 +170,15 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveToEnd() {
|
public void moveToEnd() {
|
||||||
hideNotice();
|
|
||||||
mPresenter.autoDriveToNextStation();
|
mPresenter.autoDriveToNextStation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAutopilotEnableChange(boolean isEnable) {
|
public void onAutopilotEnableChange(boolean isEnable) {
|
||||||
if (isEnable) {
|
if (isEnable) {
|
||||||
showAutopilotBiz();
|
showAutopilotBiz();
|
||||||
}else{
|
} else {
|
||||||
hideAutopilotBiz();
|
hideAutopilotBiz();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,30 +128,6 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
|||||||
currentAutopilot.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(nextStation.getLat(), nextStation.getLon());
|
currentAutopilot.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(nextStation.getLat(), nextStation.getLon());
|
||||||
currentAutopilot.vehicleType = VEHICAL_TYPE;
|
currentAutopilot.vehicleType = VEHICAL_TYPE;
|
||||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().aiCloudToAdasData(currentAutopilot);
|
MogoApisHandler.getInstance().getApis().getAdasControllerApi().aiCloudToAdasData(currentAutopilot);
|
||||||
|
|
||||||
RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), currentStation.getSiteId())));
|
|
||||||
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
|
||||||
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
|
|
||||||
.leaveStation(request).subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
|
||||||
@Override
|
|
||||||
public void onError(String message, int code) {
|
|
||||||
super.onError(message, code);
|
|
||||||
Logger.d(TAG, "leave station error: " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
super.onError(e);
|
|
||||||
Logger.e(TAG,e,"leave station exception");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (mView != null) {
|
|
||||||
mView.refreshBusStations(stationList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshCurrentStation() {
|
private void refreshCurrentStation() {
|
||||||
@@ -200,6 +176,31 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
|||||||
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING:
|
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING:
|
||||||
mView.onAutopilotEnableChange(true);
|
mView.onAutopilotEnableChange(true);
|
||||||
mView.onAutopilotStatusChanged(true);
|
mView.onAutopilotStatusChanged(true);
|
||||||
|
mView.hideSlidePanel();
|
||||||
|
mView.hideNotice();
|
||||||
|
RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), stationList.get(currentStationIndex).getSiteId())));
|
||||||
|
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
||||||
|
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
|
||||||
|
.leaveStation(request).subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||||
|
@Override
|
||||||
|
public void onError(String message, int code) {
|
||||||
|
super.onError(message, code);
|
||||||
|
Logger.d(TAG, "leave station error: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
super.onError(e);
|
||||||
|
Logger.e(TAG,e,"leave station exception");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (mView != null) {
|
||||||
|
mView.refreshBusStations(stationList);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mView.onAutopilotEnableChange(false);
|
mView.onAutopilotEnableChange(false);
|
||||||
|
|||||||
@@ -60,14 +60,23 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
|
|||||||
@Override
|
@Override
|
||||||
public void onClickImpl(View v) {
|
public void onClickImpl(View v) {
|
||||||
// 如果能自动驾驶,就自动驾驶,不能就提示
|
// 如果能自动驾驶,就自动驾驶,不能就提示
|
||||||
if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() != IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) {
|
// if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() != IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) {
|
||||||
restartAutopilot();
|
// restartAutopilot();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
checkCallView(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isCallViewShow());
|
checkCallView(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isCallViewShow());
|
||||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("Och", StatusDescriptor.CALL_VIEW, callViewListener);
|
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("Och", StatusDescriptor.CALL_VIEW, callViewListener);
|
||||||
|
|
||||||
|
findViewById(R.id.btnAutopilotDisable).setOnClickListener(view-> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE, "不能使用"));
|
||||||
|
|
||||||
|
findViewById(R.id.btnAutopilotEnable).setOnClickListener(view-> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE, "能使用"));
|
||||||
|
|
||||||
|
findViewById(R.id.btnAutopilotRunning).setOnClickListener(view -> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING, "Running"));
|
||||||
|
|
||||||
|
findViewById(R.id.btnAutopilotArrive).setOnClickListener(view -> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(-1, "Running"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCallView(boolean isShown) {
|
private void checkCallView(boolean isShown) {
|
||||||
@@ -82,25 +91,33 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showSlidePanle(String text) {
|
public void showSlidePanle(String text) {
|
||||||
slidePanelView.setText(text);
|
getActivity().runOnUiThread(()->{
|
||||||
slidePanelView.setVisibility(View.VISIBLE);
|
slidePanelView.setText(text);
|
||||||
|
slidePanelView.setVisibility(View.VISIBLE);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideSlidePanel() {
|
public void hideSlidePanel() {
|
||||||
slidePanelView.setVisibility(View.GONE);
|
getActivity().runOnUiThread(()->{
|
||||||
|
slidePanelView.setVisibility(View.GONE);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showNotice(String notice) {
|
public void showNotice(String notice) {
|
||||||
tvNotice.setText(notice);
|
getActivity().runOnUiThread(()->{
|
||||||
tvNotice.setVisibility(View.VISIBLE);
|
tvNotice.setText(notice);
|
||||||
fivNoticeHead.setVisibility(View.VISIBLE);
|
tvNotice.setVisibility(View.VISIBLE);
|
||||||
fivNoticeHead.startAnim();
|
fivNoticeHead.setVisibility(View.VISIBLE);
|
||||||
|
fivNoticeHead.startAnim();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideNotice() {
|
public void hideNotice() {
|
||||||
tvNotice.setVisibility(View.GONE);
|
getActivity().runOnUiThread(()->{
|
||||||
fivNoticeHead.setVisibility(View.GONE);
|
tvNotice.setVisibility(View.GONE);
|
||||||
fivNoticeHead.stopAnim();
|
fivNoticeHead.setVisibility(View.GONE);
|
||||||
|
fivNoticeHead.stopAnim();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,17 +126,23 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
|
|||||||
* @param isInAutopilot true - 在自动驾驶中 false - 不在自动驾驶中
|
* @param isInAutopilot true - 在自动驾驶中 false - 不在自动驾驶中
|
||||||
*/
|
*/
|
||||||
public void onAutopilotStatusChanged(boolean isInAutopilot) {
|
public void onAutopilotStatusChanged(boolean isInAutopilot) {
|
||||||
ctvAutopilotStatus.setChecked(isInAutopilot);
|
getActivity().runOnUiThread(()->{
|
||||||
|
ctvAutopilotStatus.setChecked(isInAutopilot);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideAutopilotBiz() {
|
public void hideAutopilotBiz() {
|
||||||
ctvAutopilotStatus.setVisibility(View.GONE);
|
getActivity().runOnUiThread(()->{
|
||||||
slidePanelView.setVisibility(View.GONE);
|
ctvAutopilotStatus.setVisibility(View.GONE);
|
||||||
|
slidePanelView.setVisibility(View.GONE);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAutopilotBiz() {
|
public void showAutopilotBiz() {
|
||||||
ctvAutopilotStatus.setVisibility(View.VISIBLE);
|
getActivity().runOnUiThread(()->{
|
||||||
slidePanelView.setVisibility(View.VISIBLE);
|
ctvAutopilotStatus.setVisibility(View.VISIBLE);
|
||||||
|
slidePanelView.setVisibility(View.VISIBLE);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() {
|
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() {
|
||||||
|
|||||||
@@ -65,4 +65,47 @@
|
|||||||
app:layout_constraintRight_toRightOf="@id/module_mogo_och_notice"
|
app:layout_constraintRight_toRightOf="@id/module_mogo_och_notice"
|
||||||
app:layout_constraintTop_toTopOf="@id/module_mogo_och_notice"/>
|
app:layout_constraintTop_toTopOf="@id/module_mogo_och_notice"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/btnAutopilotDisable"
|
||||||
|
android:text="Disable"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
android:textSize="30sp"
|
||||||
|
android:background="#f00" />
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/btnAutopilotEnable"
|
||||||
|
android:text="Enable"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btnAutopilotDisable"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
android:textSize="30sp"
|
||||||
|
android:background="#0f0" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/btnAutopilotRunning"
|
||||||
|
android:text="Running"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btnAutopilotEnable"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
android:textSize="30sp"
|
||||||
|
android:background="#00f" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/btnAutopilotArrive"
|
||||||
|
android:text="Arrived"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btnAutopilotRunning"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
android:textSize="30sp"
|
||||||
|
android:background="#f00" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -143,4 +143,6 @@ public interface IMogoADASController extends IProvider {
|
|||||||
void onAutopilotArriveLike( int type );
|
void onAutopilotArriveLike( int type );
|
||||||
|
|
||||||
int getAutopilotStatus();
|
int getAutopilotStatus();
|
||||||
|
|
||||||
|
void mockOchStatus(int state, String reason);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -669,10 +669,23 @@ public class MogoADASController implements IMogoADASController {
|
|||||||
public int getAutopilotStatus() {
|
public int getAutopilotStatus() {
|
||||||
int status = IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE;
|
int status = IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE;
|
||||||
try {
|
try {
|
||||||
AutopilotServiceManage.getInstance().autopilotStateCall().getState();
|
status = AutopilotServiceManage.getInstance().autopilotStateCall().getState();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mockOchStatus(int state, String reason) {
|
||||||
|
if(state == -1){
|
||||||
|
if (mAdasOCHCallback != null) {
|
||||||
|
mAdasOCHCallback.onArriveAt(new AdasOCHData(1, 1d, 1d));
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (mAdasOCHCallback != null) {
|
||||||
|
mAdasOCHCallback.onStateChanged(state, reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user