diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPStatusBarView.kt b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPStatusBarView.kt index 3cbe38d985..4bb0bd9403 100644 --- a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPStatusBarView.kt +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPStatusBarView.kt @@ -35,7 +35,7 @@ class BusPStatusBarView @JvmOverloads constructor( init { LayoutInflater.from(context).inflate(R.layout.p_bus_view_status_bar, this, true) - setBackgroundColor(Color.parseColor("#80FFFFFF")) + setBackgroundResource(R.drawable.bg_status_bar) isClickable = true isFocusable = true } diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java index 703d4af07e..4eafc8271c 100644 --- a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java @@ -2,14 +2,19 @@ package com.mogo.och.bus.passenger.ui; import android.os.Bundle; import android.view.LayoutInflater; +import android.view.View; import android.widget.FrameLayout; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; import com.mogo.commons.mvp.IView; import com.mogo.commons.mvp.MvpFragment; import com.mogo.commons.mvp.Presenter; +import com.mogo.eagle.core.data.multidisplay.TelematicConstant; +import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener; +import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager; import com.mogo.eagle.core.function.view.MapBizView; import com.mogo.och.bus.passenger.R; @@ -40,9 +45,50 @@ public abstract class BusPassengerBaseFragment { + BusPassengerBaseFragment implements MapAndLiveVideoView.ChangeItemListener { public static final String TAG = "BusPassengerRouteFragment"; @@ -50,9 +52,6 @@ public class BusPassengerRouteFragment extends private Group mRouteInfoView; private RecyclerView mStationsListRv; private BusPassengerMapDirectionView mMapDirectionView; -// private ImageView mMapArrowIcon; -// private RotateAnimation rotateAnimation; -// private float lastBearing = 0; private BusPassengerLineStationsAdapter mAdapter; private TextView emptyTv; private AppCompatImageView mAutopilotIv; @@ -60,6 +59,13 @@ public class BusPassengerRouteFragment extends private AppCompatTextView mCurrentArriveStationTitle; private AppCompatTextView mCurrentArriveTip; private AppCompatImageView mSpeakArrivedIv; + private DriverMonitorView driverMonitorView; + private ConstraintLayout indicatorView; + private View mapIndicator; + private View liveIndicator; + + private MapAndLiveVideoView mapAndLiveVideoView; + List views = new ArrayList<>(); /** * 改变自动驾驶状态 @@ -91,7 +97,6 @@ public class BusPassengerRouteFragment extends mNoLineInfoView =findViewById(R.id.bus_p_no_order_data_view); emptyTv = findViewById(R.id.no_order_data_tv); -// mCarPlateNum = findViewById(R.id.bus_p_driver_num_plate_tv); mLineName = findViewById(R.id.bus_p_line_name_tv); mAutopilotIv = findViewById(R.id.auto_status_iv); mCurrentArriveStation = findViewById(R.id.bus_p_cur_station_name); @@ -99,8 +104,6 @@ public class BusPassengerRouteFragment extends mCurrentArriveTip = findViewById(R.id.bus_p_cur_station_tip); mSpeakArrivedIv = findViewById(R.id.speak_arrived_iv); -// mOperationTime = findViewById(R.id.line_operation_time_tv); - mRouteInfoView = findViewById(R.id.bus_p_line_cl); mStationsListRv = findViewById(R.id.bus_p_line_stations_rl); @@ -109,12 +112,24 @@ public class BusPassengerRouteFragment extends mAdapter = new BusPassengerLineStationsAdapter(getContext(), mStationsList); mStationsListRv.setAdapter(mAdapter); -// mMapArrowIcon = findViewById(R.id.bus_p_arrow_nor); + indicatorView = findViewById(R.id.busIndicatorView); + mapIndicator = findViewById(R.id.firstIndicator); + liveIndicator = findViewById(R.id.secondIndicator); - videoSwitch.setOnClickListener(new View.OnClickListener() { + driverMonitorView = new DriverMonitorView(getContext()); + driverMonitorView.setLiveListener(new DriverMonitorView.LiveListener() { @Override - public void onClick(View v) { - // TODO: 2023/5/4 漫游视频打开/关闭 + public void onPlayError() { + goneLiveShadow(); + } + + @Override + public void showOrHideLiveBtn(boolean isShow) { + if (isShow){ + visibleLiveShadow(); + }else { + goneLiveShadow(); + } } }); @@ -128,13 +143,69 @@ public class BusPassengerRouteFragment extends } }); } + + mapAndLiveVideoView = findViewById(R.id.mapAndLiveVideoView); + + initLiveView(); + } + + private void initLiveView() { + views.add(new View(getContext()));// 其实是空的,真正小地图还在fragment里 + views.add(driverMonitorView); + mapAndLiveVideoView.setData(views); + mapAndLiveVideoView.setVisibility(View.GONE); + indicatorView.setVisibility(View.GONE); + } + + + @SuppressLint("UseCompatLoadingForDrawables") + @Override + public void changeToItem(int position) { +// (position == 0): 空view 地图占位 (position == 1) :live video + if (position == 0){ + mapIndicator.setBackground(getContext().getDrawable(R.drawable.indicator_selected_bg)); + liveIndicator.setBackground(getContext().getDrawable(R.drawable.indicator_unselected_bg)); + }else { + mapIndicator.setBackground(getContext().getDrawable(R.drawable.indicator_unselected_bg)); + liveIndicator.setBackground(getContext().getDrawable(R.drawable.indicator_selected_bg)); + } + mMapDirectionView.setVisibility(position == 0? View.VISIBLE:View.GONE); + } + + @Override + protected void openOrCloseLiveVideo() { + if (videoSwitch.isSelected()){ + videoSwitch.setSelected(false); + }else { + videoSwitch.setSelected(true); + mapAndLiveVideoView.changeToSecondView(); + } + mapAndLiveVideoView.setItemChangeListener(videoSwitch.isSelected()? this:null); + mapAndLiveVideoView.setVisibility(videoSwitch.isSelected()? View.VISIBLE : View.GONE); + indicatorView.setVisibility(videoSwitch.isSelected() ? View.VISIBLE : View.GONE); + mMapDirectionView.setVisibility(videoSwitch.isSelected() ? View.GONE : View.VISIBLE); + mapIndicator.setBackground(getContext().getDrawable(R.drawable.indicator_unselected_bg)); + liveIndicator.setBackground(getContext().getDrawable(R.drawable.indicator_selected_bg)); + } + + @Override + protected void goneLiveShadow() { + videoSwitch.setVisibility(View.GONE); +// driverMonitorView.setVisibility(View.GONE); + indicatorView.setVisibility(View.GONE); + } + + @Override + protected void visibleLiveShadow() { + videoSwitch.setVisibility(View.VISIBLE); } @Override protected void initViews(Bundle savedInstanceState) { super.initViews(savedInstanceState); - mMapDirectionView = findViewById(R.id.bus_p_line_map_view); + mMapDirectionView = findViewById(R.id.busPLineMapView); mMapDirectionView.onCreateView(savedInstanceState); + } @Override @@ -244,14 +315,6 @@ public class BusPassengerRouteFragment extends } } -// public void updatePlateNum(String plateNum){ -// if ("".equals(plateNum) || null == plateNum) { -// mCarPlateNum.setText("-- --"); -// }else { -// mCarPlateNum.setText((plateNum)); -// } -// } - public void updateLineInfo(String lineName, String lineDurTime) { mLineName.setText(lineName); // mOperationTime.setText(lineDurTime); @@ -301,27 +364,6 @@ public class BusPassengerRouteFragment extends } } -// @Override -// public void onCameraChange(float bearing) { -//// startIvCompass(bearing); -// } - -// /** -// * 设置指南针旋转 -// * -// * @param bearing -// */ -// private void startIvCompass(float bearing) { -// bearing = 360 - bearing; -// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startIvCompass: " + bearing); -// rotateAnimation = new RotateAnimation(lastBearing, bearing, Animation.RELATIVE_TO_SELF -// , 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); -// rotateAnimation.setFillAfter(true); -// -// mMapArrowIcon.startAnimation(rotateAnimation); -// lastBearing = bearing; -// } - public void onCarLocationChanged(MogoLocation location) { updateSpeedView((float) location.getGnssSpeed()); } diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/MapAndLiveVideoView.kt b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/MapAndLiveVideoView.kt new file mode 100644 index 0000000000..736f5e3809 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/MapAndLiveVideoView.kt @@ -0,0 +1,139 @@ +package com.mogo.och.bus.passenger.ui + +import android.app.Activity +import android.content.Context +import android.util.AttributeSet +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.LinearLayout +import android.widget.RelativeLayout +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager +import com.mogo.eagle.core.utilcode.mogo.logger.Logger +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.ui.MapAndLiveVideoView.Companion.TAG +import java.lang.Exception + +/** + * @author: wangmingjun + * @date: 2023/5/9 + */ + +class MapAndLiveVideoView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs), ViewPager.OnPageChangeListener { + + private var viewPager: ViewPager? = null + private var pagerAdapter: AdvancePagerAdapter? = null + private var changeItemListener: ChangeItemListener? = null + + companion object { + const val TAG = "MapAndLiveVideoView" + } + + init { + initView() + } + + private fun initView() { + viewPager = ViewPager(context) + pagerAdapter = AdvancePagerAdapter() + viewPager?.adapter = pagerAdapter + + addView(viewPager, LayoutParams(-1, -1)) + + viewPager?.addOnPageChangeListener(this) + } + + fun setData(list: MutableList){ + pagerAdapter?.setData(list) + pagerAdapter?.notifyDataSetChanged() + } + + fun setItemChangeListener(listener : ChangeItemListener?){ + changeItemListener = listener + } + + fun changeToSecondView(){ + viewPager?.currentItem = 1 + } + + override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { + Logger.d(TAG, "onPageScrolled--position = $position") + } + + override fun onPageSelected(position: Int) { + Logger.d(TAG, "onPageSelected--position = $position") + } + var startPosition = 1 + override fun onPageScrollStateChanged(state: Int) { + Logger.d(TAG, "onPageScrollStateChanged--state = $state") + viewPager?.let { + val position = it.currentItem + if (state == 0) { //静止 + if (startPosition == position){ + if (position==0){ + it.currentItem = 1 + }else{ + it.currentItem = 0 + } + }else{ + changeItemListener?.changeToItem(it.currentItem) + } + }else if (state == 1){ // 开始滑动 + startPosition = it.currentItem + }else{ + + } + } + } + + interface ChangeItemListener{ + fun changeToItem(position: Int) + } +} + +class AdvancePagerAdapter : PagerAdapter(), + ViewPager.OnPageChangeListener { + private var views: List? = null + + fun setData(views: List?){ + this.views = views + } + + override fun instantiateItem(container: View, position: Int): Any { + Logger.d(TAG, "instantiateItem--position = $position") + return try { + val currentItem = position % views!!.size + (container as ViewPager).addView(views!![currentItem]) + views!![currentItem] + }catch (e: Exception){ + container + } + } + + override fun getCount(): Int { + return if (views == null){ + 0 + }else{ + views!!.size + } + } + + override fun isViewFromObject(arg0: View, arg1: Any): Boolean { + return arg0 === arg1 + } + + override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { +// Logger.d(TAG, "onPageScrolled--position = $position") + } + + override fun onPageSelected(position: Int) { +// Logger.d(TAG, "onPageSelected--position = $position") + } + + override fun onPageScrollStateChanged(state: Int) { +// Logger.d(TAG, "onPageScrollStateChanged--state = $state") + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/live_view_loading_bg.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/live_view_loading_bg.png new file mode 100644 index 0000000000..99f5600926 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/live_view_loading_bg.png differ diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_status_bar.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_status_bar.xml index 36611a9a99..6bc804de4e 100644 --- a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_status_bar.xml +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_status_bar.xml @@ -1,8 +1,9 @@ - \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/indicator_select.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/indicator_select.xml new file mode 100644 index 0000000000..85d784f55d --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/indicator_select.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/indicator_unselect.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/indicator_unselect.xml new file mode 100644 index 0000000000..8de50ed358 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/indicator_unselect.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml index cc60b4b8d0..b483e24f21 100644 --- a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml @@ -33,13 +33,12 @@ diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_driver_monitor_view.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_driver_monitor_view.xml new file mode 100644 index 0000000000..738b29af84 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_driver_monitor_view.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_route_fragment.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_route_fragment.xml index ce540144cd..38f8520fad 100644 --- a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_route_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_route_fragment.xml @@ -6,22 +6,6 @@ android:padding="@dimen/dp_40" android:background="@android:color/transparent"> - - - - - - - - - - - - - - - - @@ -249,22 +233,52 @@ - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-common-module/src/main/res/drawable-nodpi/count_down_rotate_bg.png b/OCH/mogo-och-common-module/src/main/res/drawable-nodpi/count_down_rotate_bg.png index 3e49a07b00..9f33e0d8dd 100644 Binary files a/OCH/mogo-och-common-module/src/main/res/drawable-nodpi/count_down_rotate_bg.png and b/OCH/mogo-och-common-module/src/main/res/drawable-nodpi/count_down_rotate_bg.png differ diff --git a/OCH/mogo-och-common-module/src/main/res/layout/dialog_bus_commit.xml b/OCH/mogo-och-common-module/src/main/res/layout/dialog_bus_commit.xml index ab121f0d7e..0dcd9c9048 100644 --- a/OCH/mogo-och-common-module/src/main/res/layout/dialog_bus_commit.xml +++ b/OCH/mogo-och-common-module/src/main/res/layout/dialog_bus_commit.xml @@ -10,8 +10,8 @@ { - mLiveShadow.setVisibility(View.GONE); - } - ); - - mLiveBtn.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View v) { - mLiveShadow.setVisibility(mLiveShadow.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); - return true; - } - }); - CallerTelematicListenerManager.INSTANCE.addListener(TAG, new IReceivedMsgListener() { - @Override - public void onReceivedServerSn(@Nullable String sn) { - - } - - @Override - public void onReceivedMsg(int type, @NonNull byte[] byteArray) { - if (type == TelematicConstant.CONTROL_PASSENGER_DRIVER_MONITOR) { - switch (new String(byteArray)) { - // 乘客端开启漫游 - case "0": { - mLiveShadow.setVisibility(View.GONE); - break; - } - // 乘客端关闭漫游 - case "1": { - mLiveShadow.setVisibility(View.VISIBLE); - break; - } - } - } - } - }); showRouteFragment(); diff --git a/OCH/mogo-och-shuttle-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-shuttle-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml index a15c7f5b90..841a1aefed 100644 --- a/OCH/mogo-och-shuttle-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-shuttle-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml @@ -54,17 +54,17 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> - + + + + + + + + + + +