优化基础布局

This commit is contained in:
tongchenfei
2021-01-22 09:58:22 +08:00
parent 5e1961eb33
commit 6952cfac94
9 changed files with 106 additions and 57 deletions

View File

@@ -37,22 +37,6 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
@Override
protected void initViews() {
super.initViews();
// findViewById(R.id.btnEnterOchBus).setOnClickListener(new OnPreventFastClickListener() {
// @Override
// public void onClickImpl(View v) {
// showOchBus();
// }
// });
// findViewById(R.id.btnArrive).setOnClickListener(view->{
// mPresenter.onArriveAt(new AdasOCHData(10, nextStation.getLon(), nextStation.getLat()));
// });
// btnExecute = findViewById(R.id.btnExecute);
// btnExecute.setOnClickListener(new OnPreventFastClickListener() {
// @Override
// public void onClickImpl(View v) {
// mPresenter.autoDriveToNextStation();
// }
// });
tvNotice = findViewById(R.id.module_mogo_och_bus_station_notice);
tvNotice.setOnClickListener(view->{
@@ -101,26 +85,26 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
// todo 渲染小巴路线数据
stationList.clear();
stationList.addAll(busStationList);
// for (int i = 0; i < stationList.size(); i++) {
// OchBusStation station = stationList.get(i);
// if (station.getIsCurrentSite() == OchBusPresenter.STATION_STATUS_LEAVING) {
// tvNotice.setText("正在从 " + i + "站驶向" + (i + 1) + "站");
// nextStation = stationList.get(i + 1);
// btnExecute.setVisibility(View.GONE);
// break;
// } else if (station.getIsCurrentSite() == OchBusPresenter.STATION_STATUS_STOPED) {
// tvNotice.setText("车辆正停在" + i + "站");
// btnExecute.setVisibility(View.VISIBLE);
// if (i == stationList.size() - 1) {
// btnExecute.setText("单程结束");
// }else if(i == 0){
// btnExecute.setText("准备出发");
// }else{
// btnExecute.setText("乘客已上车,准备出发");
// }
// break;
// }
// }
for (int i = 0; i < stationList.size(); i++) {
OchBusStation station = stationList.get(i);
if (station.getIsCurrentSite() == OchBusPresenter.STATION_STATUS_LEAVING) {
tvNotice.setText("正在从 " + i + "站驶向" + (i + 1) + "");
nextStation = stationList.get(i + 1);
onAutopilotStatusChanged(true);
break;
} else if (station.getIsCurrentSite() == OchBusPresenter.STATION_STATUS_STOPED) {
tvNotice.setText("车辆正停在" + i + "");
onAutopilotStatusChanged(false);
if (i == stationList.size() - 1) {
showSlidePanle("单程结束");
}else if(i == 0){
showSlidePanle("准备出发");
}else{
showSlidePanle("乘客已上车,准备出发");
}
break;
}
}
}
});
}
@@ -145,11 +129,8 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
return this;
}
private boolean isInAutopilot;
@Override
public void moveToEnd() {
onAutopilotStatusChanged(isInAutopilot);
isInAutopilot = !isInAutopilot;
mPresenter.autoDriveToNextStation();
}
}

View File

