This commit is contained in:
tongchenfei
2021-01-25 17:58:23 +08:00
parent 3f49398b39
commit f18f76d2d2
49 changed files with 258 additions and 46 deletions

View File

@@ -56,21 +56,31 @@ public class OchBusStationAdapter extends RecyclerView.Adapter<OchBusStationAdap
holder.tvStationName.setText(stationList.get(position).getSiteName());
if (position == currentStation) {
holder.tvStationName.setTextColor(context.getResources().getColor(R.color.module_mogo_och_bus_current_station_name_text_color));
holder.ivIcon.setImageResource(R.drawable.module_mogo_och_bus_icon_arriving_station);
} else if (position < currentStation) {
// 驶过
holder.tvStationName.setTextColor(context.getResources().getColor(R.color.module_mogo_och_bus_arrived_station_name_text_color));
holder.ivIcon.setImageResource(R.drawable.module_mogo_och_bus_icon_arrived_station);
}else {
holder.tvStationName.setTextColor(context.getResources().getColor(R.color.module_mogo_och_bus_not_arrive_station_name_text_color));
holder.ivIcon.setImageResource(R.drawable.module_mogo_och_bus_icon_not_arrive_station);
}
if (position == 0) {
holder.tvStationNotice.setText("起点");
holder.tvStationNotice.setVisibility(View.VISIBLE);
holder.vDashTop.setVisibility(View.GONE);
holder.vDashBottom.setVisibility(View.VISIBLE);
} else if (position == getItemCount() - 1) {
holder.tvStationNotice.setText("终点");
holder.tvStationNotice.setVisibility(View.VISIBLE);
holder.vDashTop.setVisibility(View.VISIBLE);
holder.vDashBottom.setVisibility(View.GONE);
}else{
holder.tvStationNotice.setVisibility(View.GONE);
holder.vDashTop.setVisibility(View.VISIBLE);
holder.vDashBottom.setVisibility(View.VISIBLE);
}
}
@@ -84,11 +94,14 @@ public class OchBusStationAdapter extends RecyclerView.Adapter<OchBusStationAdap
ImageView ivIcon;
TextView tvStationName;
TextView tvStationNotice;
View vDashBottom,vDashTop;
public ViewHolder(@NonNull View itemView) {
super(itemView);
ivIcon = itemView.findViewById(R.id.module_mogo_och_bus_station_icon);
tvStationName = itemView.findViewById(R.id.module_mogo_och_bus_station_name);
tvStationNotice = itemView.findViewById(R.id.module_mogo_och_bus_station_notice);
vDashTop = itemView.findViewById(R.id.module_mogo_och_bus_station_top_dash);
vDashBottom = itemView.findViewById(R.id.module_mogo_och_bus_station_bottom_dash);
}
}
}

View File

@@ -44,10 +44,6 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
adapter = new OchBusStationAdapter(getContext());
rvStationList.setAdapter(adapter);
rvStationList.setLayoutManager(new LinearLayoutManager(getContext()));
tvStationNotice.setOnClickListener(view -> {
showSlidePanle("到达站点,乘客以下车");
});
}
@NonNull
@@ -88,15 +84,17 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
} else {
// todo 渲染小巴路线数据
adapter.refreshStationList(stationList);
int currPos = -1;
for (int i = 0; i < stationList.size(); i++) {
OchBusStation station = stationList.get(i);
if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_ARRIVING) {
tvStationName.setText(station.getSiteName());
tvStationNotice.setText("下一站");
currPos = i;
onAutopilotStatusChanged(true);
break;
} else if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_STOPED) {
currPos = i;
tvStationNotice.setText("当前车站");
tvStationName.setText(station.getSiteName());
onAutopilotStatusChanged(false);
@@ -106,11 +104,25 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
} else if (i == 0) {
showSlidePanle("准备出发");
} else {
showNotice("行程结束,请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车");
showSlidePanle("乘客已上车,准备出发");
}
break;
}
}
// todo smoothMove
int moveTo = currPos +1;
if (currPos < 3) {
moveTo = 0;
}
if (currPos >= stationList.size() - 3) {
moveTo = stationList.size()-1;
}
if (moveTo >= stationList.size()) {
moveTo = stationList.size()-1;
}
rvStationList.smoothScrollToPosition(moveTo);
}
});
}
@@ -137,6 +149,7 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
@Override
public void moveToEnd() {
hideNotice();
mPresenter.autoDriveToNextStation();
}
}

