Updated on 2026-08-14
This commit is contained in:
parent
26adeb67ce
commit
449d24b23f
6 changed files with 21 additions and 16 deletions
|
|
@ -19,22 +19,24 @@ import ru.dev.gbixahue.eu4d.lib.android.global.threading.postUI
|
|||
class AfterScanModifier : AfterActionModification {
|
||||
override fun modify(payload: PayloadHolder, taskEvent: TaskEvent<*>, itemList: List<Item>): List<Item> {
|
||||
val foundItem = itemList.findDataItem(TlvId.CardId) ?: return listOf()
|
||||
val card = smartCast(taskEvent)?.card ?: return listOf()
|
||||
val actionView = payload.get(PayloadKey.actionView) as? ActionView ?: return listOf()
|
||||
|
||||
return if (taskEvent is TaskEvent.Event && taskEvent.data is ScanEvent.OnReadEvent) {
|
||||
val card = (taskEvent.data as ScanEvent.OnReadEvent).card
|
||||
val actionView = payload.remove(PayloadKey.actionView) as? ActionView ?: return listOf()
|
||||
|
||||
if (isPersonalized(card)) {
|
||||
actionView.showSnackbar(CardError.NotPersonalized)
|
||||
return listOf()
|
||||
}
|
||||
|
||||
return if (isNotPersonalized(card)) {
|
||||
actionView.showSnackbar(CardError.NotPersonalized)
|
||||
postUI { actionView.showActionFab(false) }
|
||||
listOf()
|
||||
} else {
|
||||
payload.set(PayloadKey.card, card)
|
||||
foundItem.setData(card.cardId)
|
||||
postUI { actionView.showActionFab(true) }
|
||||
listOf(foundItem)
|
||||
} else listOf()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isPersonalized(card: Card): Boolean = card.status == CardStatus.NotPersonalized
|
||||
private fun smartCast(taskEvent: TaskEvent<*>): ScanEvent.OnReadEvent? {
|
||||
return (taskEvent as? TaskEvent.Event)?.data as? ScanEvent.OnReadEvent
|
||||
}
|
||||
|
||||
private fun isNotPersonalized(card: Card): Boolean = card.status == CardStatus.NotPersonalized
|
||||
}
|
||||
|
|
@ -8,7 +8,9 @@ import com.tangem.tangemtest._arch.structure.PayloadHolder
|
|||
import com.tangem.tangemtest._arch.structure.abstraction.Item
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.PayloadKey
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.findDataItem
|
||||
import com.tangem.tangemtest.ucase.tunnel.ActionView
|
||||
import com.tangem.tangemtest.ucase.variants.TlvId
|
||||
import ru.dev.gbixahue.eu4d.lib.android.global.threading.postUI
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -30,6 +32,7 @@ class SignScanConsequence: ItemsChangeConsequence {
|
|||
val card = payload.remove(PayloadKey.card) as Card?
|
||||
if (card == null) {
|
||||
hashItem.restoreDefaultData()
|
||||
postUI { (payload.get(PayloadKey.actionView) as? ActionView)?.showActionFab(false) }
|
||||
} else {
|
||||
val dataForHashing = hashItem.getData() as? String ?: "Any data mother...s"
|
||||
val hashedData = when(card.curve) {
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ interface SnackbarHolder {
|
|||
}
|
||||
|
||||
interface ActionView : ViewScreen, SnackbarHolder {
|
||||
fun showActionFab(enable: Boolean)
|
||||
fun showActionFab(show: Boolean)
|
||||
}
|
||||
|
|
@ -126,8 +126,8 @@ abstract class BaseCardActionFragment : Fragment(), LayoutHolder, ActionView {
|
|||
return view as ViewGroup
|
||||
}
|
||||
|
||||
override fun showActionFab(enable: Boolean) {
|
||||
if (enable) actionFab.show() else actionFab.hide()
|
||||
override fun showActionFab(show: Boolean) {
|
||||
if (show) actionFab.show() else actionFab.hide()
|
||||
}
|
||||
|
||||
override fun showSnackbar(id: Id) {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ internal class Notifier(private val vm: ParamsViewModel) {
|
|||
private val gson: Gson = GsonInitializer().gson
|
||||
|
||||
fun handleActionResult(response: TaskEvent<*>, list: List<Item>) {
|
||||
notifyItemsChanged(list)
|
||||
if (list.isNotEmpty()) notifyItemsChanged(list)
|
||||
handleResponse(response)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@
|
|||
<string name="unknown">unknown</string>
|
||||
<string name="switch_description">Docs</string>
|
||||
|
||||
<string name="card_error_not_personalized">The card not personalized</string>
|
||||
<string name="card_error_not_personalized">Your card hasn\'t been personalized yet. You need to run personalize command first.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue