添加车站面板显示

This commit is contained in:
tongchenfei
2021-01-22 18:25:27 +08:00
parent 45bd6208df
commit 3f49398b39
13 changed files with 289 additions and 55 deletions

1
.idea/gradle.xml generated
View File

@@ -89,6 +89,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -44,6 +44,8 @@ dependencies {
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid
implementation rootProject.ext.dependencies.androidxrecyclerview
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogooch
implementation rootProject.ext.dependencies.mogoutils

View File

@@ -0,0 +1,94 @@
package com.mogo.och.bus.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.och.bus.R;
import com.mogo.och.bus.bean.OchBusStation;
import com.mogo.och.bus.constant.OchBusConst;
import java.util.ArrayList;
import java.util.List;
/**
* Station Panel 中的车站列表adapter
*
* @author tongchenfei
*/
public class OchBusStationAdapter extends RecyclerView.Adapter<OchBusStationAdapter.ViewHolder> {
private final Context context;
private final List<OchBusStation> stationList = new ArrayList<>();
private int currentStation;
public OchBusStationAdapter(Context context) {
this.context = context;
}
public void refreshStationList(List<OchBusStation> stationList) {
this.stationList.clear();
this.stationList.addAll(stationList);
for (int i = 0; i < stationList.size(); i++) {
OchBusStation station = stationList.get(i);
if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_ARRIVING || station.getIsCurrentSite() == OchBusConst.STATION_STATUS_STOPED) {
currentStation = i;
break;
}
}
notifyDataSetChanged();
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_och_bus_station, parent, false));
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
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));
} else if (position < currentStation) {
// 驶过
holder.tvStationName.setTextColor(context.getResources().getColor(R.color.module_mogo_och_bus_arrived_station_name_text_color));
}else {
holder.tvStationName.setTextColor(context.getResources().getColor(R.color.module_mogo_och_bus_not_arrive_station_name_text_color));
}
if (position == 0) {
holder.tvStationNotice.setText("起点");
holder.tvStationNotice.setVisibility(View.VISIBLE);
} else if (position == getItemCount() - 1) {
holder.tvStationNotice.setText("终点");
holder.tvStationNotice.setVisibility(View.VISIBLE);
}else{
holder.tvStationNotice.setVisibility(View.GONE);
}
}
@Override
public int getItemCount() {
return stationList.size();
}
static class ViewHolder extends RecyclerView.ViewHolder{
ImageView ivIcon;
TextView tvStationName;
TextView tvStationNotice;
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);
}
}
}

View File

@@ -0,0 +1,13 @@
package com.mogo.och.bus.constant;
/**
* 常量
*
* @author tongchenfei
*/
public class OchBusConst {
public static final int STATION_STATUS_IDLE = 0;
public static final int STATION_STATUS_STOPED = 1;
public static final int STATION_STATUS_LEAVING = 2;
public static final int STATION_STATUS_ARRIVING = 3;
}

View File