View File

@@ -0,0 +1,31 @@
package com.mogo.och.bus.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.constraintlayout.widget.ConstraintLayout;
/**
* 强制拦截所有touch时间的约束布局
*
* @author tongchenfei
*/
public class NoTouchConstraintLayout extends ConstraintLayout {
public NoTouchConstraintLayout(Context context) {
super(context);
}
public NoTouchConstraintLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NoTouchConstraintLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return true;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 850 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="17px" />
<solid android:color="#AD3D4E81" />
</shape>
</item>
<item
android:bottom="3px"
android:left="3px"
android:right="3px"
android:top="3px">
<shape>
<corners android:radius="17px" />
<gradient
android:endColor="#202D4E"
android:startColor="#2C3862" />
</shape>
</item>
</layer-list>

View File

@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.mogo.och.bus.view.NoTouchConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/module_mogo_och_bus_station_panel_width"
android:layout_height="@dimen/module_mogo_och_bus_station_panel_height"
android:background="#FF2C3862">
android:clickable="true"
android:background="@drawable/module_och_bus_panel_bkg">
<TextView
@@ -55,4 +56,4 @@
app:layout_constraintRight_toRightOf="@id/vGuide"
app:layout_constraintTop_toBottomOf="@id/vGuide" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.mogo.och.bus.view.NoTouchConstraintLayout>

View File

@@ -1,47 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/module_mogo_och_bus_station_icon"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_bus_station_name"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_bus_station_name"
android:src="@drawable/icon_heart_choose" />
android:layout_height="wrap_content">
<View
android:layout_width="10px"
android:layout_height="25px"
android:id="@+id/vLine"
android:background="@drawable/module_mogo_och_bus_station_v_green_dash"
app:layout_constraintTop_toBottomOf="@id/module_mogo_och_bus_station_icon"
android:id="@+id/module_mogo_och_bus_station_bottom_dash"
android:layout_width="1px"
android:layout_height="30px"
android:background="#fff"
app:layout_constraintLeft_toLeftOf="@id/module_mogo_och_bus_station_icon"
app:layout_constraintRight_toRightOf="@id/module_mogo_och_bus_station_icon"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_bus_station_icon"
android:layout_marginTop="10px"/>
<View
android:id="@+id/module_mogo_och_bus_station_top_dash"
android:layout_width="1px"
android:layout_height="30px"
android:background="#fff"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_bus_station_icon"
android:layout_marginBottom="10px"
app:layout_constraintLeft_toLeftOf="@id/module_mogo_och_bus_station_icon"
app:layout_constraintRight_toRightOf="@id/module_mogo_och_bus_station_icon" />
<ImageView
android:id="@+id/module_mogo_och_bus_station_icon"
android:layout_width="20px"
android:layout_height="20px"
android:scaleType="center"
android:src="@drawable/module_mogo_och_bus_icon_arrived_station"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_bus_station_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_bus_station_name" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/module_mogo_och_bus_station_name"
android:textSize="@dimen/module_mogo_och_bus_station_name_text_size"
android:textColor="@color/module_mogo_och_bus_arrived_station_name_text_color"
android:text="后鲁站"
android:layout_marginStart="@dimen/module_mogo_och_bus_station_name_margin_left"
app:layout_constraintLeft_toRightOf="@id/module_mogo_och_bus_station_icon"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/module_mogo_och_bus_station_name_margin_left"
android:text="后鲁站"
android:textColor="@color/module_mogo_och_bus_arrived_station_name_text_color"
android:textSize="@dimen/module_mogo_och_bus_station_name_text_size"
app:layout_constraintLeft_toRightOf="@id/module_mogo_och_bus_station_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<TextView
android:id="@+id/module_mogo_och_bus_station_notice"
android:textSize="@dimen/module_mogo_och_bus_station_notice_text_size"
android:textColor="@color/module_mogo_och_bus_station_notice_text_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="起点"
android:textColor="@color/module_mogo_och_bus_station_notice_text_color"
android:textSize="@dimen/module_mogo_och_bus_station_notice_text_size"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_bus_station_name"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_bus_station_name"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_bus_station_name"/>
app:layout_constraintTop_toTopOf="@id/module_mogo_och_bus_station_name" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -12,6 +12,7 @@ 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.FrameAnimImageView;
import com.mogo.och.view.SlidePanelView;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
@@ -27,6 +28,8 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
private CheckedTextView ctvAutopilotStatus;
private FrameLayout flStationPanelContainer;
private FrameAnimImageView fivNoticeHead;
private final SlidePanelView.OnSlidePanelMoveToEndListener onSlideToEndListener = () -> {
// 此处做一个代理,处理一下共有情况
hideSlidePanel();
@@ -47,9 +50,11 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
tvNotice = findViewById(R.id.module_mogo_och_notice);
ctvAutopilotStatus = findViewById(R.id.module_mogo_och_autopilot_status);
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container);
fivNoticeHead = findViewById(R.id.module_mogo_och_notice_head);
LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer);
slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener);
fivNoticeHead.setAnimRes(sHappy1);
checkCallView(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isCallViewShow());
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("Och", StatusDescriptor.CALL_VIEW, callViewListener);
@@ -78,10 +83,14 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
public void showNotice(String notice) {
tvNotice.setText(notice);
tvNotice.setVisibility(View.VISIBLE);
fivNoticeHead.setVisibility(View.VISIBLE);
fivNoticeHead.startAnim();
}
public void hideNotice(){
tvNotice.setVisibility(View.GONE);
fivNoticeHead.setVisibility(View.GONE);
fivNoticeHead.stopAnim();
}
/**
@@ -113,4 +122,36 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
* @return 站点面板view
*/
public abstract int getStationPanelViewId();
private final int[] sHappy1 = {
R.drawable.ic_happy1_00000,
R.drawable.ic_happy1_00001,
R.drawable.ic_happy1_00002,
R.drawable.ic_happy1_00003,
R.drawable.ic_happy1_00004,
R.drawable.ic_happy1_00005,
R.drawable.ic_happy1_00006,
R.drawable.ic_happy1_00007,
R.drawable.ic_happy1_00008,
R.drawable.ic_happy1_00009,
R.drawable.ic_happy1_00010,
R.drawable.ic_happy1_00011,
R.drawable.ic_happy1_00012,
R.drawable.ic_happy1_00013,
R.drawable.ic_happy1_00014,
R.drawable.ic_happy1_00015,
R.drawable.ic_happy1_00016,
R.drawable.ic_happy1_00017,
R.drawable.ic_happy1_00018,
R.drawable.ic_happy1_00019,
R.drawable.ic_happy1_00020,
R.drawable.ic_happy1_00021,
R.drawable.ic_happy1_00022,
R.drawable.ic_happy1_00023,
R.drawable.ic_happy1_00024,
R.drawable.ic_happy1_00025,
R.drawable.ic_happy1_00026,
R.drawable.ic_happy1_00027,
R.drawable.ic_happy1_00028
};
}

