From 5f812bb301e9e19cd6a7f8063de63c36e7f3b06c Mon Sep 17 00:00:00 2001 From: therajanmaurya Date: Fri, 21 Oct 2022 16:20:47 +0530 Subject: [PATCH] fix: make image optional --- .../github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sweet-Error/src/main/java/com/github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt b/Sweet-Error/src/main/java/com/github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt index 735dee1..aec8203 100644 --- a/Sweet-Error/src/main/java/com/github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt +++ b/Sweet-Error/src/main/java/com/github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt @@ -153,7 +153,7 @@ class SweetUIErrorHandler(private val context: Context, private val view: View) llErrorToLoad.visibility = View.GONE llEmptyUI.visibility = View.GONE llCustomUI.visibility = View.VISIBLE - ivCustomFeatureImage.setImageResource(featureImage!!) + featureImage?.let { ivCustomFeatureImage.setImageResource(it) } ?: run { ivCustomFeatureImage.visibility = View.GONE } featureName?.let { tvCustomFeatureName.text = it } ?: run { tvCustomFeatureName.visibility = View.GONE } subFeatureName?.let { tvCustomSubFeatureName.text = it } ?: run { tvCustomSubFeatureName.visibility = View.GONE } } @@ -172,7 +172,7 @@ class SweetUIErrorHandler(private val context: Context, private val view: View) llErrorToLoad.visibility = View.GONE llEmptyUI.visibility = View.GONE llCustomUI.visibility = View.VISIBLE - ivCustomFeatureImage.setImageResource(featureImage!!) + featureImage?.let { ivCustomFeatureImage.setImageResource(it) } ?: run { ivCustomFeatureImage.visibility = View.GONE } tvCustomFeatureName.text = featureName tvCustomSubFeatureName.visibility = View.GONE }