wjc
15 小时以前 4bc924d0ce29560a5e1ad1adf1042de032d954a1
app/src/main/java/com/hdl/photovoltaic/ui/message/MessageHouseFragment.java
@@ -30,6 +30,7 @@
import com.hdl.photovoltaic.ui.adapter.MessageHouseAdapter;
import com.hdl.photovoltaic.ui.bean.MessageBean;
import com.hdl.photovoltaic.ui.bean.UnCountBean;
import com.hdl.photovoltaic.ui.powerstation.HouseSearchActivity;
import com.hdl.photovoltaic.utils.KeyboardStateObserverUtils;
import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
@@ -47,7 +48,7 @@
    private FragementMessageHouseBinding viewBinding;
    private MessageHouseAdapter mMessageHouseAdapter;
    private boolean isFirstLoading = true;
    private boolean isRead = true;
    private final List<MessageBean> mList = new ArrayList<>();
@@ -81,7 +82,7 @@
        HdlMessageLogic.getInstance().getMessageHouseList(homeName, new CloudCallBeak<List<MessageBean>>() {
            @Override
            public void onSuccess(List<MessageBean> list) {
                isFirstLoading = false;
                isRead = false;
                if (isShowLoading) {
                    hideLoading();
                }
@@ -179,15 +180,12 @@
    private void initEvent() {
        //搜索
        viewBinding.powerStationSearchEt.addTextChangedListener(powerStationSearchWatcher);
        //清除搜索文案
        viewBinding.powerStationClearIv.setOnClickListener(new View.OnClickListener() {
        viewBinding.powerStationSearchCl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                viewBinding.powerStationSearchEt.setText("");
                viewBinding.powerStationClearIv.setVisibility(View.GONE);
                getMessageHouseList("", false);
                Intent intent = new Intent();
                intent.setClass(_mActivity, SearchMessageHouseActivity.class);
                startActivity(intent);
            }
        });
        //全部已读
@@ -263,22 +261,7 @@
        viewBinding.houseListRcv.setLayoutManager(new LinearLayoutManager(_mActivity));
        viewBinding.houseListRcv.setAdapter(mMessageHouseAdapter);
        this.pullToRefresh();
        //在界面中使用
        KeyboardStateObserverUtils.getKeyboardStateObserver(_mActivity).setKeyboardVisibilityListener(new KeyboardStateObserverUtils.OnKeyboardVisibilityListener() {
            @Override
            public void onKeyboardShow(int h) {
                //Toast.makeText(MainActivity.this,"键盘弹出",Toast.LENGTH_SHORT).show();
//                viewBinding.messageSearchEt.requestFocus();
            }
            @Override
            public void onKeyboardHide(int h) {
                viewBinding.powerStationSearchEt.clearFocus();
            }
        });
    }
    /**
@@ -356,54 +339,23 @@
                // 取消粘性事件
                EventBus.getDefault().removeStickyEvent(eventBus);
                HdlLogLogic.print("正在点击【消息】");
                //第二次进来不显示加载框
                if (!isFirstLoading) {
                if (!isRead) {
                    //第二次进来不显示加载框
                    initData(false);
                }
            }
        } else if (eventBus.getTopic().equals(ConstantManage.refresh_message_house)) {
            // 取消粘性事件
            EventBus.getDefault().removeStickyEvent(eventBus);
            //第二次进来不显示加载框
            if (!isFirstLoading) {
                initData(false);
            }
            initData(false);
        }
    }
    /**
     *
     */
    private final TextWatcher powerStationSearchWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //搜索关键字
            String currSearchText = s.toString().replace(" ", "");
            if (TextUtils.isEmpty(currSearchText)) {
                viewBinding.powerStationClearIv.setVisibility(View.GONE);
//                HdlThreadLogic.toast(_mActivity, R.string.search_content_null);
                return;
            }
            viewBinding.powerStationClearIv.setVisibility(View.VISIBLE);
            viewBinding.powerStationSearchEt.clearFocus();
            getMessageHouseList(currSearchText, false);
        }
        @Override
        public void afterTextChanged(Editable s) {
        }
    };
    @Override
    public void onDestroy() {
        super.onDestroy();
        viewBinding.powerStationSearchEt.removeTextChangedListener(powerStationSearchWatcher);
    }
}