| | |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | currentIndex = 0; |
| | | initView(); |
| | | showFragment(); |
| | | postEventBus(MessageFunctionTabSwitch.nascent); |
| | | |
| | | } |
| | | }); |
| | |
| | | currentIndex = 1; |
| | | initView(); |
| | | showFragment(); |
| | | postEventBus(MessageFunctionTabSwitch.recover); |
| | | |
| | | } |
| | | }); |
| | |
| | | currentIndex = 2; |
| | | initView(); |
| | | showFragment(); |
| | | postEventBus(MessageFunctionTabSwitch.all); |
| | | } |
| | | }); |
| | | } |
| | |
| | | viewBinding.line2V.setVisibility(View.GONE); |
| | | viewBinding.line3V.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void initData() { |
| | |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setTopic(ConstantManage.message_function_tab_switch); |
| | | baseEventBus.setType(tabSwitch.toString()); |
| | | EventBus.getDefault().post(baseEventBus); |
| | | //发送粘性事件(如果不发粘性事件会遇到一个没有加载出来的碎片接收不到信息) |
| | | EventBus.getDefault().postSticky(baseEventBus); |
| | | } |
| | | |
| | | |
| | |
| | | //把当前显示的fragment记录下来 |
| | | currentFragment = fragmentList.get(currentIndex); |
| | | |
| | | if (this.currentIndex == 0) { |
| | | postEventBus(MessageFunctionTabSwitch.nascent); |
| | | } else if (this.currentIndex == 1) { |
| | | postEventBus(MessageFunctionTabSwitch.recover); |
| | | } else if (this.currentIndex == 2) { |
| | | postEventBus(MessageFunctionTabSwitch.all); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) |
| | | public void onEventMessage(BaseEventBus eventBus) { |
| | | super.onEventMessage(eventBus); |
| | | if (eventBus == null) { |
| | | return; |
| | | } |
| | | //接收外部点击事件 |
| | | if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) { |
| | | if (eventBus.getType().equals(HomepageTitleTabSwitch.message.toString())) { |
| | | postEventBus(MessageFunctionTabSwitch.nascent); |
| | | HdlLogLogic.print("正在点击【消息】"); |
| | | // 取消粘性事件 |
| | | EventBus.getDefault().removeStickyEvent(eventBus); |
| | | |
| | | } |
| | | } |
| | | } |