mac
2024-05-22 4598b51c90c695c9ccbe5350a84e4a46b9d8e587
app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java
@@ -12,6 +12,7 @@
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.google.gson.Gson;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.base.CustomBaseFragment;
@@ -28,7 +29,7 @@
import com.hdl.photovoltaic.ui.adapter.MessageAdapter;
import com.hdl.photovoltaic.ui.bean.MessageBean;
import com.hdl.photovoltaic.ui.bean.UnCountBean;
import com.hdl.photovoltaic.widget.TypeTitleListDialog;
import com.hdl.photovoltaic.widget.BTypeTitleListDialog;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import org.greenrobot.eventbus.EventBus;
@@ -117,7 +118,14 @@
        viewBinding.messageSearchCl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String messageStateType;
                if (isAlarmDeviceClick) {
                    messageStateType = MessageStateType.untreated;
                } else {
                    messageStateType = MessageStateType.processed;
                }
                Intent intent = new Intent();
                intent.putExtra("MessageStateType", messageStateType);
                intent.setClass(_mActivity, SearchMessageActivity.class);
                startActivity(intent);
            }
@@ -151,21 +159,7 @@
                viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.up);
                viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down);
                viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down);
                List<String> stringList = getTypeList(FilterType.deviceType);
                TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList);
                typeTitleListDialog.show();
                typeTitleListDialog.setOnListener(new TypeTitleListDialog.OnClickListener() {
                    @Override
                    public void onClick(int position, String title) {
                        viewBinding.allDeviceTitleTv.setText(title);
                        mDeviceTypeFilterKye = FilterType.deviceType;
                        mDeviceTypeFilterValue = findFilterValueString(title);
                        loadNextPageMessageList(true, 1, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true);
                    }
                });
                setTypeTitleListDialog(viewBinding.allDeviceTitleTv, FilterType.deviceType, getTypeList(FilterType.deviceType));
            }
        });
@@ -176,18 +170,8 @@
                viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down);
                viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.up);
                viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down);
                List<String> stringList = getTypeList(FilterType.type);
                TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList);
                typeTitleListDialog.show();
                typeTitleListDialog.setOnListener(new TypeTitleListDialog.OnClickListener() {
                    @Override
                    public void onClick(int position, String title) {
                        viewBinding.allGradeTitleTv.setText(title);
                        mTypeFilterKye = FilterType.type;
                        mTypeFilterValue = findFilterValueString(title);
                        loadNextPageMessageList(true, 1, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true);
                    }
                });
                setTypeTitleListDialog(viewBinding.allGradeTitleTv, FilterType.type, getTypeList(FilterType.type));
            }
        });
        //全部时间(当天、近3天、近7天、近30天)按钮
@@ -197,18 +181,7 @@
                viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down);
                viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down);
                viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.up);
                List<String> stringList = getTypeList(FilterType.timeType);
                TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList);
                typeTitleListDialog.show();
                typeTitleListDialog.setOnListener(new TypeTitleListDialog.OnClickListener() {
                    @Override
                    public void onClick(int position, String title) {
                        viewBinding.allTimeTitleTv.setText(title);
                        mTimeTypeFilterKye = FilterType.timeType;
                        mTimeTypeFilterValue = findFilterValueString(title);
                        loadNextPageMessageList(true, 1, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true);
                    }
                });
                setTypeTitleListDialog(viewBinding.allTimeTitleTv, FilterType.timeType, getTypeList(FilterType.timeType));
            }
        });
@@ -248,13 +221,49 @@
                @Override
                public void onClick(int position, MessageBean messageBean) {
                    Intent intent = new Intent();
                    intent.putExtra("msgId", messageBean.getMsgId().toString());
                    intent.putExtra("messageBean",new Gson().toJson(messageBean));
                    intent.setClass(_mActivity, MessageInfoActivity.class);
                    startActivity(intent);
                }
            });
        }
    }
    /**
     * 类型筛选
     *
     * @param textView   组件显示
     * @param filterType 过滤类型
     * @param stringList 过滤类型值表
     */
    private void setTypeTitleListDialog(TextView textView, String filterType, List<String> stringList) {
        BTypeTitleListDialog typeTitleListDialog = new BTypeTitleListDialog(_mActivity, stringList);
        typeTitleListDialog.show();
        typeTitleListDialog.setOnListener(new BTypeTitleListDialog.OnClickListener() {
            @Override
            public void onClick(int position, String title) {
                textView.setText(title);
                switch (filterType) {
                    case FilterType.deviceType: {
                        mDeviceTypeFilterKye = filterType;
                        mDeviceTypeFilterValue = findFilterValueString(title);
                    }
                    break;
                    case FilterType.type: {
                        mTypeFilterKye = filterType;
                        mTypeFilterValue = findFilterValueString(title);
                    }
                    break;
                    case FilterType.timeType: {
                        mTimeTypeFilterKye = filterType;
                        mTimeTypeFilterValue = findFilterValueString(title);
                    }
                    break;
                }
                loadNextPageMessageList(true, 1, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true);
            }
        });
    }
@@ -290,7 +299,7 @@
                // 取消粘性事件
                EventBus.getDefault().removeStickyEvent(eventBus);
                //进来读取一次数据(为了更新currentPage,currentTotal这个值)
                initData();
//                initData();
                HdlLogLogic.print("正在点击【消息】");
            }
@@ -509,10 +518,15 @@
            @Override
            public void onFailure(HDLException e) {
                TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv);
                if (textView != null) {
                    textView.setVisibility(View.GONE);
                }
                HdlThreadLogic.runMainThread(new Runnable() {
                    @Override
                    public void run() {
                        TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv);
                        if (textView != null) {
                            textView.setVisibility(View.GONE);
                        }
                    }
                });
            }
        });
    }