package com.adealink.weparty.commonui.widget.banner.adapter

import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.adealink.weparty.commonui.imageview.FusionPreviewImageView

/**
 * 可缩放预览图片的BannerAdapter
 * Created by XiaoDongLin.
 * Date: 2024/12/26
 */
class PreviewImageViewBannerAdapter(dataList: List<String>) :
    BannerAdapter<String, PreviewImageViewHolder>(dataList) {
    override fun onCreateHolder(parent: ViewGroup, viewType: Int): PreviewImageViewHolder {
        val preImageView = FusionPreviewImageView(parent.context)

        //注意，必须设置为match_parent，这个是viewpager2强制要求的
        val params = ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT
        )
        preImageView.setLayoutParams(params)
        return PreviewImageViewHolder(preImageView)
    }

    override fun onBindView(holder: PreviewImageViewHolder, data: String, position: Int, size: Int) {
        holder.preImageView.setImagePath(urlPath = data)
    }
}

class PreviewImageViewHolder(val preImageView: FusionPreviewImageView) :
    RecyclerView.ViewHolder(preImageView) {

}


