aboutsummaryrefslogtreecommitdiff
path: root/taler-kotlin-common/src/main/java/net/taler/common
diff options
context:
space:
mode:
Diffstat (limited to 'taler-kotlin-common/src/main/java/net/taler/common')
-rw-r--r--taler-kotlin-common/src/main/java/net/taler/common/Amount.kt1
-rw-r--r--taler-kotlin-common/src/main/java/net/taler/common/AndroidUtils.kt7
2 files changed, 8 insertions, 0 deletions
diff --git a/taler-kotlin-common/src/main/java/net/taler/common/Amount.kt b/taler-kotlin-common/src/main/java/net/taler/common/Amount.kt
index bd12a40..76cd294 100644
--- a/taler-kotlin-common/src/main/java/net/taler/common/Amount.kt
+++ b/taler-kotlin-common/src/main/java/net/taler/common/Amount.kt
@@ -159,6 +159,7 @@ data class Amount(
@Throws(AmountOverflowException::class)
operator fun times(factor: Int): Amount {
+ if (factor == 0) return zero(currency)
var result = this
for (i in 1 until factor) result += this
return result
diff --git a/taler-kotlin-common/src/main/java/net/taler/common/AndroidUtils.kt b/taler-kotlin-common/src/main/java/net/taler/common/AndroidUtils.kt
index fda537b..ba6ee1c 100644
--- a/taler-kotlin-common/src/main/java/net/taler/common/AndroidUtils.kt
+++ b/taler-kotlin-common/src/main/java/net/taler/common/AndroidUtils.kt
@@ -38,6 +38,8 @@ import android.text.format.DateUtils.getRelativeTimeSpanString
import android.view.View
import android.view.View.INVISIBLE
import android.view.View.VISIBLE
+import android.view.inputmethod.InputMethodManager
+import androidx.core.content.ContextCompat.getSystemService
import androidx.fragment.app.Fragment
import androidx.navigation.NavDirections
import androidx.navigation.fragment.findNavController
@@ -61,6 +63,11 @@ fun View.fadeOut(endAction: () -> Unit = {}) {
}.start()
}
+fun View.hideKeyboard() {
+ getSystemService(context, InputMethodManager::class.java)
+ ?.hideSoftInputFromWindow(windowToken, 0)
+}
+
fun assertUiThread() {
check(Looper.getMainLooper().thread == Thread.currentThread())
}