Skip to content

Commit

Permalink
优化空文字的设置逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
junixapp committed May 13, 2022
1 parent f6029de commit 03980a8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/lxj/demo1/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MainActivity : AppCompatActivity() {
emptyIcon = R.mipmap.ic_launcher_round,
loadingLayoutId = R.layout.custom_loading2,
errorLayoutId = R.layout.custom_error,
emptyLayoutId = R.layout.custom_empty
// emptyLayoutId = R.layout.custom_empty
) { slInLayout.postDelayed({slInLayout.showEmpty()}, 1000) }
slInLayout.showLoading()
slInLayout.postDelayed({slInLayout.showContent()}, 2000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ class StateLayout @JvmOverloads constructor(context: Context, attributeSet: Attr
val group = emptyView as ViewGroup
(0 until group.childCount).forEach {
val child = group.getChildAt(it)
if(child is TextView && child.text.isNullOrEmpty() && !emptyText.isNullOrEmpty()) {
if(child is TextView && !emptyText.isNullOrEmpty()) {
child.text = emptyText
}else if(child is ImageView && child.drawable==null && emptyIcon!=0){
}else if(child is ImageView && emptyIcon!=0){
child.setImageResource(emptyIcon)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object StateLayoutConfig {
var animDuration = 120L
var useContentBgWhenLoading = false //是否在Loading状态使用内容View的背景
var enableLoadingShadow = false //是否启用加载状态时的半透明阴影
var emptyText: String = "暂无数据"
var emptyText: String = ""
var emptyIcon: Int = 0
var enableTouchWhenLoading = false
var defaultShowLoading = false
Expand Down

0 comments on commit 03980a8

Please sign in to comment.