@@ -1,22 +1,19 @@
package com.mogo.och.bus.fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.Group;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.view.OnPreventFastClickListener;
import com.mogo.och.BaseOchFragment;
import com.mogo.och.bus.R;
import com.mogo.och.bus.adapter.OchBusStationAdapter;
import com.mogo.och.bus.bean.OchBusStation;
import com.mogo.och.bus.constant.OchBusConst;
import com.mogo.och.bus.presenter.OchBusPresenter;
import com.mogo.och.view.SlidePanelView;
import com.mogo.service.adas.entity.AdasOCHData;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
@@ -30,16 +27,25 @@ import java.util.List;
*/
public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresenter> implements SlidePanelView.OnSlidePanelMoveToEndListener {
private static final String TAG = "OchBusFragment";
private final List<OchBusStation> stationList = new ArrayList<>();
private TextView tvNotice;
private TextView tvStationNotice;
private TextView tvStationName;
private RecyclerView rvStationList;
private OchBusStationAdapter adapter;
@Override
protected void initViews() {
super.initViews();
tvNotice = findViewById(R.id.module_mogo_och_bus_station_notice);
tvStationNotice = findViewById(R.id.module_mogo_och_bus_current_station_notice);
tvStationName = findViewById(R.id.module_mogo_och_bus_current_station_name);
rvStationList = findViewById(R.id.module_mogo_och_bus_rv_station_list);
tvNotice.setOnClickListener(view->{
adapter = new OchBusStationAdapter(getContext());
rvStationList.setAdapter(adapter);
rvStationList.setLayoutManager(new LinearLayoutManager(getContext()));
tvStationNotice.setOnClickListener(view -> {
showSlidePanle("到达站点,乘客以下车");
});
}
@@ -72,34 +78,34 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
}
}
private OchBusStation nextStation;
public void refreshBusStations(List<OchBusStation> busStationList) {
public void refreshBusStations(List<OchBusStation> stationList) {
if (getActivity() == null) {
return;
}
getActivity().runOnUiThread(() -> {
if (busStationList == null) {
if (stationList == null) {
// todo 获取小巴数据失败
} else {
// todo 渲染小巴路线数据
stationList.clear();
stationList.addAll(busStationList);
adapter.refreshStationList(stationList);
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);
if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_ARRIVING) {
tvStationName.setText(station.getSiteName());
tvStationNotice.setText("下一站");
onAutopilotStatusChanged(true);
break;
} else if (station.getIsCurrentSite() == OchBusPresenter.STATION_STATUS_STOPED) {
tvNotice.setText("辆正停在" + i + "");
} else if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_STOPED) {
tvStationNotice.setText("当前车站");
tvStationName.setText(station.getSiteName());
onAutopilotStatusChanged(false);
if (i == stationList.size() - 1) {
tvStationNotice.setText("终点");
showSlidePanle("单程结束");
}else if(i == 0){
} else if (i == 0) {
showSlidePanle("准备出发");
}else{
} else {
showSlidePanle("乘客已上车,准备出发");
}
break;
@@ -114,7 +120,7 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
}
private void queryStationListIfNecessary() {
if (stationList == null || stationList.isEmpty()) {
if (adapter.getItemCount() == 0) {
mPresenter.queryBusRoutes();
}
}

View File

@@ -28,6 +28,11 @@ import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_ARRIVING;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_IDLE;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_LEAVING;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_STOPED;
/**
* 网约车小巴
*
@@ -37,11 +42,6 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
private static final String TAG = "OchBusPresenter";
private static final int VEHICAL_TYPE = 10;
public static final int STATION_STATUS_IDLE = 0;
public static final int STATION_STATUS_STOPED = 1;
public static final int STATION_STATUS_LEAVING = 2;
public static final int STATION_STATUS_ARRIVING = 3;
public OchBusPresenter(OchBusFragment view) {
super(view);
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasOCHCallback(this);

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="6px"
android:dashGap="5px"
android:dashWidth="5px"
android:color="@color/module_mogo_och_bus_current_station_notice_text_color" />
</shape>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:drawable="@drawable/module_mogo_och_bus_station_green_dash_line"
android:visible="true"
android:fromDegrees="90" />
</item>
</layer-list>

View File

@@ -1,19 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<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="@dimen/module_mogo_och_bus_station_panel_width"
android:layout_height="@dimen/module_mogo_och_bus_station_panel_height">
android:layout_height="@dimen/module_mogo_och_bus_station_panel_height"
android:background="#FF2C3862">
<TextView
android:id="@+id/module_mogo_och_bus_current_station_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/module_mogo_och_bus_station_notice"
android:text="站点信息"
android:textSize="@dimen/module_mogo_och_bus_station_notice_text_size"
android:textColor="#fff"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
android:layout_marginStart="@dimen/module_mogo_och_bus_station_panel_guide_offset_left"
android:layout_marginTop="@dimen/module_mogo_och_bus_station_panel_padding_top"
android:text="顺义政府站"
android:textColor="@color/module_mogo_och_bus_current_station_name_text_color"
android:textSize="@dimen/module_mogo_och_bus_current_station_name_text_size"
app:layout_constraintLeft_toLeftOf="@id/vGuide"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vGuide"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginStart="@dimen/module_mogo_och_bus_station_panel_padding_left"
android:layout_marginTop="@dimen/module_mogo_och_bus_station_panel_guide_offset_top"
android:layout_marginEnd="@dimen/module_mogo_och_bus_station_panel_padding_right"
android:background="#FF51649D"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/module_mogo_och_bus_current_station_name" />
<TextView
android:id="@+id/module_mogo_och_bus_current_station_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/module_mogo_och_bus_station_panel_guide_offset_right"
android:text="站点信息"
android:textColor="#fff"
android:textSize="@dimen/module_mogo_och_bus_station_notice_text_size"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_bus_current_station_name"
app:layout_constraintRight_toRightOf="@id/vGuide"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_bus_current_station_name" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_mogo_och_bus_rv_station_list"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/module_mogo_och_bus_station_panel_guide_offset_left"
android:layout_marginTop="@dimen/module_mogo_och_bus_station_panel_guide_offset_top"
android:layout_marginEnd="@dimen/module_mogo_och_bus_station_panel_guide_offset_right"
android:layout_marginBottom="@dimen/module_mogo_och_bus_station_panel_padding_bottom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@id/vGuide"
app:layout_constraintRight_toRightOf="@id/vGuide"
app:layout_constraintTop_toBottomOf="@id/vGuide" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
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" />
<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"
app:layout_constraintLeft_toLeftOf="@id/module_mogo_och_bus_station_icon"
app:layout_constraintRight_toRightOf="@id/module_mogo_och_bus_station_icon" />
<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: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:text="起点"
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"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="module_mogo_och_bus_current_station_name_text_color">#FF1FA7FF</color>
<color name="module_mogo_och_bus_current_station_notice_text_color">#FFFFFFFF</color>
<color name="module_mogo_och_bus_arrived_station_name_text_color">#FFFFFFFF</color>
<color name="module_mogo_och_bus_not_arrive_station_name_text_color">#FF51649D</color>
<color name="module_mogo_och_bus_station_notice_text_color">#FF8299EB</color>
</resources>

View File

@@ -1,7 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 本套资源适配分体机xhdpi -->
<dimen name="module_mogo_och_bus_station_notice_text_size">24px</dimen>
<dimen name="module_mogo_och_bus_station_panel_width">464px</dimen>
<dimen name="module_mogo_och_bus_station_panel_height">310px</dimen>
<dimen name="module_mogo_och_bus_station_panel_height">348px</dimen>
<dimen name="module_mogo_och_bus_current_station_name_text_size">32px</dimen>
<dimen name="module_mogo_och_bus_current_station_notice_text_size">20px</dimen>
<dimen name="module_mogo_och_bus_station_name_text_size">26px</dimen>
<dimen name="module_mogo_och_bus_station_notice_text_size">20px</dimen>
<dimen name="module_mogo_och_bus_station_name_margin_left">15px</dimen>
<dimen name="module_mogo_och_bus_station_panel_padding_top">20px</dimen>
<dimen name="module_mogo_och_bus_station_panel_padding_left">36px</dimen>
<dimen name="module_mogo_och_bus_station_panel_padding_bottom">28px</dimen>
<dimen name="module_mogo_och_bus_station_panel_padding_right">36px</dimen>
<dimen name="module_mogo_och_bus_station_panel_guide_offset_left">3px</dimen>
<dimen name="module_mogo_och_bus_station_panel_guide_offset_right">3px</dimen>
<dimen name="module_mogo_och_bus_station_panel_guide_offset_top">17px</dimen>
<dimen name="module_mogo_och_bus_station_panel_guide_offset_bottom">17px</dimen>
</resources>

View File

@@ -16,19 +16,6 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- <View-->
<!-- android:layout_width="@dimen/module_mogo_och_autopilot_status_bg_width"-->
<!-- android:layout_height="@dimen/module_mogo_och_autopilot_status_bg_height"-->
<!-- android:id="@+id/module_mogo_och_autopilot_status_bg"-->
<!-- android:background="@drawable/module_mogo_och_autopilot_status_bg"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"/>-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:id="@+id/module_mogo_och_"-->
<CheckedTextView
android:id="@+id/module_mogo_och_autopilot_status"
android:layout_width="@dimen/module_mogo_och_autopilot_status_bg_width"
@@ -39,7 +26,7 @@
android:gravity="center"
android:textAlignment="center"
android:paddingTop="@dimen/module_mogo_och_autopilot_status_text_padding_top"
android:text="自动驾驶"
android:text="自动"
android:textColor="@color/module_mogo_och_autopilot_text_color_selector"
android:textSize="@dimen/module_mogo_och_autopilot_status_text_size"
app:layout_constraintBottom_toBottomOf="parent"