From 4bbb1a0fcdc32e1629436acf58437779f5789f3e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 6 Apr 2020 18:24:08 -0600 Subject: ui: add suffix to persistent keepalive in editor Signed-off-by: Jason A. Donenfeld --- .../java/com/wireguard/android/databinding/BindingAdapters.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ui/src/main/java/com') 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 fe828004..055c2f06 100644 --- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt +++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt @@ -151,4 +151,15 @@ object BindingAdapters { fun setInetAddressSetText(view: TextView, addresses: Iterable?) { view.text = if (addresses != null) Attribute.join(addresses.map { it?.hostAddress }) else "" } + + @JvmStatic + fun tryParseInt(s: String?): Int { + if (s == null) + return 0 + return try { + Integer.parseInt(s) + } catch (_: Exception) { + 0 + } + } } -- cgit v1.2.3