Refactor "fired" to "executed"
Which is a better fit, because we already have an "execute" function.
This commit is contained in:
@@ -10,7 +10,7 @@ abstract class Action {
|
||||
abstract val iconResId: Int
|
||||
abstract val titleResId: Int
|
||||
|
||||
var fired: Boolean = false
|
||||
var executed: Boolean = false
|
||||
|
||||
abstract fun canExecuteOn(data: ByteArray): Boolean
|
||||
abstract suspend fun execute(context: Context, data: ByteArray)
|
||||
@@ -24,7 +24,7 @@ abstract class IntentAction : Action() {
|
||||
if (intent == null) {
|
||||
context.toast(errorMsg)
|
||||
} else {
|
||||
fired = context.execShareIntent(intent)
|
||||
executed = context.execShareIntent(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,6 @@ abstract class SchemeAction : Action() {
|
||||
}
|
||||
|
||||
final override suspend fun execute(context: Context, data: ByteArray) {
|
||||
fired = context.openUrl(String(data))
|
||||
executed = context.openUrl(String(data))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ object OpenOrSearchAction : Action() {
|
||||
override fun canExecuteOn(data: ByteArray): Boolean = false
|
||||
|
||||
override suspend fun execute(context: Context, data: ByteArray) {
|
||||
fired = openUrlOrSearch(context, String(data))
|
||||
executed = openUrlOrSearch(context, String(data))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,6 @@ object WebAction : Action() {
|
||||
if (!url.startsWith("http") && !url.startsWith("ftp")) {
|
||||
url = "http://${url}"
|
||||
}
|
||||
fired = context.openUrl(url)
|
||||
executed = context.openUrl(url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ object WifiAction : Action() {
|
||||
|
||||
override suspend fun execute(context: Context, data: ByteArray) {
|
||||
withContext(Dispatchers.IO) {
|
||||
fired = WifiConnector.parse(String(data))?.let {
|
||||
executed = WifiConnector.parse(String(data))?.let {
|
||||
WifiConnector.addNetwork(context, it)
|
||||
} ?: false
|
||||
withContext(Dispatchers.Main) {
|
||||
context.toast(
|
||||
if (fired) {
|
||||
if (executed) {
|
||||
R.string.wifi_added
|
||||
} else {
|
||||
R.string.wifi_config_failed
|
||||
|
||||
@@ -222,7 +222,7 @@ class DecodeActivity : AbstractBaseActivity() {
|
||||
label = newLabel
|
||||
}
|
||||
}
|
||||
if (action.fired) {
|
||||
if (action.executed) {
|
||||
maybeBackOrFinish()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user