package com.gh.gamecenter.feature.exposure

import android.content.Context
import android.util.AttributeSet
import androidx.cardview.widget.CardView

class ExposurableCardView: CardView, IExposureListProvider {

    private var boundedExposureEventList: List<ExposureEvent>? = null

    constructor(context: Context) : this(context, null)
    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

    fun setExposureEventList(exposureEventList: List<ExposureEvent>) {
        boundedExposureEventList = exposureEventList
    }

    override fun provideExposureData(): ExposureEvent? = null

    override fun provideExposureDataList(): List<ExposureEvent>? {
        boundedExposureEventList?.forEach {
            it.getFreshExposureEvent()
        }
        return boundedExposureEventList
    }

}