From 77b5937fbb8490b368acac85f434113a175f1bba Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 6 Apr 2020 18:09:03 -0600 Subject: ui: add missing fields to detail view Signed-off-by: Jason A. Donenfeld --- .../com/wireguard/android/databinding/BindingAdapters.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ui/src/main/java/com/wireguard/android') diff --git a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt index 05d69aec..fe828004 100644 --- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt +++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt @@ -26,6 +26,7 @@ import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener import com.wireguard.config.Attribute import com.wireguard.config.InetNetwork import java9.util.Optional +import java.net.InetAddress /** * Static methods for use by generated code in the Android data binding library. @@ -135,13 +136,19 @@ object BindingAdapters { @JvmStatic @BindingAdapter("android:text") - fun setText(view: TextView, text: Optional<*>) { - view.text = text.map { it.toString() }.orElse("") + fun setOptionalText(view: TextView, text: Optional<*>?) { + view.text = text?.map { it.toString() }?.orElse("") ?: "" } @JvmStatic @BindingAdapter("android:text") - fun setText(view: TextView, networks: Iterable?) { + fun setInetNetworkSetText(view: TextView, networks: Iterable?) { view.text = if (networks != null) Attribute.join(networks) else "" } + + @JvmStatic + @BindingAdapter("android:text") + fun setInetAddressSetText(view: TextView, addresses: Iterable?) { + view.text = if (addresses != null) Attribute.join(addresses.map { it?.hostAddress }) else "" + } } -- cgit v1.2.3