package com.cheng.blzb.ui.fragment.photo

import coil.load
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.github.chrisbanes.photoview.PhotoView
import com.cheng.blzb.R
import com.cheng.blzb.utils.BitmapUtils

class PhotoViewAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.listitem_photo_view) {

    override fun convert(holder: BaseViewHolder, item: String) {
        if (item.startsWith("http")) {
            holder.getView<PhotoView>(R.id.iv_photo).load(item)
        } else {
            BitmapUtils.compressImg(context, item) {
                holder.getView<PhotoView>(R.id.iv_photo).load(it)
            }
        }
    }
}