package com.bc_chat.im.plug

import android.view.KeyEvent
import android.widget.EditText
import io.rong.common.RLog
import io.rong.imkit.IExtensionModule
import io.rong.imkit.RongExtension
import io.rong.imkit.RongIM
import io.rong.imkit.emoticon.EmojiTab
import io.rong.imkit.emoticon.IEmojiItemClickListener
import io.rong.imkit.emoticon.IEmoticonTab
import io.rong.imkit.plugin.IPluginModule
import io.rong.imkit.plugin.ImagePlugin
import io.rong.imkit.widget.provider.ImageMessageItemProvider
import io.rong.imlib.model.Conversation
import io.rong.imlib.model.Message
import io.rong.message.ImageMessage
import java.util.*

/**
 * author：Created by zhaohaoting on 2019/3/15
 * email：526309416@qq.com
 * desc：
 */
class ImageExtensioModule : IExtensionModule {

    override fun getEmoticonTabs(): MutableList<IEmoticonTab>? {
        return null
    }

    private var mEditText: EditText? = null
    private var stack: Stack<EditText>? = null
    private var types: Array<String>? = null

    override fun onInit(appKey: String) {
        //自定义震动消息
        RongIM.registerMessageType(ImageMessage::class.java)
        RongIM.registerMessageTemplate(ImageMessageItemProvider())
    }

    override fun onAttachedToExtension(extension: RongExtension) {
        this.mEditText = extension.inputEditText
        this.stack?.push(this.mEditText)
    }

    override fun onConnect(token: String) {}


    override fun onDetachedFromExtension() {}

    override fun onReceivedMessage(message: Message) {}

    override fun getPluginModules(conversationType: Conversation.ConversationType): List<IPluginModule> {
        val pluginModules = arrayListOf<IPluginModule>()
        pluginModules.add(ImagePlugin())
        return pluginModules
    }


    override fun onDisconnect() {}
}