package com.bc_chat.im.messages.collection

import android.content.Context
import android.content.Intent
import android.graphics.drawable.Drawable
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat

import com.bc_chat.im.R
import com.bc_chat.im.activity.CollectionActivity

import io.rong.imkit.RongExtension
import io.rong.imkit.plugin.IPluginModule
import io.rong.imlib.model.Conversation

/**
 * author：Created by zhaohaoting on 2019/03/03
 * email：526309416@qq.com
 * desc：
 */
class CollectionPlugin : IPluginModule {

    private var context: Context? = null
    private var conversationType: Conversation.ConversationType? = null
    private var targetId: String? = null

    override fun obtainDrawable(context: Context): Drawable? {
        return ContextCompat.getDrawable(context, R.drawable.rc_collect_plugin_icon)
    }

    override fun obtainTitle(context: Context): String {
        return "收藏"
    }

    override fun onClick(currentFragment: Fragment, extension: RongExtension) {
        context = currentFragment.activity
        conversationType = extension.conversationType
        targetId = extension.targetId
        val intent = Intent(context, CollectionActivity::class.java)
        intent.putExtra("conversationType", conversationType)
        intent.putExtra("targetId", targetId)
        context!!.startActivity(intent)
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {}
}
