| File was renamed from app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java |
| | |
| | | import android.content.Intent; |
| | | import android.os.AsyncTask; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | 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; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | | import com.hdl.photovoltaic.databinding.FragmentMessageBinding; |
| | | import com.hdl.photovoltaic.enums.FilterType; |
| | | import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; |
| | | import com.hdl.photovoltaic.enums.MessageStateType; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlMessageLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | 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.BTypeTitleListDialog; |
| | | import com.hdl.photovoltaic.widget.TypeTitleListDialog; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder; |
| | | 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.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 消息模块界面 |
| | | */ |
| | | public class MessageFragment extends CustomBaseFragment { |
| | | public class MessageActivity extends CustomBaseActivity { |
| | | |
| | | private FragmentMessageBinding viewBinding; |
| | | |
| | | private MessageAdapter mMessageAdapter; |
| | | private boolean isAlarmDeviceClick = true;//true表示告警设备被选中,则false表示报警记录被选中 |
| | | |
| | | private MessageBean mMessageBean; |
| | | private final List<MessageBean> mList = new ArrayList<>(); |
| | | |
| | | private boolean isRefreshTotalCount = true; |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF000000)); |
| | | try { |
| | | String json = getIntent().getStringExtra("messageBean"); |
| | | mMessageBean = new Gson().fromJson(json, MessageBean.class); |
| | | if (mMessageBean == null) { |
| | | mMessageBean = new MessageBean(); |
| | | } |
| | | } catch (Exception ignored) { |
| | | if (mMessageBean == null) { |
| | | mMessageBean = new MessageBean(); |
| | | } |
| | | } |
| | | //初始化界面 |
| | | initView(); |
| | | //初始化监听器 |
| | |
| | | } |
| | | |
| | | private void initEvent() { |
| | | |
| | | |
| | | //后退的事件 |
| | | viewBinding.topBackLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HdlCommonLogic.getInstance().postEventBus(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house); |
| | | finish(); |
| | | } |
| | | }); |
| | | //发生中 |
| | | viewBinding.messageTabNascentTitleTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | |
| | | viewBinding.allClearIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (TextUtils.isEmpty(mMessageBean.getHomeId().replace(" ", ""))) { |
| | | return; |
| | | } |
| | | // showLoading(); |
| | | HdlMessageLogic.getInstance().messageAllRead("", new CloudCallBeak<Boolean>() { |
| | | HdlMessageLogic.getInstance().messageAllRead(mMessageBean.getHomeId(), new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | // hideLoading(); |
| | |
| | | if (eventBus == null) { |
| | | return; |
| | | } |
| | | //接收外部点击事件 |
| | | if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) { |
| | | if (eventBus.getType().equals(HomepageTitleTabSwitch.message.toString())) { |
| | | // 取消粘性事件 |
| | | EventBus.getDefault().removeStickyEvent(eventBus); |
| | | //进来读取一次数据(为了更新currentPage,currentTotal这个值) |
| | | // initData(); |
| | | HdlLogLogic.print("正在点击【消息】"); |
| | | |
| | | } |
| | | } else if (eventBus.getTopic().equals(ConstantManage.message_function_push_post)) { |
| | | if (eventBus.getTopic().equals(ConstantManage.message_function_push_post)) { |
| | | if (eventBus.getType().equals(MessageStateType.untreated)) { |
| | | updateListData(); |
| | | }/* else if (eventBus.getType().equals(MessageStateType.processed)) { |
| | |
| | | * @param isClear true表示清空缓存 |
| | | */ |
| | | private void loadNextPageMessageList( |
| | | |
| | | boolean isShowLoading, |
| | | int pageNo, |
| | | String deviceType_filter_key, |
| | |
| | | String timeType_filter_key, |
| | | String timeType_filter_value, |
| | | boolean isClear) { |
| | | if (TextUtils.isEmpty(mMessageBean.getHomeId().replace(" ", ""))) { |
| | | return; |
| | | } |
| | | if (isClear) { |
| | | //表示从第一页可以读取,默认清空所有缓存数据; |
| | | clearCacheData(); |
| | |
| | | } else { |
| | | messageStateType = MessageStateType.processed; |
| | | } |
| | | HdlMessageLogic.getInstance().getPageNoMessageList("", pageNo, messageStateType, deviceType_filter_key, deviceType_filter_value, type_filter_key, type_filter_value, timeType_filter_key, timeType_filter_value, "", new CloudCallBeak<HdlMessageLogic.MessageListClass>() { |
| | | HdlMessageLogic.getInstance().getPageNoMessageList(mMessageBean.getHomeId(), pageNo, messageStateType, deviceType_filter_key, deviceType_filter_value, type_filter_key, type_filter_value, timeType_filter_key, timeType_filter_value, "", new CloudCallBeak<HdlMessageLogic.MessageListClass>() { |
| | | @Override |
| | | public void onSuccess(HdlMessageLogic.MessageListClass messageListClass) { |
| | | if (messageListClass != null) { |
| | |
| | | * 读取消息【未读数量,未处理总数量,已处理总数量】 |
| | | */ |
| | | private void getUnreadCount() { |
| | | HdlMessageLogic.getInstance().getMessageUntreatedCount("", new CloudCallBeak<UnCountBean>() { |
| | | if (TextUtils.isEmpty(mMessageBean.getHomeId().replace(" ", ""))) { |
| | | return; |
| | | } |
| | | HdlMessageLogic.getInstance().getMessageUntreatedCount(mMessageBean.getHomeId(), new CloudCallBeak<UnCountBean>() { |
| | | @Override |
| | | public void onSuccess(UnCountBean unCountBean) { |
| | | |
| | |
| | | } |
| | | return stringList; |
| | | } |
| | | |
| | | @Override |
| | | public void onBackPressed() { |
| | | HdlCommonLogic.getInstance().postEventBus(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house); |
| | | super.onBackPressed(); |
| | | |
| | | } |
| | | } |