wjc
2024-11-27 22c83310cbc4b04615be42d51645b47eff87cb7d
app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java
@@ -1,12 +1,14 @@
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;
@@ -20,6 +22,7 @@
import com.hdl.photovoltaic.base.CustomBaseActivity;
import com.hdl.photovoltaic.databinding.ActivitySearchMessgeBinding;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlFileLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlMessageLogic;
@@ -107,6 +110,8 @@
                    HdlThreadLogic.toast(_mActivity, R.string.search_content_null);
                    return;
                }
                viewBinding.messageSearchEt.clearFocus();
                hideSoftInputFromWindow();
                viewBinding.historyListParent.setVisibility(View.GONE);
                viewBinding.listParent.setVisibility(View.VISIBLE);
                addSearchTextToList();
@@ -152,17 +157,23 @@
                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());
            }
        });
@@ -177,6 +188,8 @@
                    HdlThreadLogic.toast(_mActivity, R.string.search_content_null);
                    return;
                }
                viewBinding.messageSearchEt.clearFocus();
                hideSoftInputFromWindow();
                viewBinding.historyListParent.setVisibility(View.GONE);
                viewBinding.listParent.setVisibility(View.VISIBLE);
                addSearchTextToList();
@@ -194,6 +207,23 @@
            }
        });
    }
    /**
     * 显示软键盘
     */
    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() {
@@ -221,7 +251,7 @@
            @Override
            public void onKeyboardShow(int h) {
                //Toast.makeText(MainActivity.this,"键盘弹出",Toast.LENGTH_SHORT).show();
                viewBinding.messageSearchEt.requestFocus();
//                viewBinding.messageSearchEt.requestFocus();
            }
@@ -271,6 +301,7 @@
                if (searchMessageAdapter != null) {
                    searchMessageAdapter.setList(mList);
                }
                nullDataUpdateUi();
            }
        });
    }
@@ -426,6 +457,14 @@
    }
    /**
     * 没有消息列表的样式
     */
    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);
    }
    /**
     * 获取【搜索历史记录文件】全路径
     */
    public String getHistoryFileNamePath() {