diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/model/TicketModel.kt b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/model/TicketModel.kt index 0af4f82efc..fd220686cb 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/model/TicketModel.kt +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/model/TicketModel.kt @@ -28,6 +28,9 @@ import com.mogo.och.common.module.biz.network.OchCommonServiceCallback import com.mogo.och.common.module.manager.loopmanager.BizLoopManager import com.mogo.och.common.module.manager.loopmanager.LoopInfo import com.mogo.och.common.module.voice.VoiceNotice.showNotice +import io.reactivex.Observable +import io.reactivex.ObservableEmitter +import io.reactivex.ObservableOnSubscribe import io.reactivex.schedulers.Schedulers object TicketModel : IReceivedMsgListener, IMogoOnMessageListener { @@ -36,6 +39,10 @@ object TicketModel : IReceivedMsgListener, IMogoOnMessageListener?=null + + private val observable = Observable.create(ObservableOnSubscribe { emitter -> emitterMain = emitter }) + init { //监听乘客屏发来的消息 @@ -91,11 +98,14 @@ object TicketModel : IReceivedMsgListener, IMogoOnMessageListener{ override fun onSuccess(data: WriteOffCountResponse?) { - + data?.data?.let { + emitterMain?.onNext(it) + d(SceneConstant.M_BUS + TAG, "${busNextStation.name}核销人数:${it}") + } } override fun onFail(code: Int, msg: String?) { @@ -104,6 +114,10 @@ object TicketModel : IReceivedMsgListener, IMogoOnMessageListener{ + return observable + } + private fun receiveWrteOffInfo(writeOffMsg: WriteOffMsg?) { if(writeOffMsg!=null) { if (writeOffMsg.isScuccess != null) { diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/net/OrderServiceManager.kt b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/net/OrderServiceManager.kt index 0941e4f2b0..6792800f9e 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/net/OrderServiceManager.kt +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/net/OrderServiceManager.kt @@ -206,14 +206,14 @@ object OrderServiceManager { @JvmStatic fun queryBusTaskByLineId( context: Context, - lineId: String?, + taskId: String?, siteId: String?, callback: OchCommonServiceCallback? ) { mService.writeOffCount( MoGoAiCloudClientConfig.getInstance().serviceAppId, SharedPrefsMgr.getInstance().token, - lineId, + taskId, siteId ) .transformTry() diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/writeoff/WriteOffView.kt b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/writeoff/WriteOffView.kt index c88d749fcd..c3542fc18a 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/writeoff/WriteOffView.kt +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/writeoff/WriteOffView.kt @@ -7,6 +7,7 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.findViewTreeViewModelStoreOwner import com.mogo.och.bus.R +import kotlinx.android.synthetic.main.shuttle_wirte_off_view.view.tv_write_off_count class WriteOffView : ConstraintLayout, WriteOffViewModel.IwriteOffViewCallback { @@ -45,5 +46,9 @@ class WriteOffView : ConstraintLayout, WriteOffViewModel.IwriteOffViewCallback { } } + override fun setWriteOffCount(showText: String) { + tv_write_off_count.text = showText + } + } \ No newline at end of file diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/writeoff/WriteOffViewModel.kt b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/writeoff/WriteOffViewModel.kt index 11c943b451..297d35b959 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/writeoff/WriteOffViewModel.kt +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/bus/ui/writeoff/WriteOffViewModel.kt @@ -1,29 +1,68 @@ package com.mogo.och.bus.ui.writeoff import androidx.lifecycle.ViewModel +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.och.bus.R +import com.mogo.och.bus.model.TicketModel +import com.mogo.och.common.module.utils.RxUtils +import io.reactivex.Observable +import io.reactivex.Observer +import io.reactivex.disposables.Disposable -class WriteOffViewModel: ViewModel() { +class WriteOffViewModel : ViewModel() { private val TAG = WriteOffViewModel::class.java.simpleName - private var viewCallback:IwriteOffViewCallback?=null + private var viewCallback: IwriteOffViewCallback? = null init { } - fun setWriteOffCallback(viewCallback:IwriteOffViewCallback){ - this.viewCallback = viewCallback - } + private var disposable: Disposable? = null + + private val observer = object : Observer { + override fun onSubscribe(d: Disposable) { + disposable = d + } + + override fun onError(e: Throwable) { + + } + + override fun onComplete() { + + } + + override fun onNext(countInfo: String) { + viewCallback?.setWriteOffCount(countInfo) + } + + } + + fun setWriteOffCallback(viewCallback: IwriteOffViewCallback) { + this.viewCallback = viewCallback + TicketModel + .getWriteOffCountObservable() + .flatMap { t -> + val showText = + AbsMogoApplication.getApp().getString(R.string.shuttle_write_off_count, t) + CallerLogger.d(SceneConstant.M_BUS + TAG, "显示文案:${showText}") + Observable.just(showText) + } + .subscribe(observer) + } override fun onCleared() { super.onCleared() this.viewCallback = null - + RxUtils.disposeSubscribe(disposable) } - interface IwriteOffViewCallback{ - + interface IwriteOffViewCallback { + fun setWriteOffCount(count:String) } } \ No newline at end of file diff --git a/OCH/shuttle/driver/src/main/res/layout/shuttle_wirte_off_view.xml b/OCH/shuttle/driver/src/main/res/layout/shuttle_wirte_off_view.xml index 4bb58d8511..d549ca9937 100644 --- a/OCH/shuttle/driver/src/main/res/layout/shuttle_wirte_off_view.xml +++ b/OCH/shuttle/driver/src/main/res/layout/shuttle_wirte_off_view.xml @@ -8,7 +8,7 @@ android:id="@+id/no_line_data_view"> + android:text="@string/shuttle_write_off_count_default"/> \ No newline at end of file diff --git a/OCH/shuttle/driver/src/main/res/values/strings.xml b/OCH/shuttle/driver/src/main/res/values/strings.xml index 4d190f9d75..dbde761190 100644 --- a/OCH/shuttle/driver/src/main/res/values/strings.xml +++ b/OCH/shuttle/driver/src/main/res/values/strings.xml @@ -39,7 +39,8 @@ 取消 暂无任务 - 本站核销成功:%1$s人 + 本站核销成功:%1$d人 + 本站核销成功:0人