View File

@@ -0,0 +1,65 @@
package com.mogo.och.view;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
/**
* 帧动画ImageView封装
*
* @author tongchenfei
*/
public class FrameAnimImageView extends androidx.appcompat.widget.AppCompatImageView implements Handler.Callback {
public static final long FRAME_INTERVAL = 50L;
private final static int MSG_LOOP = 3003;
public FrameAnimImageView(Context context) {
super(context);
}
public FrameAnimImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FrameAnimImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
private int[] animRes;
private int animPos;
private boolean isInAnim = false;
private final Handler animHandler = new Handler(this);
public void setAnimRes(int[] animRes) {
this.animRes = animRes;
}
public void startAnim() {
isInAnim = true;
animHandler.sendEmptyMessage(MSG_LOOP);
}
public void stopAnim() {
isInAnim = false;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
stopAnim();
}
@Override
public boolean handleMessage(Message msg) {
if (isInAnim && animRes != null) {
if (animPos >= animRes.length) {
animPos = 0;
}
setImageResource(animRes[animPos++]);
animHandler.sendEmptyMessageDelayed(MSG_LOOP, FRAME_INTERVAL);
}
return true;
}
}

View File

@@ -114,7 +114,7 @@ public class SlidePanelView extends View {
textPaint.setShader(textGradient);
textPaint.getFontMetrics(blockTextMetrics);
bmBlock = BitmapFactory.decodeResource(getResources(), R.drawable.ic_block);
bmBlock = BitmapFactory.decodeResource(getResources(), R.drawable.module_och_base_slide_block);
blockWidth = bmBlock.getWidth();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/module_mogo_och_base_icon_in_autopilot" android:state_checked="true" />
<item android:drawable="@drawable/module_mogo_och_base_icon_not_in_autopilot" />
</selector>

View File

@@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:paddingStart="@dimen/module_mogo_och_margin_left"
android:paddingTop="@dimen/module_mogo_och_margin_top"
android:paddingEnd="@dimen/module_mogo_och_margin_right"
@@ -21,8 +22,7 @@
android:layout_width="@dimen/module_mogo_och_autopilot_status_bg_width"
android:layout_height="@dimen/module_mogo_och_autopilot_status_bg_height"
android:background="@drawable/module_mogo_och_autopilot_status_bg"
android:drawableTop="@drawable/icon_heart_choose"
android:drawablePadding="@dimen/module_mogo_och_autopilot_status_text_drawable_padding"
android:drawableTop="@drawable/module_mogo_och_base_autopilot_status_icon_selector"
android:gravity="center"
android:textAlignment="center"
android:paddingTop="@dimen/module_mogo_och_autopilot_status_text_padding_top"
@@ -45,13 +45,24 @@
android:id="@+id/module_mogo_och_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF2254B1"
android:background="@drawable/module_mogo_och_base_notice_box_bg"
android:maxWidth="@dimen/module_mogo_och_notice_text_max_width"
android:text="请携带好随身物品注意侧后方来车感谢体验蘑菇智行自动驾驶车!"
android:text="请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车!"
android:textColor="#fff"
android:textSize="@dimen/module_mogo_och_notice_text_size"
android:visibility="gone"
tools:visibility = "visible"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.mogo.och.view.FrameAnimImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/module_mogo_och_notice_head"
android:src="@drawable/ic_happy1_00000"
android:visibility="gone"
android:layout_marginTop="185px"
app:layout_constraintRight_toRightOf="@id/module_mogo_och_notice"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_notice"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 此资源适配分体机 xhdpi -->
<dimen name="module_mogo_och_margin_left">37px</dimen>
<dimen name="module_mogo_och_margin_left">55px</dimen>
<dimen name="module_mogo_och_margin_right">40px</dimen>
<dimen name="module_mogo_och_margin_bottom">40px</dimen>
<dimen name="module_mogo_och_margin_top">24px</dimen>
@@ -14,7 +14,7 @@
<dimen name="module_mogo_och_autopilot_status_bg_height">120px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_size">20px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_padding_top">25px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_padding_top">13px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_drawable_padding">12px</dimen>
<dimen name="module_mogo_och_notice_text_max_width">460px</dimen>