@@ -11,7 +11,10 @@ import androidx.fragment.app.Fragment;
import com.mogo.commons.mvp.IView;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.commons.mvp.Presenter;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.och.view.SlidePanelView;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
/**
* 网约车基础Fragment主要负责布局通用界面处理站点面板和通话面板互斥情况
@@ -47,6 +50,20 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer);
slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener);
checkCallView(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isCallViewShow());
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("Och", StatusDescriptor.CALL_VIEW, callViewListener);
}
private void checkCallView(boolean isShown){
if (flStationPanelContainer == null) {
return;
}
if (isShown) {
flStationPanelContainer.setTranslationY(131f);
}else{
flStationPanelContainer.setTranslationY(0f);
}
}
public void showSlidePanle(String text) {
@@ -79,6 +96,18 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
return null;
}
private final IMogoStatusChangedListener callViewListener = (descriptor, isTrue) -> {
if (descriptor == StatusDescriptor.CALL_VIEW) {
checkCallView(isTrue);
}
};
@Override
public void onDestroyView() {
super.onDestroyView();
MogoApisHandler.getInstance().getApis().getStatusManagerApi().unregisterStatusChangedListener("Och", StatusDescriptor.CALL_VIEW, callViewListener);
}
/**
* 获取站点面板view在{@link #initViews()}时候添加到container中
* @return 站点面板view

View File

@@ -14,7 +14,6 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
@@ -49,10 +48,15 @@ public class SlidePanelView extends View {
private final Paint blockPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private static final int BLOCK_START_X = 10;
private static final int BLOCK_START_Y = 10;
private static final int TEXT_MARGIN_LEFT = 20;
private static final int TEXT_MARGIN_RIGHT = 30;
private static final int BLOCK_START_X = 15;
private static final int BLOCK_START_Y = 15;
private static final int NORMAL_TEXT_MARGIN_LEFT = 40;
private static final int NORMAL_TEXT_MARGIN_RIGHT = 50;
private static final int SHORT_TEXT_MARGIN_LEFT = 60;
private static final int SHORT_TEXT_MARGIN_RIGHT = 70;
private int textMarginLeft = NORMAL_TEXT_MARGIN_LEFT;
private int textMarginRight = NORMAL_TEXT_MARGIN_RIGHT;
private OnSlidePanelMoveToEndListener moveToEndListener;
@@ -105,7 +109,7 @@ public class SlidePanelView extends View {
textPaint.setStyle(Paint.Style.FILL);
textPaint.setTextSize(40);
textPaint.setTextAlign(Paint.Align.LEFT);
textGradient = new LinearGradient(-GRADIENT_OFFSET, 0, 0, 0, new int[]{0x33ffffff, 0xffffffff, 0x29ffffff}, new float[]{0, 0.5f, 1f}, Shader.TileMode.CLAMP);
textGradient = new LinearGradient(-GRADIENT_OFFSET, 0, 0, 0, new int[]{0x33ffffff, 0xffffffff, 0x33ffffff}, null, Shader.TileMode.CLAMP);
textGradient.setLocalMatrix(gradientMatrix);
textPaint.setShader(textGradient);
textPaint.getFontMetrics(blockTextMetrics);
@@ -118,17 +122,22 @@ public class SlidePanelView extends View {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
int widthSize;
int heightSize;
Log.d(TAG, "onMeasure:\r\n widthMode: " + widthMode + " widthSize: " + widthSize + " \r\n heightMode: " + heightMode + " heightSize: " + heightSize);
if (blockText.length() < 5) {
textMarginLeft = SHORT_TEXT_MARGIN_LEFT;
textMarginRight = SHORT_TEXT_MARGIN_RIGHT;
} else {
textMarginLeft = NORMAL_TEXT_MARGIN_LEFT;
textMarginRight = NORMAL_TEXT_MARGIN_RIGHT;
}
Log.d(TAG, "textMetrics: ascent: " + blockTextMetrics.ascent + " descent: " + blockTextMetrics.descent + " top: " + blockTextMetrics.top + " bottom: " + blockTextMetrics.bottom);
if (widthMode == MeasureSpec.AT_MOST) {
// 宽度根据图片大小,字符串长度,各种间隔确定
// 高度根据图片大小和上下间隔确定
textPaint.getTextBounds(blockText, 0, blockText.length(), textRect);
widthSize = BLOCK_START_X * 2 + bmBlock.getWidth() + TEXT_MARGIN_LEFT + TEXT_MARGIN_RIGHT + textRect.width();
widthSize = BLOCK_START_X * 2 + bmBlock.getWidth() + textMarginLeft + textMarginRight + textRect.width();
heightSize = BLOCK_START_Y * 2 + bmBlock.getHeight();
widthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, widthMode);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);
@@ -148,7 +157,7 @@ public class SlidePanelView extends View {
matrixAnim.cancel();
}
textOffset = (getHeight() - blockTextMetrics.ascent - blockTextMetrics.descent) / 2;
matrixAnim = ObjectAnimator.ofFloat(this, "matrixTranslate", 0, w + GRADIENT_OFFSET).setDuration(1000);
matrixAnim = ObjectAnimator.ofFloat(this, "matrixTranslate", 0, w + GRADIENT_OFFSET).setDuration(2000);
matrixAnim.setRepeatCount(ValueAnimator.INFINITE);
matrixAnim.start();
}
@@ -231,7 +240,7 @@ public class SlidePanelView extends View {
gradientMatrix.setTranslate(matrixTranslate, 0);
textGradient.setLocalMatrix(gradientMatrix);
canvas.save();
canvas.drawText(blockText, blockWidth + BLOCK_START_X + TEXT_MARGIN_LEFT, textOffset, textPaint);
canvas.drawText(blockText, blockWidth + BLOCK_START_X + textMarginLeft, textOffset, textPaint);
canvas.restore();
// 画滑块
canvas.drawBitmap(bmBlock, BLOCK_START_X + blockOffset, BLOCK_START_Y, blockPaint);

View File

@@ -37,6 +37,7 @@
android:drawableTop="@drawable/icon_heart_choose"
android:drawablePadding="@dimen/module_mogo_och_autopilot_status_text_drawable_padding"
android:gravity="center"
android:textAlignment="center"
android:paddingTop="@dimen/module_mogo_och_autopilot_status_text_padding_top"
android:text="自动驾驶"
android:textColor="@color/module_mogo_och_autopilot_text_color_selector"

View File

@@ -2,8 +2,10 @@ package com.mogo.httpdns;
import android.location.Location;
import com.mogo.utils.httpdns.HttpSimpleLocation;
import androidx.annotation.Keep;
import com.mogo.utils.httpdns.HttpSimpleLocation;
@Keep
public interface IHttpDnsLocationChanged {
/**
* 获取当前定位

View File

@@ -57,9 +57,9 @@ MOGO_UTILS_VERSION=2.0.12
MAP_AMAP_VERSION=2.0.12
MAP_AUTONAVI_VERSION=2.0.12
MOGO_MAP_VERSION=2.0.12
MOGO_MAP_API_VERSION=2.0.12
MOGO_MAP_API_VERSION=2.0.13
MOGO_SERVICE_VERSION=2.0.12
MOGO_SERVICE_API_VERSION=2.0.12
MOGO_SERVICE_API_VERSION=2.0.14
MOGO_CONNECTION_VERSION=2.0.12
MOGO_MODULE_APPS_VERSION=2.0.12
MOGO_MODULE_NAVI_VERSION=2.0.12
@@ -145,7 +145,7 @@ MOGO_OCH_TAXI_VERSION=1.0.0
######## 外部依赖引用
# 车聊聊
CARCHATTING_VERSION=2.2.70
CARCHATTING_VERSION=2.2.77
# 车聊聊接口
CARCHATTINGPROVIDER_VERSION=1.1.11
# websocket

View File

@@ -129,6 +129,19 @@ public interface IMogoStatusManager extends IProvider {
*/
boolean isMainPageLaunched();
/**
* 对话框是否展示
* @return
*/
boolean isCallViewShow();
/**
* 设置对话框展示状态
* @param tag
* @param status
*/
void setCallViewShow(String tag, boolean status);
/**
* 设置vrMode状态
* @param tag 业务类型

View File

@@ -101,4 +101,8 @@ public enum StatusDescriptor {
* 顶部弹框容器准备就绪
*/
TOP_CONTAINER_READY,
/**
* 聊天框是否正在展示
*/
CALL_VIEW
}

View File

@@ -142,6 +142,16 @@ public class MogoStatusManager implements IMogoStatusManager {
return get_bool_val( StatusDescriptor.MEDIA_PLAYER_STATUS );
}
@Override
public boolean isCallViewShow() {
return get_bool_val(StatusDescriptor.CALL_VIEW);
}
@Override
public void setCallViewShow(String tag, boolean status) {
doSetStatus(tag,StatusDescriptor.CALL_VIEW,status);
}
@Override
public void setMediaPlayStatus(String tag, boolean status) {
doSetStatus(tag, StatusDescriptor.MEDIA_PLAYER_STATUS, status);