[m1]
[1.1.2] [通讯]
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.mogo.och.bus.passenger.bean.response
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
|
||||
/**
|
||||
*/
|
||||
data class LineInfoListResponse(val data: List<LineInfoResponse.LineInfo>?) : BaseData() {
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ object CharterPassengerModel {
|
||||
// 路距计算
|
||||
private const val TAGDISTANCE = "BusPassengerModelDistance"
|
||||
|
||||
private lateinit var mContext: Context
|
||||
private var mContext: Context = AbsMogoApplication.getApp()
|
||||
|
||||
//Model->Presenter:自动驾驶状态相关
|
||||
var mADASStatusCallback: IBusPassengerADASStatusCallback? = null
|
||||
@@ -66,7 +66,6 @@ object CharterPassengerModel {
|
||||
private var locusInfo: LocusResponse.LocusInfo? = null
|
||||
|
||||
fun init() {
|
||||
AbsMogoApplication.getApp().also { this.mContext = it }
|
||||
initListeners()
|
||||
queryLoginStatus()
|
||||
}
|
||||
@@ -114,7 +113,6 @@ object CharterPassengerModel {
|
||||
object : LoginStatusManager.ILoginStatusChangeListener {
|
||||
override fun onStatusChange(currentStatus: TaxiLoginStatusEnum) {
|
||||
if (LoginStatusManager.isLogin()) {
|
||||
// todo 关闭轮训在特定时机进行登录状态查下
|
||||
// 1、打开视频播放、
|
||||
// 2 、打开空调暖风机灯设置页面
|
||||
// 3、车控页面、
|
||||
|
||||
@@ -38,7 +38,7 @@ object BusPassengerServiceManager {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryLineList(context: Context, callback: OchCommonServiceCallback<LineInfoResponse>?) {
|
||||
fun queryLineList(context: Context, callback: OchCommonServiceCallback<LineInfoListResponse>?) {
|
||||
mBusPassengerServiceApi.queryLineList().transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "lineList"))
|
||||
}
|
||||
@@ -57,7 +57,7 @@ object BusPassengerServiceManager {
|
||||
@JvmStatic
|
||||
fun queryBusinessStatus(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<BusinessStatusResponse>?
|
||||
callback: OchCommonServiceCallback<BusinessStatusResponse>
|
||||
) {
|
||||
mBusPassengerServiceApi.queryBusinessStatus().transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "businessStatus"))
|
||||
|
||||
@@ -41,7 +41,7 @@ internal interface PassengerServiceApi {
|
||||
@Header("appId") appId: String = MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
@Header("ticket") ticket: String=MoGoAiCloudClientConfig.getInstance().token,
|
||||
@Query("sn") sn: String = CallerTelematicManager.getServerToken()
|
||||
): Observable<LineInfoResponse>
|
||||
): Observable<LineInfoListResponse>
|
||||
|
||||
/**
|
||||
* 04查询所选线路的站点 10
|
||||
|
||||
@@ -12,12 +12,18 @@ import com.mogo.och.bus.passenger.bean.response.LineInfoResponse
|
||||
/**
|
||||
* Created by adityagohad on 06/06/17.
|
||||
*/
|
||||
class OrderLineItemAdapter(private val context: Context, private val dataList: List<LineInfoResponse.Result>) : RecyclerView.Adapter<OrderLineItemAdapter.TextVH>() {
|
||||
class OrderLineItemAdapter(private val context: Context, private val dataList: MutableList<LineInfoResponse.LineInfo>) : RecyclerView.Adapter<OrderLineItemAdapter.TextVH>() {
|
||||
|
||||
private var checkIndex = -1
|
||||
|
||||
var checkChangeListener:CheckListener?=null
|
||||
|
||||
fun setDataList(dataList: List<LineInfoResponse.LineInfo>){
|
||||
this.dataList.clear()
|
||||
this.dataList.addAll(dataList)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TextVH {
|
||||
val view: View
|
||||
@@ -48,7 +54,7 @@ class OrderLineItemAdapter(private val context: Context, private val dataList: L
|
||||
}
|
||||
|
||||
interface CheckListener{
|
||||
fun onCheckListener(lineInfo:LineInfoResponse.Result)
|
||||
fun onCheckListener(lineInfo:LineInfoResponse.LineInfo)
|
||||
}
|
||||
|
||||
inner class TextVH(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
@@ -16,13 +16,20 @@ import com.mogo.och.bus.passenger.bean.response.SiteInfoResponse
|
||||
/**
|
||||
* Created by adityagohad on 06/06/17.
|
||||
*/
|
||||
class OrderSiteItemAdapter(private val context: Context, private val dataList: List<SiteInfoResponse.SiteInfo>) : RecyclerView.Adapter<OrderSiteItemAdapter.TextVH>() {
|
||||
class OrderSiteItemAdapter(private val context: Context, private val dataList: MutableList<SiteInfoResponse.SiteInfo>) : RecyclerView.Adapter<OrderSiteItemAdapter.TextVH>() {
|
||||
|
||||
private var checkIndex = -1
|
||||
private var enableIndex = -1
|
||||
|
||||
var checkChangeListener:CheckListener?=null
|
||||
|
||||
|
||||
fun setDataList(dataList: List<SiteInfoResponse.SiteInfo>){
|
||||
this.dataList.clear()
|
||||
this.dataList.addAll(dataList)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setEnableIndex(enableIndex:Int){
|
||||
this.enableIndex = enableIndex
|
||||
notifyDataSetChanged()
|
||||
|
||||
@@ -8,17 +8,26 @@ import android.view.View
|
||||
import android.view.animation.LinearInterpolator
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.mogo.eagle.core.data.telematic.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.call.telematic.CallerTelematicManager
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoListResponse
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoResponse
|
||||
import com.mogo.och.bus.passenger.bean.response.SiteInfoResponse
|
||||
import com.mogo.och.bus.passenger.model.CharterPassengerModel
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.ui.adapter.OrderLineItemAdapter
|
||||
import com.mogo.och.bus.passenger.ui.adapter.OrderSiteItemAdapter
|
||||
import com.mogo.och.bus.passenger.view.BottomDecoration
|
||||
import com.mogo.och.bus.passenger.view.RecyclerViewCornerRadius
|
||||
import com.mogo.och.common.module.bean.dpmsg.ChangeDestMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import kotlinx.android.synthetic.m1.m1_order_lineside.view.*
|
||||
import kotlinx.android.synthetic.m1.m1_soft_fragment.*
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
|
||||
class LineSiteView @JvmOverloads constructor(
|
||||
@@ -27,14 +36,19 @@ class LineSiteView @JvmOverloads constructor(
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private var checkLine: LineInfoResponse.Result?=null
|
||||
private var checkSite: SiteInfoResponse.SiteInfo?=null
|
||||
companion object{
|
||||
const val TAG = "LineSiteView"
|
||||
}
|
||||
|
||||
private var tempCheckLine: LineInfoResponse.Result?=null
|
||||
private var checkLine: LineInfoResponse.LineInfo?=null
|
||||
private var checkSite: SiteInfoResponse.SiteInfo?=null
|
||||
private var currentSite: SiteInfoResponse.SiteInfo?=null
|
||||
|
||||
private var tempCheckLine: LineInfoResponse.LineInfo?=null
|
||||
private var tempCheckSite: SiteInfoResponse.SiteInfo?=null
|
||||
|
||||
|
||||
private val lineList = mutableListOf<LineInfoResponse.Result>()
|
||||
private val lineList = mutableListOf<LineInfoResponse.LineInfo>()
|
||||
private val siteList = mutableListOf<SiteInfoResponse.SiteInfo>()
|
||||
|
||||
private var lineAdapter: OrderLineItemAdapter
|
||||
@@ -56,27 +70,6 @@ class LineSiteView @JvmOverloads constructor(
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
lineList.add(LineInfoResponse.Result("路线名称1",1))
|
||||
lineList.add(LineInfoResponse.Result("路线名称2",2))
|
||||
lineList.add(LineInfoResponse.Result("路线名称3",3))
|
||||
lineList.add(LineInfoResponse.Result("路线名称4",4))
|
||||
lineList.add(LineInfoResponse.Result("路线名称5",5))
|
||||
lineList.add(LineInfoResponse.Result("路线名称6",6))
|
||||
lineList.add(LineInfoResponse.Result("路线名称7",7))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",1,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",2,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",3,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",4,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",5,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",6,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",7,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",8,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",9,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",10,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",11,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",12,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
siteList.add(SiteInfoResponse.SiteInfo(1,"线路id",13,"站点名称",0.0,0.0,0.0,0.0,0.0,0))
|
||||
|
||||
rlv_line_list.layoutManager = LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false)
|
||||
rlv_line_list.addItemDecoration(BottomDecoration(AutoSizeUtils.dp2px(context,60f)))
|
||||
rlv_line_list.adapter = lineAdapter
|
||||
@@ -85,13 +78,25 @@ class LineSiteView @JvmOverloads constructor(
|
||||
rv_site_list.addItemDecoration(BottomDecoration(AutoSizeUtils.dp2px(context,60f)))
|
||||
rv_site_list.adapter = siteAdapter
|
||||
|
||||
val hasSetLineAndSite = CharterPassengerModel.hasSetLineAndSite()
|
||||
if (hasSetLineAndSite!=null) {// 已经设置了线路和站点
|
||||
lineList.add(hasSetLineAndSite.first)
|
||||
checkLine = hasSetLineAndSite.first
|
||||
checkSite = hasSetLineAndSite.second
|
||||
checkLine?.let {
|
||||
querySitesByLineId(it.lineId.toString())
|
||||
}
|
||||
}else{
|
||||
queryLineList()
|
||||
}
|
||||
|
||||
initListener()
|
||||
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
lineAdapter.checkChangeListener = object :OrderLineItemAdapter.CheckListener{
|
||||
override fun onCheckListener(lineInfo: LineInfoResponse.Result) {
|
||||
override fun onCheckListener(lineInfo: LineInfoResponse.LineInfo) {
|
||||
ToastUtils.showLong("选中线路${lineInfo} 对比当前坐标计算需要禁用的站点")
|
||||
tempCheckLine = lineInfo
|
||||
siteAdapter.clearCheck()
|
||||
@@ -109,14 +114,53 @@ class LineSiteView @JvmOverloads constructor(
|
||||
ToastUtils.showLong("取消切换")
|
||||
}
|
||||
tv_line_submit.onClick {
|
||||
ToastUtils.showLong("向司机端确认弹出loading 并启动轮询查看是否正常连接司机端、等待结果")
|
||||
if (tempCheckLine==null) {
|
||||
ToastUtils.showLong("请选择线路")
|
||||
return@onClick
|
||||
}
|
||||
tempCheckLine?.let {
|
||||
val msg = ChangeDestMsg(
|
||||
it.lineId!!.toInt(),
|
||||
it.name!!,
|
||||
0,
|
||||
"",
|
||||
0,
|
||||
"",
|
||||
false
|
||||
)
|
||||
CallerTelematicManager.sendMsgToServer(
|
||||
TelematicConstant.BUSINESS_STRING,
|
||||
GsonUtils.toJson(msg).toByteArray()
|
||||
)
|
||||
}
|
||||
startAni()
|
||||
}
|
||||
tv_site_cancle.onClick {
|
||||
ToastUtils.showLong("取消切换")
|
||||
}
|
||||
tv_site_submit.onClick {
|
||||
ToastUtils.showLong("向司机端确认弹出loading 并启动轮询查看是否正常连接司机端、等待结果")
|
||||
if (tempCheckSite==null) {
|
||||
ToastUtils.showLong("请选择站点")
|
||||
return@onClick
|
||||
}
|
||||
checkLine?.let {lineInfo->
|
||||
tempCheckSite?.let {siteInfo->
|
||||
val msg = ChangeDestMsg(
|
||||
lineInfo.lineId!!.toInt(),
|
||||
lineInfo.name!!,
|
||||
currentSite!!.siteId!!.toInt(),
|
||||
currentSite!!.siteName!!,
|
||||
siteInfo.siteId!!.toInt(),
|
||||
siteInfo.siteName!!,
|
||||
false
|
||||
)
|
||||
CallerTelematicManager.sendMsgToServer(
|
||||
TelematicConstant.BUSINESS_STRING,
|
||||
GsonUtils.toJson(msg).toByteArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
startAni()
|
||||
}
|
||||
tv_switch_line.onClick {
|
||||
ToastUtils.showLong("判断速度是否为0,开始查询线路信息")
|
||||
@@ -124,9 +168,28 @@ class LineSiteView @JvmOverloads constructor(
|
||||
tv_loading_wait_driver_title.onClick {
|
||||
endAni()
|
||||
}
|
||||
|
||||
CallerTelematicListenerManager.addListener(TAG,object : IReceivedMsgListener{
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
if(type==TelematicConstant.BUSINESS_STRING){
|
||||
val msg = GsonUtils.fromJson(String(byteArray),
|
||||
ChangeDestMsg::class.java) as ChangeDestMsg
|
||||
if(msg.type==DPMsgType.TYPE_CHANGE_DEST.type){
|
||||
if(msg.destSiteId==0){
|
||||
// TODO: 选择线路结束
|
||||
ToastUtils.showShort("线路确定")
|
||||
}else{
|
||||
// TODO: 选择站点结束
|
||||
ToastUtils.showShort("站点确定")
|
||||
}
|
||||
endAni()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun startAni(){
|
||||
private fun startAni(){
|
||||
g_lines_sites_data.visibility = View.GONE
|
||||
g_loading_group.visibility = View.VISIBLE
|
||||
if(!loadingAni.isRunning) {
|
||||
@@ -134,7 +197,7 @@ class LineSiteView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun endAni(){
|
||||
private fun endAni(){
|
||||
g_lines_sites_data.visibility = View.VISIBLE
|
||||
g_loading_group.visibility = View.GONE
|
||||
}
|
||||
@@ -143,4 +206,35 @@ class LineSiteView @JvmOverloads constructor(
|
||||
super.onDetachedFromWindow()
|
||||
loadingAni.cancel()
|
||||
}
|
||||
|
||||
private fun queryLineList() {
|
||||
BusPassengerServiceManager.queryLineList(context,object :
|
||||
OchCommonServiceCallback<LineInfoListResponse> {
|
||||
override fun onSuccess(data: LineInfoListResponse?) {
|
||||
if (data?.data == null) return
|
||||
lineAdapter.setDataList(data.data)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("查询线路失败")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun querySitesByLineId(lineId:String) {
|
||||
BusPassengerServiceManager.queryLineSiteList(context,lineId,object :OchCommonServiceCallback<SiteInfoResponse>{
|
||||
override fun onSuccess(data: SiteInfoResponse?) {
|
||||
if (data?.data == null) return
|
||||
siteAdapter.setDataList(data.data)
|
||||
if(data.data.isNotEmpty()) {
|
||||
// TODO: 计算当前站点是那个
|
||||
currentSite = data.data[0]
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
ToastUtils.showShort("查询站点失败")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,9 @@ package com.mogo.och.common.module.bean.dpmsg
|
||||
data class ChangeDestMsg(
|
||||
var lineId: Int, //线路id
|
||||
var lineName: String = "", //线路名称
|
||||
var startSiteId: Int, //当前站点
|
||||
var startSiteId: Int=0, //当前站点
|
||||
var startSiteName: String = "",
|
||||
var destSiteId: Int, //目的地
|
||||
var destSiteId: Int=0, //目的地
|
||||
var destSiteName: String = "",
|
||||
var isConfirmed: Boolean = false //司机端是否同意
|
||||
): BaseDPMsg(DPMsgType.TYPE_CHANGE_DEST.type)
|
||||
|
||||
Reference in New Issue
Block a user