From e234a15b428267997c903a4ed42536c5d9f14a1f Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 10 十一月 2025 13:10:42 +0800
Subject: [PATCH] 2025.11.10 1. 新增巡查场景历史详情相关数据逻辑; 2. 新增工地施工阶段修改界面;
---
app/src/main/java/cn/flightfeather/thirdappmodule/module/base/BaseActivity.kt | 43 +++++++++++++++++++++++++++++--------------
1 files changed, 29 insertions(+), 14 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..f9ca5da 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
@@ -38,8 +40,10 @@
} catch (e: Exception) {
e.printStackTrace()
}
- setContentView(getLayoutId())
- rootView = findViewById<ViewGroup>(android.R.id.content).getChildAt(0) as ViewGroup
+ getLayoutId()?.let {
+ setContentView(it)
+ rootView = findViewById<ViewGroup>(android.R.id.content).getChildAt(0) as ViewGroup
+ }
}
override fun onDestroy() {
@@ -60,8 +64,30 @@
}
- abstract fun getLayoutId(): Int
+ 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 +104,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