| | |
| | | import com.ziang.driver.utils.AudioRecoderUtils |
| | | import kotlinx.android.synthetic.main.dialog_voice_order.* |
| | | import org.greenrobot.eventbus.EventBus |
| | | import org.greenrobot.eventbus.Subscribe |
| | | import org.greenrobot.eventbus.ThreadMode |
| | | import org.jetbrains.anko.longToast |
| | | import org.jetbrains.anko.startActivity |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | lateinit var time: CountDownTimer |
| | | private val audioRecoderUtils by lazy { AudioRecoderUtils() } |
| | | |
| | | |
| | | override fun onCreate(savedInstanceState: Bundle?) { |
| | | super.onCreate(savedInstanceState) |
| | | EventBus.getDefault().register(this) |
| | | var strBtn = "抢单" |
| | | if (type == 2) { |
| | | strBtn = "确定" |
| | | } |
| | | time = timeOver((timeDown!!.toLong() * 1000L)) { |
| | | if (it == 0) { |
| | | audioRecoderUtils.stopPlayMusic() |
| | | finish() |
| | | } else { |
| | | tv_sure.text = strBtn + it.toString() + "S" |
| | | } |
| | | } |
| | | tv_close.clickDelay { |
| | | audioRecoderUtils.stopPlayMusic() |
| | | finish() |
| | | } |
| | | tv_sure.clickDelay { |
| | | showGetOrder() |
| | | } |
| | | if (needPlayRing) |
| | | AudioRecoderUtils().startplayMusic(this,Const.voiceOrder) |
| | | iv_voice.postDelayed({ |
| | | audioRecoderUtils.startplayMusic(this,if (fromList) audio else MyApplication.voiceOrder?.audioLinkUrl) |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.APP_LOG,"实际播放路径:${if (fromList) audio else MyApplication.voiceOrder?.audioLinkUrl}")) |
| | | },2000) |
| | | iv_voice.clickDelay { |
| | | audioRecoderUtils.startplayMusic(this,if (fromList) audio else MyApplication.voiceOrder?.audioLinkUrl) |
| | | if (needPlayRing){ |
| | | AudioRecoderUtils.getInstance().startplayMusic(this, Const.voiceOrder) |
| | | if (fromList){ |
| | | AudioRecoderUtils.getInstance().startplayMusic(this, audio) |
| | | }else{ |
| | | AudioRecoderUtils.getInstance().startplayMusic(this, MyApplication.voiceOrder?.audioLinkUrl) |
| | | } |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.APP_LOG,"弹窗订单id:$orderId ,声音路径:$audio")) |
| | | } |
| | | |
| | | iv_voice.postDelayed({ |
| | | if (!isFinishing){ |
| | | // AudioRecoderUtils.getInstance().startplayMusic( |
| | | // this, |
| | | // if (fromList) audio else MyApplication.voiceOrder?.audioLinkUrl |
| | | // ) |
| | | } |
| | | EventBus.getDefault().post( |
| | | BaseEvent( |
| | | BaseEvent.APP_LOG, |
| | | "实际播放路径:${if (fromList) audio else MyApplication.voiceOrder?.audioLinkUrl}" |
| | | ) |
| | | ) |
| | | }, 500) |
| | | iv_voice.clickDelay { |
| | | AudioRecoderUtils.getInstance().startplayMusic( |
| | | this, |
| | | if (fromList) audio else MyApplication.voiceOrder?.audioLinkUrl |
| | | ) |
| | | } |
| | | EventBus.getDefault() |
| | | .post(BaseEvent(BaseEvent.APP_LOG, "弹窗订单id:$orderId ,声音路径:$audio")) |
| | | } |
| | | |
| | | override fun initView() { |
| | |
| | | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | EventBus.getDefault().unregister(this) |
| | | // AudioRecoderUtils.getInstance().stopPlayMusic() |
| | | time.cancel() |
| | | } |
| | | |
| | |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.APP_LOG,"抢单成功的id:$id")) |
| | | startActivity<CallOrderActivity>( |
| | | "orderId" to id, |
| | | "orderType" to orderType) |
| | | audioRecoderUtils.stopPlayMusic() |
| | | "orderType" to orderType |
| | | ) |
| | | |
| | | finish() |
| | | } |
| | | } |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | open fun onEventMainThread(event: BaseEvent) { |
| | | when (event.code) { |
| | | BaseEvent.ORDER_GRAB_EVENT -> { |
| | | if (orderId == event.msg) |
| | | finish() |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |