Updated on 2026-08-14
This commit is contained in:
parent
bfbf4fff95
commit
b3e52c242e
4 changed files with 25 additions and 21 deletions
|
|
@ -14,4 +14,6 @@ class BoolItem(override val id: Id, value: Boolean? = null) : BaseItem<Boolean>(
|
|||
|
||||
class ListItem(override val id: Id, value: List<KeyValue>, selectedValue: Any?)
|
||||
: BaseItem<ListValueWrapper>(ListViewModel(ListValueWrapper(selectedValue, value))
|
||||
)
|
||||
)
|
||||
|
||||
inline fun<reified T> BaseItem<T>.getData(): T? = viewModel.data
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
package com.tangem.tangemtest.ucase.domain.actions
|
||||
|
||||
import com.tangem.commands.personalization.CardConfig
|
||||
import com.tangem.tangemtest._arch.structure.impl.EditTextItem
|
||||
import com.tangem.tangemtest._arch.structure.impl.getData
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.tasks.ScanEvent
|
||||
import com.tangem.tangemtest.ucase.variants.TlvId
|
||||
import com.tangem.tasks.TaskEvent
|
||||
import ru.dev.gbixahue.eu4d.lib.android.global.log.Log
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -11,17 +14,25 @@ import com.tangem.tasks.TaskEvent
|
|||
class PersonalizeAction : BaseCardAction() {
|
||||
override fun executeMainAction(attrs: AttrForAction, callback: ActionCallback) {
|
||||
var cardId: String? = null
|
||||
ScanAction().executeMainAction(attrs) { response, b ->
|
||||
ScanAction().executeMainAction(attrs) { response, affectedList ->
|
||||
when (response) {
|
||||
is TaskEvent.Event -> {
|
||||
val taskEvent = response as TaskEvent.Event
|
||||
cardId = handleDataEvent(taskEvent.data)
|
||||
Log.d(this, "ScanAction:response: TaskEvent.Event")
|
||||
val item = affectedList.firstOrNull { it.id == TlvId.CardId } as? EditTextItem
|
||||
?: return@executeMainAction
|
||||
cardId = item.getData()
|
||||
if (cardId == null) {
|
||||
handleResponse(response, null, attrs, callback)
|
||||
return@executeMainAction
|
||||
}
|
||||
}
|
||||
is TaskEvent.Completion -> {
|
||||
Log.d(this, "ScanAction:response: TaskEvent.Completion")
|
||||
if (cardId == null) {
|
||||
handleResponse(response, null, attrs, callback)
|
||||
return@executeMainAction
|
||||
}
|
||||
|
||||
val cardConfig = attrs.payload.remove(cardConfig) as? CardConfig
|
||||
?: throw IllegalArgumentException("CardConfig must be in the payloads of the ParamsManager")
|
||||
|
||||
|
|
@ -30,21 +41,9 @@ class PersonalizeAction : BaseCardAction() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleDataEvent(event: Any?): String? {
|
||||
return when (event) {
|
||||
is ScanEvent.OnReadEvent -> {
|
||||
event.card.cardId
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
val cardConfig = "cardConfig"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,17 @@ package com.tangem.tangemtest.ucase.domain.paramsManager.managers
|
|||
|
||||
import com.tangem.CardManager
|
||||
import com.tangem.tangemtest._arch.structure.abstraction.Item
|
||||
import com.tangem.tangemtest._arch.structure.impl.EditTextItem
|
||||
import com.tangem.tangemtest.ucase.domain.actions.PersonalizeAction
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.tangemtest.ucase.variants.TlvId
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class PersonalizeParamsManager : BaseParamsManager(PersonalizeAction()) {
|
||||
override fun createParamsList(): List<Item> {
|
||||
return listOf()
|
||||
return listOf(EditTextItem(TlvId.CardId))
|
||||
}
|
||||
|
||||
override fun invokeMainAction(cardManager: CardManager, callback: ActionCallback) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.tangem.tangemtest.ucase.domain.paramsManager.ParamsManager
|
|||
import com.tangem.tasks.ScanEvent
|
||||
import com.tangem.tasks.TaskError
|
||||
import com.tangem.tasks.TaskEvent
|
||||
import ru.dev.gbixahue.eu4d.lib.android.global.log.Log
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -109,13 +110,13 @@ internal class Notifier(private val vm: ParamsViewModel) {
|
|||
|
||||
private fun handleCompletionEvent(taskEvent: TaskEvent.Completion<*>) {
|
||||
if (taskEvent.error == null) {
|
||||
if (notShowedError == null) {
|
||||
vm.seError.postValue("User was cancelled")
|
||||
} else {
|
||||
Log.d(this, "error = null")
|
||||
if (notShowedError != null) {
|
||||
vm.seError.postValue("${notShowedError!!::class.simpleName}")
|
||||
notShowedError = null
|
||||
}
|
||||
} else {
|
||||
Log.d(this, "error = ${taskEvent.error}")
|
||||
when (taskEvent.error) {
|
||||
is TaskError.UserCancelled -> {
|
||||
if (notShowedError == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue