From 279b01adbca8fe8fe74d1b6cbc4721a1950c280e Mon Sep 17 00:00:00 2001 From: Ragaa AboElezz Date: Mon, 17 Apr 2023 14:59:29 +0200 Subject: [PATCH] Enabled search with countryPhoneCode --- .../java/com/togitech/ccp/utils/SearchCountryList.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ccp/src/main/java/com/togitech/ccp/utils/SearchCountryList.kt b/ccp/src/main/java/com/togitech/ccp/utils/SearchCountryList.kt index 1c3187c..869039c 100644 --- a/ccp/src/main/java/com/togitech/ccp/utils/SearchCountryList.kt +++ b/ccp/src/main/java/com/togitech/ccp/utils/SearchCountryList.kt @@ -4,12 +4,9 @@ import android.content.Context import com.togitech.ccp.data.CountryData import com.togitech.ccp.data.utils.getCountryName -fun List.searchCountry(key: String,context: Context): MutableList { - val tempList = mutableListOf() - this.forEach { - if (context.resources.getString(getCountryName(it.countryCode)).lowercase().contains(key.lowercase())) { - tempList.add(it) - } +fun List.searchCountry(key: String,context: Context): List { + return filter { + context.resources.getString(getCountryName(it.countryCode)).lowercase() + .contains(key.lowercase()) || it.countryPhoneCode.contains(key) } - return tempList } \ No newline at end of file