完善了功能
This commit is contained in:
@@ -73,15 +73,15 @@ object DateTimeUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断给定时间是否距离当前时间超过36小时
|
||||
* 判断给定时间是否距离当前时间超过72小时
|
||||
* @param timeInMillis 时间戳(毫秒)
|
||||
* @return true 表示超过36小时,false 表示未超过
|
||||
* @return true 表示超过72小时,false 表示未超过
|
||||
*/
|
||||
fun isMoreThan36HoursFromNow(timeInMillis: Long): Boolean {
|
||||
fun isMoreThanHoursFromNow(timeInMillis: Long): Boolean {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
val timeDifference = currentTime - timeInMillis
|
||||
val hoursDifference = timeDifference / (1000 * 60 * 60) // 毫秒转小时
|
||||
return hoursDifference >= 36
|
||||
return hoursDifference >= 72
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sw.platecabinet.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
|
||||
/**
|
||||
* 键盘工具类
|
||||
*/
|
||||
object KeyboardUtils {
|
||||
|
||||
/**
|
||||
* 显示键盘
|
||||
*/
|
||||
fun showKeyboard(view: View) {
|
||||
val imm = view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏键盘
|
||||
*/
|
||||
fun hideKeyboard(activity: Activity) {
|
||||
val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
val view = activity.currentFocus ?: View(activity)
|
||||
imm.hideSoftInputFromWindow(view.windowToken, 0)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user