blob: c6830d8015f2da618152d9e8f3f710980d867bc6 [file] [log] [blame]
package com.airbnb.lottie.samples
import android.content.Context
import android.support.annotation.DrawableRes
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import com.airbnb.epoxy.CallbackProp
import com.airbnb.epoxy.ModelProp
import com.airbnb.epoxy.ModelView
import com.airbnb.epoxy.TextProp
import kotlinx.android.synthetic.main.list_item_preview.view.*
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)
class PreviewItemView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
init {
orientation = VERTICAL
inflate(R.layout.list_item_preview)
}
@TextProp
fun setTitle(title: CharSequence) {
titleView.text = title
}
@ModelProp
fun setIcon(@DrawableRes icon: Int) {
iconView.setImageResource(icon)
}
@CallbackProp
fun setClickListener(clickListener: View.OnClickListener?) {
container.setOnClickListener(clickListener)
}
}