From 73deedcdc0c51844ed2ddb307efab987918b42a4 Mon Sep 17 00:00:00 2001 From: erkutaras Date: Sun, 6 Jan 2019 20:41:59 +0300 Subject: [PATCH] add info button listener to showState function --- README.md | 4 ++-- library/build.gradle | 4 ++-- .../com/erkutaras/statelayout/StateLayout.kt | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 14fd76c..4994545 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ allprojects { **Step 2.** Add the library dependency to your project build.gradle: ``` dependencies { - implementation 'com.github.erkutaras:StateLayout:1.2.2' + implementation 'com.github.erkutaras:StateLayout:1.2.3' } ``` @@ -41,7 +41,7 @@ _If you don't migrate your project with AndroidX yet, you may need to exclude an ``` dependencies { - implementation ('com.github.erkutaras:StateLayout:1.2.2') { + implementation ('com.github.erkutaras:StateLayout:1.2.3') { exclude group: 'androidx.appcompat' } } diff --git a/library/build.gradle b/library/build.gradle index 88b15aa..4a743a8 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 28 - versionCode 17 - versionName "1.2.2" + versionCode 18 + versionName "1.2.3" vectorDrawables.useSupportLibrary = true } diff --git a/library/src/main/java/com/erkutaras/statelayout/StateLayout.kt b/library/src/main/java/com/erkutaras/statelayout/StateLayout.kt index ca3a710..4a713ea 100644 --- a/library/src/main/java/com/erkutaras/statelayout/StateLayout.kt +++ b/library/src/main/java/com/erkutaras/statelayout/StateLayout.kt @@ -244,19 +244,27 @@ class StateLayout @JvmOverloads constructor(context: Context, } fun showLoading(stateInfo: StateInfo?) { - showState(stateInfo) + if (stateInfo?.state == LOADING) showState(stateInfo) } fun showContent(stateInfo: StateInfo?) { - showState(stateInfo) + if (stateInfo?.state == CONTENT) showState(stateInfo) } fun showInfo(stateInfo: StateInfo?) { - showState(stateInfo) + if (stateInfo?.state == INFO) showState(stateInfo) + } + + fun showLoadingWithContent(stateInfo: StateInfo?) { + if (stateInfo?.state == LOADING_WITH_CONTENT) showState(stateInfo) + } + + fun showError(stateInfo: StateInfo?) { + if (stateInfo?.state == ERROR) showState(stateInfo) } fun showEmpty(stateInfo: StateInfo?) { - showState(stateInfo) + if (stateInfo?.state == EMPTY) showState(stateInfo) } fun showState(stateInfo: StateInfo?) { @@ -269,6 +277,7 @@ class StateLayout @JvmOverloads constructor(context: Context, stateInfo.infoTitle?.let { infoTitle(it) } stateInfo.infoMessage?.let { infoMessage(it) } stateInfo.infoButtonText?.let { infoButtonText(it) } + stateInfo.onStateLayoutListener?.let { infoButtonListener(it) } } null, NONE -> hideAll() }