|
@@ -0,0 +1,220 @@
|
|
|
+package com.wdkl.app.ncs.callingbed.activity
|
|
|
+
|
|
|
+import android.view.View
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
+import com.enation.javashop.net.engine.model.NetState
|
|
|
+import com.wdkl.app.ncs.callingbed.R
|
|
|
+import com.wdkl.app.ncs.callingbed.adapter.AdviceAdapter
|
|
|
+import com.wdkl.app.ncs.callingbed.adapter.TransactionItemAdapter
|
|
|
+import com.wdkl.app.ncs.callingbed.databinding.YzViewLayBinding
|
|
|
+import com.wdkl.app.ncs.callingbed.launch.CallingbedLaunch
|
|
|
+
|
|
|
+import com.wdkl.ncs.android.lib.base.BaseActivity
|
|
|
+import com.wdkl.ncs.android.lib.utils.showMessage
|
|
|
+import com.wdkl.ncs.android.middleware.common.Constant
|
|
|
+import com.wdkl.ncs.android.middleware.common.MessageEvent
|
|
|
+import com.wdkl.ncs.android.middleware.logic.contract.callingbed.BedAdviceFragmentContract
|
|
|
+import com.wdkl.ncs.android.middleware.logic.contract.callingbed.UserTransactionContract
|
|
|
+import com.wdkl.ncs.android.middleware.logic.presenter.callingbed.BedAdviceFragmentPresenter
|
|
|
+import com.wdkl.ncs.android.middleware.logic.presenter.callingbed.UserTransactionPresenter
|
|
|
+import com.wdkl.ncs.android.middleware.model.dos.AdviceDO
|
|
|
+import com.wdkl.ncs.android.middleware.model.dos.UserTransactionDO
|
|
|
+
|
|
|
+import kotlinx.android.synthetic.main.view_title_layout.*
|
|
|
+import kotlinx.android.synthetic.main.yz_view_lay.*
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
+import org.greenrobot.eventbus.ThreadMode
|
|
|
+
|
|
|
+/**
|
|
|
+ * 用户事务
|
|
|
+ * */
|
|
|
+class UserTransactionActivity : BaseActivity<UserTransactionPresenter, YzViewLayBinding>(), UserTransactionContract.View ,TransactionItemAdapter.OnItemTimeClickListener{
|
|
|
+
|
|
|
+ private val TAG = "DoctorsAdviceActivity"
|
|
|
+ private var pageNo = 1
|
|
|
+ private lateinit var adapter: TransactionItemAdapter
|
|
|
+
|
|
|
+ override fun getLayId(): Int {
|
|
|
+ return R.layout.yz_view_lay
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun bindDagger() {
|
|
|
+ CallingbedLaunch.component.inject(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun init() {
|
|
|
+ showui()
|
|
|
+ adapter = TransactionItemAdapter(activity, ArrayList())
|
|
|
+ adapter.listener = this
|
|
|
+ val layoutManager = LinearLayoutManager(activity)
|
|
|
+ rv_advice_main_view.layoutManager = layoutManager
|
|
|
+ rv_advice_main_view.adapter = adapter
|
|
|
+
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
+ presenter.loadTransactionByPage(pageNo, 2, Constant.CUSTOM_ID)
|
|
|
+ } else {
|
|
|
+ showMessage("no custom id")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun bindEvent() {
|
|
|
+
|
|
|
+ //返回上一层
|
|
|
+ view_title_layout_return.setOnClickListener {
|
|
|
+ view_title_layout_img.visibility = View.GONE
|
|
|
+ view_title_layout_tv_no.visibility =View.GONE
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ advice_refresh.setOnRefreshListener {
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
+ pageNo = 1
|
|
|
+ presenter.loadTransactionByPage(pageNo, 2, Constant.CUSTOM_ID)
|
|
|
+ } else {
|
|
|
+ showMessage("no custom id")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ advice_refresh.setOnLoadMoreListener {
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
+ pageNo += 1
|
|
|
+ presenter.loadTransactionByPage(pageNo, 2, Constant.CUSTOM_ID)
|
|
|
+ } else {
|
|
|
+ showMessage("no custom id")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cost_previous_button.setOnClickListener {
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
+ if (pageNo==1){
|
|
|
+ return@setOnClickListener
|
|
|
+ }else{
|
|
|
+ if (pageNo>=1){
|
|
|
+ pageNo -= 1
|
|
|
+ }else{
|
|
|
+ showMessage(R.string.str_first_page)
|
|
|
+ }
|
|
|
+ presenter.loadTransactionByPage(pageNo, 10, Constant.CUSTOM_ID)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ showMessage("no custom id")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cost_next_button.setOnClickListener {
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
+ pageNo += 1
|
|
|
+ presenter.loadTransactionByPage(pageNo, 10, Constant.CUSTOM_ID)
|
|
|
+ } else {
|
|
|
+ showMessage("no custom id")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun showui(){
|
|
|
+ cost_button_ll.visibility = View.GONE
|
|
|
+ view_title_layout_tv_hospital_name.setText(R.string.str_back)
|
|
|
+ view_title_layout_img.visibility = View.VISIBLE
|
|
|
+ view_title_layout_tv_no.visibility = View.VISIBLE
|
|
|
+ view_title_layout_tv_no.text = getString(R.string.str_advice)
|
|
|
+ //网络图标
|
|
|
+ if ( Constant.network_state == 1){
|
|
|
+ view_title_layout_iv_wifi.visibility = View.VISIBLE
|
|
|
+ view_title_layout_iv_ethernet.visibility = View.GONE
|
|
|
+ view_title_layout_iv_wifi.setImageResource(R.mipmap.ic_wifi_success)
|
|
|
+ }else if ( Constant.network_state == 2){
|
|
|
+ view_title_layout_iv_wifi.visibility = View.GONE
|
|
|
+ view_title_layout_iv_ethernet.visibility = View.VISIBLE
|
|
|
+ view_title_layout_iv_ethernet.setImageResource(R.mipmap.ic_ethernet_success)
|
|
|
+ }else{
|
|
|
+ view_title_layout_iv_wifi.visibility = View.GONE
|
|
|
+ view_title_layout_iv_ethernet.visibility = View.VISIBLE
|
|
|
+ view_title_layout_iv_ethernet.setImageResource(R.mipmap.ic_ethernet_fail)
|
|
|
+ }
|
|
|
+ //蓝牙图标
|
|
|
+ if ( Constant.BT_state == 0){
|
|
|
+ view_title_layout_iv_bt.setImageResource(R.mipmap.ic_bt_success)
|
|
|
+ }
|
|
|
+ //白天/黑夜
|
|
|
+ if (Constant.day_state == 0){
|
|
|
+ view_title_layout_iv_day_night.setImageResource(R.mipmap.ic_daylight)
|
|
|
+ }else{
|
|
|
+ view_title_layout_iv_day_night.setImageResource(R.mipmap.ic_night)
|
|
|
+ }
|
|
|
+ view_title_layout_iv_tcp.setImageResource(R.mipmap.ic_tcp_success)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun destory() {
|
|
|
+
|
|
|
+ }
|
|
|
+ override fun onStart() {
|
|
|
+ EventBus.getDefault().register(this)
|
|
|
+ super.onStart()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStop() {
|
|
|
+ EventBus.getDefault().unregister(this)
|
|
|
+ super.onStop()
|
|
|
+ }
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ fun onMoonEvent(messageEvent: MessageEvent) {
|
|
|
+ if (Constant.EVENT_FINISHh == messageEvent.type) {
|
|
|
+ finish()
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun showTransaction(advices: ArrayList<UserTransactionDO>) {
|
|
|
+ advice_refresh.finishRefresh()
|
|
|
+ advice_refresh.finishLoadMore()
|
|
|
+ if(advices.size>0){
|
|
|
+ yz_view_page.text= pageNo.toString()
|
|
|
+ adapter.updateCostData(advices, true)
|
|
|
+ }else{
|
|
|
+ showMessage(R.string.no_more_data)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ override fun onTimeClick(transaction: UserTransactionDO) {
|
|
|
+ if (Constant.DEVICE_ID != -1 && transaction.id !=null) {
|
|
|
+ presenter.loadsetTransaction(transaction.id, Constant.DEVICE_ID, 1)
|
|
|
+ } else {
|
|
|
+ showMessage("no custom id")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun setTransaction(advices: ArrayList<UserTransactionDO>) {
|
|
|
+ if (advices!=null){
|
|
|
+ showMessage(R.string.transaction_set_2)
|
|
|
+ }else{
|
|
|
+ showMessage(R.string.transaction_set_3)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onNoNet() {
|
|
|
+ showMessage("none network")
|
|
|
+ advice_refresh.finishRefresh()
|
|
|
+ advice_refresh.finishLoadMore()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onError(message: String, type: Int) {
|
|
|
+ advice_refresh.finishRefresh()
|
|
|
+ advice_refresh.finishLoadMore()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun complete(message: String, type: Int) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun start() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun networkMonitor(state: NetState) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|