wjc
2025-01-10 2e91f8abdcb87feda9e237895d4460a19fd7aed8
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;
@@ -64,6 +66,7 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
        setStatusBarTranslucent();
        getWindow().setNavigationBarColor(getColor(R.color.text_FF000000));
        mMessageStateType = getIntent().getStringExtra("MessageStateType");
        //历史记录文件夹创建
        HdlFileLogic.getInstance().createFileDir(HdlFileLogic.getInstance().getCurrentUserRootPath());
@@ -108,6 +111,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();
@@ -157,12 +162,16 @@
                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);
@@ -180,6 +189,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();
@@ -197,6 +208,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() {
@@ -224,7 +252,7 @@
            @Override
            public void onKeyboardShow(int h) {
                //Toast.makeText(MainActivity.this,"键盘弹出",Toast.LENGTH_SHORT).show();
                viewBinding.messageSearchEt.requestFocus();
//                viewBinding.messageSearchEt.requestFocus();
            }