package com.bc_chat.circle.fragment

import android.os.Bundle

import com.bc_chat.bc_base.entity.contact.Dynamic
import com.bc_chat.circle.activity.TopicDetailsActivity
import com.bc_chat.circle.adapetr.MineTopicAdapter
import com.bc_chat.circle.dataSource.MineTopicDataSource
import com.zhaohaoting.framework.abs.BaseRecyclerFragment
import com.zhaohaoting.framework.abs.adapter.AbsRecyclerAdapter
import com.zhaohaoting.framework.mvchelper.mvc.IAsyncDataSource
import com.zhaohaoting.framework.utils.ActivityUtils

/**
 * author：Created by zhaohaoting on 2019/8/29
 * email：526309416@qq.com
 * desc：
 */
class MineTopicFragment : BaseRecyclerFragment<Dynamic, List<Dynamic>>() {

    private var type: String? = "1"

    override fun onInit() {
        type = arguments?.getString("type")

    }

    override fun getAdapter(): AbsRecyclerAdapter<Dynamic, List<Dynamic>>? = MineTopicAdapter(activity, type!!)

    override fun getDataSource(): IAsyncDataSource<List<Dynamic>>? = MineTopicDataSource(type!!)

    companion object {
        fun newInstance(type: String): MineTopicFragment {
            val args = Bundle()
            args.putString("type", type)
            val fragment = MineTopicFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun itemClicked(vh: AbsRecyclerAdapter.BaseViewHolder<*>?, position: Int) {
        val dynamic = adapter.data.get(position)
        ActivityUtils.newInstance(this)
                .putExtra("cid", dynamic.cid)
                .navigation(TopicDetailsActivity::class.java)
    }
}
