package com.example.samplejavaapp.wrappers.event

import android.app.Activity
import pl.novelpay.app2app.model.state.AuthorisationTransactionState
import pl.novelpay.app2app.model.state.PaymentTransactionState
import pl.novelpay.client.core.internal.EventHandler
import pl.novelpay.client.sdk.communication.processor.EventObserver
import pl.novelpay.client.sdk.communication.processor.ObservableEvent

open class JEventHandler : EventObserver {
    private lateinit var bringToForeground: (Class<out Activity>) -> Unit

    override fun EventHandler.observe(event: ObservableEvent) {
        bringToForeground = { aClass ->
            bringToForeground(aClass.kotlin)
        }
    }

    fun toForeground(clazz: Class<out Activity>) {
        if(this::bringToForeground.isInitialized)
        bringToForeground(clazz)
    }

    open fun onServerEvent(event: ObservableEvent.ServerEvent) {}
    open fun onPaymentAppIDLE() {}
    open fun onPaymentAppProcessing(event: PaymentTransactionState) {}
    open fun onPaymentAppAuthorisation(event: AuthorisationTransactionState) {}
}