| | |
| | | import com.android.app_base.manager.AppManager; |
| | | import com.android.app_base.utils.ScreenSizeUtils; |
| | | import com.android.app_base.utils.Utils; |
| | | import com.android.app_base.utils.rxbus.MessageEvent; |
| | | import com.android.app_base.utils.rxbus.RxBus; |
| | | import com.android.app_base.widget.LinearItemDecoration; |
| | | import com.application.zhangshi_app_android.BR; |
| | |
| | | binding.recyclerView.setAdapter(adapter); |
| | | //右上角操作弹窗 |
| | | mOperatePopupWindow = initPopUpWindow(View.inflate(this,R.layout.pop_operate,null)); |
| | | mOperatePopupWindow.getContentView().findViewById(R.id.layout_own_top).setVisibility(View.GONE); |
| | | setOnClickListener( |
| | | mOperatePopupWindow.getContentView().findViewById(R.id.tv_add), |
| | | mOperatePopupWindow.getContentView().findViewById(R.id.tv_select), |
| | |
| | | adapter.setData(beans); |
| | | } |
| | | ); |
| | | viewModel.getBeanLiveData().observe(this, tourismBean -> { |
| | | adapter.updateData(tourismBean); |
| | | }); |
| | | viewModel.getCheckListLiveData().observe(this, (Observer<List<TourismBean>>) beans -> { |
| | | if (viewModel.getOperateTypeLiveData().getValue() == 0){ |
| | | return; |
| | |
| | | adapter.removeItem(bean); |
| | | } |
| | | }); |
| | | //观察数据的变化 |
| | | RxBus.getInstance().toObservable(this, MessageEvent.class) |
| | | .subscribe(bean -> { |
| | | if (bean.getMessageEventCode() == MessageEvent.EVENT_TOURISM_CONSUME_CHANGE){ |
| | | viewModel.getTourismById(bean.getMessageEventData().toString()); |
| | | } |
| | | }); |
| | | //观察数据的变化,有变化包括添加、修改、删除都会发送消息,接收到消息后重新获取数据 |
| | | RxBus.getInstance().toObservable(this, TourismBean.class) |
| | | .subscribe(bean -> { |