From d59d55575d913646b7a90fca651904ab889c6723 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 18 二月 2022 16:30:53 +0800
Subject: [PATCH] ### 一、任务模块相关

---
 app/src/main/java/cn/flightfeather/thirdappmodule/module/base/BaseActivity.kt |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/app/src/main/java/cn/flightfeather/thirdappmodule/module/base/BaseActivity.kt b/app/src/main/java/cn/flightfeather/thirdappmodule/module/base/BaseActivity.kt
index 6564dfa..9b8234e 100644
--- a/app/src/main/java/cn/flightfeather/thirdappmodule/module/base/BaseActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdappmodule/module/base/BaseActivity.kt
@@ -9,11 +9,13 @@
 import android.support.v4.app.Fragment
 import android.support.v4.app.FragmentManager
 import android.support.v4.app.FragmentTransaction
+import android.support.v4.content.ContextCompat
 import android.support.v7.app.AppCompatActivity
 import android.support.v7.widget.Toolbar
 import android.view.MenuItem
 import android.view.ViewGroup
 import android.view.inputmethod.InputMethodManager
+import android.widget.EditText
 import com.bumptech.glide.Glide
 import io.reactivex.disposables.Disposable
 import org.greenrobot.eventbus.EventBus
@@ -62,6 +64,28 @@
 
     abstract fun getLayoutId(): Int
 
+    /**
+     * 鎷撳睍activity涓嚜鍔ㄦ樉绀鸿蒋閿洏鐨勬柟娉�
+     */
+    fun autoShowKeyboard(editText: EditText, delay: Long = 500) {
+        editText.postDelayed({
+            ContextCompat.getSystemService(this, InputMethodManager::class.java)?.run {
+                editText.requestFocus()
+                showSoftInput(editText, 0)
+            }
+        }, delay)
+    }
+
+    /**
+     * 鎷撳睍activity涓殣钘忚蒋閿洏鐨勬柟娉�
+     */
+    fun hideKeyboard() {
+        this.window?.peekDecorView()?.let {
+            val inputManager =
+                this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+            inputManager.hideSoftInputFromWindow(it.windowToken, 0)
+        }
+    }
 }
 
 fun Context.startActivity(cls: Class<*>) {
@@ -78,15 +102,4 @@
 
 inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> FragmentTransaction) {
     beginTransaction().func().commit()
-}
-
-/**
- * 鎷撳睍fragment涓殣钘忚蒋閿洏鐨勬柟娉�
- */
-fun Activity.hideKeyboard() {
-    this.window?.peekDecorView()?.let {
-        val inputManager =
-                this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
-        inputManager.hideSoftInputFromWindow(it.windowToken, 0)
-    }
 }

--
Gitblit v1.9.3