[feature] 跑马灯

This commit is contained in:
yangyakun
2022-10-17 11:39:17 +08:00
parent e62a9d7dbb
commit 2d7970bfa0
7 changed files with 59 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
package com.mogo.och.bus.passenger.adapter;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -14,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.mogo.och.bus.passenger.R;
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
import com.mogo.och.common.module.utils.BlinkAnimationUtil;
import com.mogo.och.common.module.wigets.MarqueeTextView;
import java.util.List;
@@ -58,9 +60,11 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_green);
BlinkAnimationUtil.setAnimation(viewHolder.stationCircle);
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.MARQUEE);
}else {
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_gray);
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.END);
}
}else{
if (position == mStations.size() - 1){
@@ -77,22 +81,26 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
viewHolder.curArrowBg.setImageResource(R.drawable.bus_p_line_grey);
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_gray);
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.END);
} else if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){//刚到站未离开的
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
viewHolder.curArrowBg.setImageResource(R.drawable.bus_p_line_grey);
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_green);
BlinkAnimationUtil.setAnimation(viewHolder.stationCircle);
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.MARQUEE);
}else if (station.getDrivingStatus() == STATION_STATUS_ARRIVING && preStation.isLeaving()){//即将到站
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
viewHolder.curArrowBg.setImageResource(R.drawable.bus_p_line_green);
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_green);
BlinkAnimationUtil.setAnimation(viewHolder.stationCircle);
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.MARQUEE);
}else if (station.getDrivingStatus() == STATION_STATUS_ARRIVING &&
(preStation.getDrivingStatus() == STATION_STATUS_ARRIVING
|| preStation.getDrivingStatus() == STATION_STATUS_STOPPED)){ //未到站的并且前面也是未到站或者刚到站的
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
viewHolder.curArrowBg.setImageResource(R.drawable.bus_p_line_blue);
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_blue);
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.END);
}
}
}
@@ -103,7 +111,7 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
}
}
class StationViewHolder extends RecyclerView.ViewHolder{
public TextView stationName;
public MarqueeTextView stationName;
public ImageView stationCircle;
public ImageView curArrowBg;
public ImageView stationStationTag;

View File

@@ -26,6 +26,7 @@ import com.mogo.och.bus.passenger.presenter.BaseBusPassengerPresenter;
import com.mogo.och.bus.passenger.ui.layoutmanager.CenterLayoutManager;
import com.mogo.och.bus.passenger.utils.BPRouteDataTestUtils;
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
import com.mogo.och.common.module.wigets.MarqueeTextView;
import java.util.ArrayList;
import java.util.List;
@@ -49,7 +50,7 @@ public class BusPassengerRouteFragment extends
private TextView mSpeedTv;
private ConstraintLayout mNoLineInfoView;
private TextView mCarPlateNum;
private TextView mLineName;
private MarqueeTextView mLineName;
private TextView mOperationTime;
private ConstraintLayout mRouteInfoView;
private RecyclerView mStationsListRv;

View File

@@ -105,14 +105,15 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
<com.mogo.och.common.module.wigets.MarqueeTextView
android:id="@+id/bus_p_line_name_tv"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:maxLines="1"
android:ellipsize="end"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:text="----"
android:textColor="@color/bus_p_line_name_color"
android:textSize="@dimen/bus_p_driver_number_plate_size"
@@ -120,6 +121,7 @@
app:layout_constraintLeft_toRightOf="@+id/bus_p_driver_num_plate_tv"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/bus_p_driver_num_plate_tv"
app:layout_constraintBottom_toBottomOf="@+id/bus_p_driver_num_plate_tv"
app:layout_goneMarginLeft="0px" />
<TextView

View File

@@ -3,7 +3,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
<com.mogo.och.common.module.wigets.MarqueeTextView
android:id="@+id/bus_p_station"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@@ -35,6 +35,7 @@ import com.mogo.och.common.module.biz.constant.OchCommonConst;
import com.mogo.och.common.module.biz.provider.LoginService;
import com.mogo.och.common.module.utils.BlinkAnimationUtil;
import com.mogo.och.common.module.utils.OCHThreadPoolManager;
import com.mogo.och.common.module.wigets.MarqueeTextView;
import com.mogo.och.common.module.wigets.OCHCommitDialog;
import org.greenrobot.eventbus.Subscribe;
@@ -53,7 +54,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
public static final String TAG = "BusFragment";
private TextView mSwitchLine; //切换路线
private TextView mLineName;
private MarqueeTextView mLineName;
private TextView mTaskTime;
private Group groupStationsPanel;
private ConstraintLayout noDataView;

View File

@@ -10,15 +10,16 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
<com.mogo.och.common.module.wigets.MarqueeTextView
android:id="@+id/module_och_bus_line_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_68"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_64"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:text="--"
android:textColor="#FFF"
android:textSize="38px"

View File

@@ -0,0 +1,35 @@
package com.mogo.och.common.module.wigets;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewDebug;
public class MarqueeTextView extends androidx.appcompat.widget.AppCompatTextView{
public MarqueeTextView(Context context) {
this(context, null);
}
public MarqueeTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
@ViewDebug.ExportedProperty(category = "focus")
public boolean isFocused() {
return true;
}
@Override
@ViewDebug.ExportedProperty
public boolean isSelected() {
return true;
}
}