| | |
| | | package com.hdl.photovoltaic.ui.message; |
| | | |
| | | import android.os.Bundle; |
| | | import android.os.SystemClock; |
| | | import android.view.View; |
| | | |
| | | |
| | |
| | | import com.hdl.photovoltaic.enums.MessageFunctionTabSwitch; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.ui.bean.BUserInfo; |
| | | 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; |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | currentIndex = 0; |
| | | showFragment(); |
| | | initView(); |
| | | showFragment(); |
| | | postEventBus(MessageFunctionTabSwitch.nascent); |
| | | |
| | | } |
| | | }); |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | currentIndex = 1; |
| | | showFragment(); |
| | | initView(); |
| | | showFragment(); |
| | | postEventBus(MessageFunctionTabSwitch.recover); |
| | | |
| | | } |
| | | }); |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | currentIndex = 2; |
| | | showFragment(); |
| | | initView(); |
| | | showFragment(); |
| | | postEventBus(MessageFunctionTabSwitch.all); |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | private void initView() { |
| | | if (this.currentIndex == 0) { |
| | | viewBinding.messageTabAllTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | | viewBinding.messageTabNascentTitleTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null)); |
| | | viewBinding.messageTabRecoverTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | | viewBinding.line1V.setVisibility(View.GONE); |
| | | viewBinding.line2V.setVisibility(View.VISIBLE); |
| | | viewBinding.line3V.setVisibility(View.GONE); |
| | | 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.messageTabRecoverTitleTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null)); |
| | | viewBinding.line1V.setVisibility(View.GONE); |
| | | viewBinding.line2V.setVisibility(View.GONE); |
| | | viewBinding.line3V.setVisibility(View.VISIBLE); |
| | | 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.messageTabRecoverTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | | viewBinding.line1V.setVisibility(View.VISIBLE); |
| | | viewBinding.line2V.setVisibility(View.GONE); |
| | | viewBinding.line3V.setVisibility(View.GONE); |
| | | postEventBus(MessageFunctionTabSwitch.all); |
| | | } else if (this.currentIndex == 1) { |
| | | viewBinding.messageTabNascentTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | | viewBinding.messageTabRecoverTitleTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null)); |
| | | viewBinding.messageTabAllTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | | viewBinding.line1V.setVisibility(View.GONE); |
| | | viewBinding.line2V.setVisibility(View.VISIBLE); |
| | | viewBinding.line3V.setVisibility(View.GONE); |
| | | } else if (this.currentIndex == 2) { |
| | | viewBinding.messageTabNascentTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | | viewBinding.messageTabRecoverTitleTv.setTextColor(getResources().getColor(R.color.text80_FFFFFF, null)); |
| | | viewBinding.messageTabAllTitleTv.setTextColor(getResources().getColor(R.color.text_FFFFFFFF, null)); |
| | | viewBinding.line1V.setVisibility(View.GONE); |
| | | 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); |
| | | } |
| | | |
| | | |
| | |
| | | fragmentList.add(mRecoverMessageFragment); |
| | | fragmentList.add(mAllMessageFragment); |
| | | showFragment(); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | currentFragment = fragmentList.get(currentIndex); |
| | | ft.commit(); |
| | | //把当前显示的fragment记录下来 |
| | | currentFragment = fragmentList.get(currentIndex); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | ft.commit(); |
| | | //把当前显示的fragment记录下来 |
| | | currentFragment = fragmentList.get(currentIndex); |
| | | |
| | | } |
| | | |
| | | |
| | | @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); |
| | | |
| | | } |
| | | } |
| | | } |