| | |
| | | package com.hdl.photovoltaic.ui.message; |
| | | |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.text.Editable; |
| | | import android.text.TextUtils; |
| | | import android.text.TextWatcher; |
| | | import android.view.View; |
| | | import android.view.inputmethod.InputMethodManager; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.bean.PageNumberObject; |
| | | import com.hdl.photovoltaic.databinding.ActivitySearchMessgeBinding; |
| | | import com.hdl.photovoltaic.enums.MessageStateType; |
| | | import com.hdl.photovoltaic.enums.ShowErrorMode; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlFileLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlMessageLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.ui.adapter.SearchHistoryAdapter; |
| | | import com.hdl.photovoltaic.ui.adapter.SearchMessageAdapter; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceBean; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | | import com.hdl.photovoltaic.utils.KeyboardStateObserverUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF000000)); |
| | | mMessageStateType = getIntent().getStringExtra("MessageStateType"); |
| | | //历史记录文件夹创建 |
| | | HdlFileLogic.getInstance().createFileDir(HdlFileLogic.getInstance().getCurrentUserRootPath()); |
| | |
| | | HdlThreadLogic.toast(_mActivity, R.string.search_content_null); |
| | | return; |
| | | } |
| | | viewBinding.messageSearchEt.clearFocus(); |
| | | hideSoftInputFromWindow(); |
| | | viewBinding.historyListParent.setVisibility(View.GONE); |
| | | viewBinding.listParent.setVisibility(View.VISIBLE); |
| | | addSearchTextToList(); |
| | |
| | | currSearchText = ""; |
| | | viewBinding.messageSearchEt.setText(""); |
| | | viewBinding.historyListParent.setVisibility(View.VISIBLE); |
| | | viewBinding.deviceNullDataIc.getRoot().setVisibility(View.GONE); |
| | | viewBinding.listParent.setVisibility(View.GONE); |
| | | searchHistoryAdapter.setList(searchHistoryTitleList); |
| | | clearCacheData(); |
| | | viewBinding.messageSearchEt.requestFocus(); |
| | | showSoftInput(); |
| | | } |
| | | }); |
| | | //删除 |
| | | viewBinding.messageDelIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | viewBinding.messageSearchEt.clearFocus(); |
| | | hideSoftInputFromWindow(); |
| | | searchHistoryTitleList = new ArrayList<>(); |
| | | searchHistoryAdapter.setList(searchHistoryTitleList); |
| | | viewBinding.deviceNullDataIc.getRoot().setVisibility(View.GONE); |
| | | HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath()); |
| | | } |
| | | }); |
| | |
| | | @Override |
| | | public void onClick(int position, String title) { |
| | | viewBinding.messageSearchEt.setText(title); |
| | | //搜索关键字 |
| | | currSearchText = viewBinding.messageSearchEt.getText().toString().replace(" ", ""); |
| | | if (TextUtils.isEmpty(currSearchText)) { |
| | | HdlThreadLogic.toast(_mActivity, R.string.search_content_null); |
| | | return; |
| | | } |
| | | viewBinding.messageSearchEt.clearFocus(); |
| | | hideSoftInputFromWindow(); |
| | | viewBinding.historyListParent.setVisibility(View.GONE); |
| | | viewBinding.listParent.setVisibility(View.VISIBLE); |
| | | addSearchTextToList(); |
| | | loadNextPageMessageList(true, 1, viewBinding.messageSearchEt.getText().toString(), true); |
| | | } |
| | | }); |
| | | //消息点击是事件 |
| | |
| | | @Override |
| | | public void onClick(int position, MessageBean messageBean) { |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("msgId", messageBean.getMsgId().toString()); |
| | | intent.putExtra("messageStateType", mMessageStateType); |
| | | intent.putExtra("messageBean", new Gson().toJson(messageBean)); |
| | | intent.setClass(_mActivity, MessageInfoActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 显示软键盘 |
| | | */ |
| | | public void showSoftInput() { |
| | | InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
| | | inputMethodManager.showSoftInput(viewBinding.messageSearchEt, 0); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 隐藏软键盘 |
| | | */ |
| | | public void hideSoftInputFromWindow() { |
| | | InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
| | | inputMethodManager.hideSoftInputFromWindow(viewBinding.getRoot().getWindowToken(), 0); |
| | | } |
| | | |
| | | private void initView() { |
| | |
| | | searchMessageAdapter = new SearchMessageAdapter(_mActivity); |
| | | viewBinding.listRcv.setLayoutManager(new LinearLayoutManager(_mActivity)); |
| | | viewBinding.listRcv.setAdapter(searchMessageAdapter); |
| | | viewBinding.messageSearchEt.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | viewBinding.messageSearchEt.requestFocus(); |
| | | } |
| | | }); |
| | | |
| | | //在界面中使用 |
| | | 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.messageSearchEt.clearFocus(); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | if (searchMessageAdapter != null) { |
| | | searchMessageAdapter.setList(mList); |
| | | } |
| | | nullDataUpdateUi(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | searchHistoryTitleList.remove(searchHistoryTitleList.get(i)); |
| | | } |
| | | } |
| | | searchHistoryTitleList.add(currSearchText); |
| | | // 倒序排列数据(搜索最后排在前面) |
| | | Collections.reverse(searchHistoryTitleList); |
| | | searchHistoryTitleList.add(0, currSearchText); |
| | | if (searchHistoryTitleList.size() > maxValue) { |
| | | //历史记录不能超出10 |
| | | searchHistoryTitleList.remove(searchHistoryTitleList.get(maxValue + 1)); |
| | | searchHistoryTitleList.remove(searchHistoryTitleList.get(maxValue)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 没有消息列表的样式 |
| | | */ |
| | | private void nullDataUpdateUi() { |
| | | boolean is_data = mList != null && mList.size() > 0; |
| | | HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.deviceNullDataIc.getRoot(), viewBinding.deviceNullDataIc.nullDataGifAnimationIv, viewBinding.deviceNullDataIc.nullDataTv, getString(R.string.message_alarm_data_null), is_data); |
| | | } |
| | | |
| | | /** |