package com.base.pdfviewerscannerwhite.utils

import android.annotation.SuppressLint
import android.content.Context
import android.content.Context.INPUT_METHOD_SERVICE
import android.view.inputmethod.InputMethodManager
import android.widget.EditText


object KeyBoardUtils {

    @SuppressLint("ServiceCast")
    fun Context.hideKeyboard(editText: EditText) {
        editText.clearFocus()
        val imm = this.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
        imm.hideSoftInputFromWindow(editText.windowToken, 0)
    }

    @SuppressLint("ServiceCast")
    fun Context.showKeyBoard(editText: EditText) {
        editText.requestFocus()
        val imm = this.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager?
        imm?.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT)
    }
}