| | |
| | | import com.hdl.photovoltaic.base.CustomBaseFragment; |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | | import com.hdl.photovoltaic.databinding.FragmentMessageBinding; |
| | | import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; |
| | | import com.hdl.photovoltaic.enums.MessageFunctionTabSwitch; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | viewBinding.line1V.setVisibility(View.GONE); |
| | | viewBinding.line2V.setVisibility(View.VISIBLE); |
| | | viewBinding.line3V.setVisibility(View.GONE); |
| | | postEventBus(HdlCommonLogic.MessageFunctionTabSwitch.nascent); |
| | | postEventBus(MessageFunctionTabSwitch.nascent); |
| | | } else if (this.currentIndex == 1) { |
| | | viewBinding.messageTabAllTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | | viewBinding.messageTabNascentTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | |
| | | viewBinding.line1V.setVisibility(View.GONE); |
| | | viewBinding.line2V.setVisibility(View.GONE); |
| | | viewBinding.line3V.setVisibility(View.VISIBLE); |
| | | postEventBus(HdlCommonLogic.MessageFunctionTabSwitch.recover); |
| | | postEventBus(MessageFunctionTabSwitch.recover); |
| | | } else if (this.currentIndex == 2) { |
| | | viewBinding.messageTabAllTitleTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null)); |
| | | viewBinding.messageTabNascentTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | |
| | | viewBinding.line1V.setVisibility(View.VISIBLE); |
| | | viewBinding.line2V.setVisibility(View.GONE); |
| | | viewBinding.line3V.setVisibility(View.GONE); |
| | | postEventBus(HdlCommonLogic.MessageFunctionTabSwitch.all); |
| | | postEventBus(MessageFunctionTabSwitch.all); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @param tabSwitch - |
| | | */ |
| | | private void postEventBus(HdlCommonLogic.MessageFunctionTabSwitch tabSwitch) { |
| | | private void postEventBus(MessageFunctionTabSwitch tabSwitch) { |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setTopic(ConstantManage.message_function_tab_switch); |
| | | baseEventBus.setType(tabSwitch + ""); |
| | | baseEventBus.setType(tabSwitch.toString()); |
| | | EventBus.getDefault().post(baseEventBus); |
| | | } |
| | | |
| | |
| | | //如果之前没有添加过 |
| | | if (!fragmentList.get(currentIndex).isAdded()) { |
| | | //第三个参数为添加当前的fragment时绑定一个tag |
| | | ft.hide(currentFragment) |
| | | .add(R.id.message_fcv, fragmentList.get(currentIndex), currentIndex + ""); |
| | | ft.hide(currentFragment).add(R.id.message_fcv, fragmentList.get(currentIndex), currentIndex + ""); |
| | | } else { |
| | | ft.hide(currentFragment) |
| | | .show(fragmentList.get(currentIndex)); |
| | | ft.hide(currentFragment).show(fragmentList.get(currentIndex)); |
| | | } |
| | | currentFragment = fragmentList.get(currentIndex); |
| | | ft.commit(); |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onEventMessage(BaseEventBus eventBus) { |
| | | super.onEventMessage(eventBus); |
| | | //接收外部点击事件 |
| | | if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) { |
| | | if (eventBus.getType().equals(HomepageTitleTabSwitch.message.toString())) { |
| | | postEventBus(MessageFunctionTabSwitch.nascent); |
| | | HdlLogLogic.print("正在点击【消息】"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |