mac
2023-12-29 65ca1786a55107624ffabc9bde0df72118f9ceec
app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java
@@ -1,6 +1,7 @@
package com.hdl.photovoltaic.ui.message;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
@@ -12,8 +13,11 @@
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.photovoltaic.ui.bean.BUserInfo;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import org.greenrobot.eventbus.EventBus;
@@ -61,8 +65,8 @@
            @Override
            public void onClick(View v) {
                currentIndex = 0;
                showFragment();
                initView();
                showFragment();
            }
        });
@@ -71,8 +75,8 @@
            @Override
            public void onClick(View v) {
                currentIndex = 1;
                showFragment();
                initView();
                showFragment();
            }
        });
@@ -82,8 +86,8 @@
            @Override
            public void onClick(View v) {
                currentIndex = 2;
                showFragment();
                initView();
                showFragment();
            }
        });
    }
@@ -91,29 +95,26 @@
    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);
        }
    }
@@ -128,7 +129,7 @@
    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);
    }
@@ -160,8 +161,6 @@
            fragmentList.add(mRecoverMessageFragment);
            fragmentList.add(mAllMessageFragment);
            showFragment();
        }
    }
@@ -175,14 +174,23 @@
        //如果之前没有添加过
        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();
        //把当前显示的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);
        }
    }
    /**
@@ -198,8 +206,20 @@
            }
        }
        ft.commit();
        //把当前显示的fragment记录下来
        currentFragment = fragmentList.get(currentIndex);
    }
    @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("正在点击【消息】");
            }
        }
    }