diff --git a/app/src/main/java/com/goldenraven/padawanwallet/ui/wallet/WalletRootScreen.kt b/app/src/main/java/com/goldenraven/padawanwallet/ui/wallet/WalletRootScreen.kt index bed0c999..b494a7fa 100644 --- a/app/src/main/java/com/goldenraven/padawanwallet/ui/wallet/WalletRootScreen.kt +++ b/app/src/main/java/com/goldenraven/padawanwallet/ui/wallet/WalletRootScreen.kt @@ -290,7 +290,7 @@ fun SendReceive(navController: NavHostController) { .height(70.dp) ) { Button( - onClick = { ClickHelper.getInstance().clickOnce { navController.navigate(Screen.ReceiveScreen.route) }}, + onClick = { ClickHelper.clickOnce { navController.navigate(Screen.ReceiveScreen.route) }}, colors = ButtonDefaults.buttonColors(containerColor = padawan_theme_button_secondary), shape = RoundedCornerShape(20.dp), border = standardBorder, @@ -311,7 +311,7 @@ fun SendReceive(navController: NavHostController) { } } Button( - onClick = { ClickHelper.getInstance().clickOnce { navController.navigate(Screen.SendScreen.route) }}, + onClick = { ClickHelper.clickOnce { navController.navigate(Screen.SendScreen.route) }}, colors = ButtonDefaults.buttonColors(containerColor = padawan_theme_button_primary), shape = RoundedCornerShape(20.dp), border = standardBorder, diff --git a/app/src/main/java/com/goldenraven/padawanwallet/utils/ClickHelper.kt b/app/src/main/java/com/goldenraven/padawanwallet/utils/ClickHelper.kt index 363f0274..77fe91e8 100644 --- a/app/src/main/java/com/goldenraven/padawanwallet/utils/ClickHelper.kt +++ b/app/src/main/java/com/goldenraven/padawanwallet/utils/ClickHelper.kt @@ -1,21 +1,14 @@ package com.goldenraven.padawanwallet.utils -class ClickHelper private constructor() { +object ClickHelper { private val now: Long get() = System.currentTimeMillis() private var lastEventTimeMs: Long = 0 + fun clickOnce(event: () -> Unit) { if (now - lastEventTimeMs >= 800L) { event.invoke() } lastEventTimeMs = now } - companion object { - @Volatile - private var instance: ClickHelper? = null - fun getInstance() = - instance ?: synchronized(this) { - instance ?: ClickHelper().also { instance = it } - } - } -} \ No newline at end of file +}