package com.bc_chat.circle.adapetr

import android.content.Context
import com.bc_chat.bc_base.entity.contact.Dynamic
import com.bc_chat.bc_base.entity.contact.UserCircleDetailModel
import com.bc_chat.contacts.R
import com.bc_chat.contacts.databinding.ItemUserCircleBinding
import com.umeng.socialize.utils.DeviceConfig.context
import com.zhaohaoting.framework.abs.adapter.AbsRecyclerAdapter
import com.zhaohaoting.framework.abs.adapter.ListToAdapter
import com.zhaohaoting.framework.utils.format.MsTransformation
import com.zhaohaoting.framework.utils.glid.GlideUtils

/**
 * author：Created by zhaohaoting on 2019/8/28
 * email：526309416@qq.com
 * desc：
 */
class MineTopicAdapter(context: Context, val type: String) : ListToAdapter<Dynamic, List<Dynamic>>(context) {

    override fun getItemLayoutId(type: Int): Int = R.layout.item_user_circle

    override fun onBindViewHolderHF(baseViewHolder: AbsRecyclerAdapter.BaseViewHolder<*>?, realPosition: Int, data: Dynamic?) {
        val binding = baseViewHolder?.dataBinding as ItemUserCircleBinding
        if ("1".equals(type)) {
            binding.tvTitle.text = data?.title
        } else {
            binding.tvTitle.text = "回复：《%s》".format(data?.title)

        }
        GlideUtils.loadCircleImage(context, data?.photo, binding.ivPhoto)
        binding.tvCommentCount.text = data?.comments_count.toString()
        binding.tvTime.text = MsTransformation.formatTimesBefore1(data?.c_time!! * 1000, System.currentTimeMillis())
    }
}