diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-04-06 18:09:03 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-04-06 18:09:03 -0600 |
commit | 77b5937fbb8490b368acac85f434113a175f1bba (patch) | |
tree | 84ed0b11682f0d87be3edd20cceb1acae52b0123 /ui/src/main/java/com/wireguard | |
parent | 3144d360569cb358fc750733ccb180d3e9d2bc48 (diff) |
ui: add missing fields to detail view
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt | 13 |
1 files changed, 10 insertions, 3 deletions
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<InetNetwork?>?) { + fun setInetNetworkSetText(view: TextView, networks: Iterable<InetNetwork?>?) { view.text = if (networks != null) Attribute.join(networks) else "" } + + @JvmStatic + @BindingAdapter("android:text") + fun setInetAddressSetText(view: TextView, addresses: Iterable<InetAddress?>?) { + view.text = if (addresses != null) Attribute.join(addresses.map { it?.hostAddress }) else "" + } } |