package com.bonait.bnframework.common.utils;

import static androidx.core.content.ContextCompat.getSystemService;

import android.app.Activity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

import com.bonait.bnframework.MainApplication;

/**
 * @author: liup
 * @description:
 * @date: 2024/5/21 10:12.
 */
public class KeyboardUtil {

    // 隐藏键盘的方法
    public static void hideKeyboard(View view) {
        InputMethodManager inputMethodManager = (InputMethodManager) MainApplication.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
        if (inputMethodManager != null) {
            inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }
}
