mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
cff73c67dc
commit
951a0c91a5
@ -4,6 +4,7 @@ package io.legado.app.utils
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.cardview.widget.CardView
|
import androidx.cardview.widget.CardView
|
||||||
@ -28,12 +29,10 @@ fun Context.toastOnUi(message: Int, duration: Int = Toast.LENGTH_SHORT) {
|
|||||||
fun Context.toastOnUi(message: CharSequence?, duration: Int = Toast.LENGTH_SHORT) {
|
fun Context.toastOnUi(message: CharSequence?, duration: Int = Toast.LENGTH_SHORT) {
|
||||||
runOnUI {
|
runOnUI {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
if (toast == null || BuildConfig.DEBUG || AppConfig.recordLog) {
|
toast?.cancel()
|
||||||
toast?.cancel()
|
toast = Toast(this)
|
||||||
toast = Toast(this)
|
val toastView: View = inflate(R.layout.view_toast)
|
||||||
toast?.view = inflate(R.layout.view_toast)
|
toast?.view = toastView
|
||||||
}
|
|
||||||
val toastView = toast?.view!!
|
|
||||||
val cardView = toastView.findViewById<CardView>(R.id.cv_content)
|
val cardView = toastView.findViewById<CardView>(R.id.cv_content)
|
||||||
cardView.setCardBackgroundColor(bottomBackground)
|
cardView.setCardBackgroundColor(bottomBackground)
|
||||||
val isLight = ColorUtils.isColorLight(bottomBackground)
|
val isLight = ColorUtils.isColorLight(bottomBackground)
|
||||||
|
Loading…
Reference in New Issue
Block a user