[Taxi-d 280 Taxi-p 130] opt

This commit is contained in:
liujing
2022-06-29 18:21:10 +08:00
parent b2714efd6d
commit 67aa51a99d
10 changed files with 65 additions and 60 deletions

View File

@@ -144,10 +144,10 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
@Override
public void onDriverHasCheckedPilotCondition(boolean isBoarded) {
if (isBoarded){
mView.showOrHideServingOrderFragment(true);
}
mView.showOrHideStartAutopilotView(true,isBoarded);
CallerLogger.INSTANCE.d(M_TAXI_P+TAG,"isBoarded = "+isBoarded);
runOnUIThread(() -> {
mView.updateStartAutopilotBtnStatus(isBoarded);
});
}
private void updateOrderView(TaxiPassengerOrderQueryRespBean.Result order) {
@@ -179,14 +179,16 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
// TODO: 2022/6/10 若司机端已经确认,则显示开始行程按钮 并且可点击,第二步的轮询停止
//TODO: 2022/6/10 若订单取消或者隐藏则关掉开始行程界面,轮询也要取消
if (TaxiPassengerOrderStatusEnum.UserArriveAtStart.getCode() == order.orderStatus){
//开启轮询司机是否已准备好开启自动驾驶的环境
TaxiPassengerModel.getInstance().startDriverReadyToAutopilotLoop();
runOnUIThread(() ->{
CallerLogger.INSTANCE.d(M_TAXI_P+TAG,"UserArriveAtStart");
mView.showOrHideStartAutopilotView(true,false);
});
//开启轮询司机是否已准备好开启自动驾驶的环境
TaxiPassengerModel.getInstance().startDriverReadyToAutopilotLoop();
}
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.getCode() == order.orderStatus){
runOnUIThread(() ->{
mView.showOrHideServingOrderFragment(true);
mView.showOrHideStartAutopilotView(false,false);
});
TaxiPassengerModel.getInstance().startOrStopReadyToAutopilotoop(false);

View File

@@ -283,20 +283,27 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
* @param isShow
*/
public void showOrHideStartAutopilotView(boolean isShow, boolean isClickable){
if (isShow){
if (mStartAutopilotView == null || mStartAutopilotView.get() == null){
mStartAutopilotView = new WeakReference<>(new TaxiPassengerStartAutopilotView(getContext()));
}
OverlayViewUtils.showOverlayView(getActivity(),mStartAutopilotView.get());
mStartAutopilotView.get().setOnClickStartAutopilotBtnCallback(this);
mStartAutopilotView.get().updateStartAutopilotBtnStatus(isClickable);
}else {
if (mStartAutopilotView == null || mStartAutopilotView.get() == null){
return;
}
mStartAutopilotView.get().setOnClickStartAutopilotBtnCallback(null);
OverlayViewUtils.dismissOverlayView(mStartAutopilotView.get());
// if (isShow){
// if (mStartAutopilotView == null || mStartAutopilotView.get() == null){
// mStartAutopilotView = new WeakReference<>(new TaxiPassengerStartAutopilotView(getContext()));
// mStartAutopilotView.get().setOnClickStartAutopilotBtnCallback(this);
// }
// OverlayViewUtils.showOverlayView(getActivity(),mStartAutopilotView.get());
// updateStartAutopilotBtnStatus(isClickable);
// }else {
// if (mStartAutopilotView == null || mStartAutopilotView.get() == null){
// return;
// }
// mStartAutopilotView.get().setOnClickStartAutopilotBtnCallback(null);
// OverlayViewUtils.dismissOverlayView(mStartAutopilotView.get());
// }
}
public void updateStartAutopilotBtnStatus(boolean isClickable){
if (mStartAutopilotView == null || mStartAutopilotView.get() == null){
return;
}
mStartAutopilotView.get().updateStartAutopilotBtnStatus(isClickable);
}
/**

View File

@@ -1,19 +1,17 @@
package com.mogo.och.taxi.passenger.ui;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.och.taxi.passenger.R;
import com.mogo.och.taxi.passenger.callback.ITPClickStartAutopilotCallback;
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel;
/**
* @author: wangmingjun
@@ -29,6 +27,7 @@ public class TaxiPassengerStartAutopilotView extends RelativeLayout implements V
private AnimationDrawable mAnimationStartingDrawable;
private static final long TIMER_START_AUTOPILOT_INTERVAL = 10 * 1000L;
private Context mContext;
private View view;
public TaxiPassengerStartAutopilotView(Context context) {
super(context);
@@ -37,23 +36,10 @@ public class TaxiPassengerStartAutopilotView extends RelativeLayout implements V
}
private void initView(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.taxi_p_start_autopilot_view, this,true);
view = LayoutInflater.from(context).inflate(R.layout.taxi_p_start_autopilot_view, this,true);
mStartAutopilotBtn = view.findViewById(R.id.taxi_p_start_autopilot);
mAutopilotStartingImage = view.findViewById(R.id.taxi_p_autopilot_starting);
mStartAutopilotBtn.setOnClickListener(this);
//debug 调试使用,长按光圈,调用乘客开启自动驾驶
mAutopilotStartingImage.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
//开启动画和自动驾驶
if (!isStarting){
startOrStopLoadingAnim(true);
TaxiPassengerModel.getInstance().startAutopilot();
}
return false;
}
});
}
public void setOnClickStartAutopilotBtnCallback(ITPClickStartAutopilotCallback clickCallback){
@@ -74,12 +60,24 @@ public class TaxiPassengerStartAutopilotView extends RelativeLayout implements V
public void updateStartAutopilotBtnStatus(boolean isClickable){
if (mStartAutopilotBtn == null) return;
mStartAutopilotBtn.setClickable(isClickable);
mStartAutopilotBtn.setText(mContext.getResources().getString(R.string.taxi_p_start_autopilot_txt));
mStartAutopilotBtn.setText(
mContext.getResources().getString(R.string.taxi_p_start_autopilot_txt));
if (isClickable){ //可点击状态下UI
mStartAutopilotBtn.setTextColor(mContext.getResources().getColor(R.color.taxi_p_start_autopilot_txt_color));
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mStartAutopilotBtn.getLayoutParams();
params.bottomMargin = 0;
mStartAutopilotBtn.setLayoutParams(params);
mStartAutopilotBtn.setTextColor(
mContext.getResources().getColor(R.color.taxi_p_start_autopilot_txt_color));
mStartAutopilotBtn.setBackground(mContext.getResources().getDrawable(R.drawable.anmi_flow));
startAutopilotBgAnimatorDrawable(true);
}else {// 不可点击状态下 UI
mStartAutopilotBtn.setTextColor(mContext.getResources().getColor(R.color.taxi_p_start_autopilot_txt_un_color));
LayoutParams params = (LayoutParams) mStartAutopilotBtn.getLayoutParams();
params.bottomMargin = 294;
mStartAutopilotBtn.setLayoutParams(params);
mStartAutopilotBtn.setBackground(
mContext.getResources().getDrawable(R.drawable.taxi_p_start_autopilot_txt_btn_bg));
mStartAutopilotBtn.setTextColor(
mContext.getResources().getColor(R.color.taxi_p_start_autopilot_txt_un_color));
startAutopilotBgAnimatorDrawable(false);
}
}
@@ -87,7 +85,6 @@ public class TaxiPassengerStartAutopilotView extends RelativeLayout implements V
public void startAutopilotBgAnimatorDrawable(boolean isStart){
if (isStart){
if (mAnimationBtnDrawable == null) {
mStartAutopilotBtn.setBackground(getResources().getDrawable(R.drawable.anmi_flow));
mAnimationBtnDrawable = (AnimationDrawable) mStartAutopilotBtn.getBackground();
}
if (mAnimationBtnDrawable.isRunning()) {
@@ -97,7 +94,6 @@ public class TaxiPassengerStartAutopilotView extends RelativeLayout implements V
mAnimationBtnDrawable.start();
}else {
if (mAnimationBtnDrawable != null) {
mAnimationBtnDrawable.selectDrawable(0);
mAnimationBtnDrawable.stop();
}
mAnimationBtnDrawable = null;
@@ -107,7 +103,6 @@ public class TaxiPassengerStartAutopilotView extends RelativeLayout implements V
private void startingAutopilotAnimatorDrawable(boolean isStart){
if (isStart){
if (mAnimationStartingDrawable == null) {
mAutopilotStartingImage.setBackground(getResources().getDrawable(R.drawable.starting_anmi_flow));
mAnimationStartingDrawable = (AnimationDrawable) mAutopilotStartingImage.getBackground();
}
if (mAnimationStartingDrawable.isRunning()) {
@@ -130,7 +125,7 @@ public class TaxiPassengerStartAutopilotView extends RelativeLayout implements V
isStarting = true;
mStartAutopilotBtn.setText(getResources().getString(R.string.taxi_p_start_autopilot_loading));
mStartAutopilotBtn.setTextColor(getResources().getColor(R.color.taxi_autopilot_text_color_normal));
mStartAutopilotBtn.setTextColor(getResources().getColor(R.color.taxi_p_start_autopilot_txt_un_color));
startingAutopilotCountDown();
} else {

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" tools:ignore="MissingDefaultResource">
<item android:drawable="@drawable/starting_anmi_flow" android:state_checkable="true"/>
<item android:drawable="@drawable/taxi_p_start_autopilot_txt_btn_bg"/>
</selector>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="520px" android:height="150px"/>
<corners android:radius="76px"/>
<gradient
android:angle="180"

View File

@@ -17,16 +17,15 @@
/>
<TextView
android:id="@+id/taxi_p_start_autopilot"
android:layout_width="@dimen/taxi_p_start_autopilot_btn_width"
android:layout_height="@dimen/taxi_p_start_autopilot_btn_height"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/taxi_p_start_autopilot_txt"
android:textSize="@dimen/taxi_p_start_autopilot_txt_size"
android:textStyle="bold"
android:textColor="@android:color/white"
android:textColor="@color/taxi_p_start_autopilot_txt_un_color"
android:elevation="5dp"
android:clickable="false"
android:background="@drawable/taxi_p_autopilot_btn_bg_selector"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>

View File

@@ -62,7 +62,7 @@
<dimen name="taxi_p_progress_des_size">34px</dimen>
<dimen name="taxi_p_route_txt_unit_size">28px</dimen>
<dimen name="taxi_p_start_autopilot_txt_size">60px</dimen>
<dimen name="taxi_p_start_autopilot_txt_size">52px</dimen>
<dimen name="taxi_p_start_autopilot_btn_width">1000px</dimen>
<dimen name="taxi_p_start_autopilot_btn_height">500px</dimen>
</resources>

View File

@@ -125,7 +125,7 @@
<dimen name="taxi_p_progress_des_size">34px</dimen>
<dimen name="taxi_p_route_txt_unit_size">28px</dimen>
<dimen name="taxi_p_start_autopilot_txt_size">60px</dimen>
<dimen name="taxi_p_start_autopilot_txt_size">52px</dimen>
<dimen name="taxi_p_start_autopilot_btn_width">1000px</dimen>
<dimen name="taxi_p_start_autopilot_btn_height">500px</dimen>

View File

@@ -120,7 +120,7 @@
<dimen name="taxi_p_progress_des_size">34px</dimen>
<dimen name="taxi_p_route_txt_unit_size">28px</dimen>
<dimen name="taxi_p_start_autopilot_txt_size">60px</dimen>
<dimen name="taxi_p_start_autopilot_txt_size">52px</dimen>
<dimen name="taxi_p_start_autopilot_btn_width">1000px</dimen>
<dimen name="taxi_p_start_autopilot_btn_height">500px</dimen>
</resources>

View File

@@ -185,7 +185,6 @@ public class TaxiModel {
});
if (NetworkUtils.isConnected(mContext)) {
queryAutopilotStatus();
queryCarStatus();
}
}
@@ -263,6 +262,7 @@ public class TaxiModel {
//更新view
CallerLogger.INSTANCE.d(M_TAXI + TAG, "changeCarStatus:" + mOCHCarStatus);
startOrStopOrderLoop(mOCHCarStatus == 1);
queryAutopilotStatus(mOCHCarStatus == 1);
String role = "";
if (TaxiDriverRoleEnum.DEMO.getCode() == data.data.purpose) {
role = TaxiConst.DEMO_USER;
@@ -774,13 +774,20 @@ public class TaxiModel {
}
}
public void queryAutopilotStatus(boolean isStart){
if (isStart){
queryAutopilotStatus();
}
}
public void queryAutopilotStatus(){
if (mCurrentOCHOrder == null) return;
TaxiServiceManager.getInstance().queryAutopilotStatus(mContext, mCurrentOCHOrder.orderNo,
new TaxiServiceCallback<TaxiDataBaseRespBean>() {
@Override
public void onSuccess(TaxiDataBaseRespBean data) {
updateAutopilotStatus(data.code == 0);
if (data != null && data.code == 0 && data.data.equals(true))
updateAutopilotStatus(data.data.equals(true));
}
@Override
@@ -1337,7 +1344,7 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(msg);
}
});
}
@@ -1361,7 +1368,6 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
}
});
}
@@ -1430,7 +1436,7 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(msg);
}
});
}