package com.bc_chat.im.module;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import io.rong.imkit.DefaultExtensionModule;
import io.rong.imkit.RongExtension;
import io.rong.imkit.emoticon.IEmoticonTab;
import io.rong.imkit.plugin.IPluginModule;
import io.rong.imkit.plugin.ImagePlugin;
import io.rong.imlib.model.Conversation;

/**
 * author：Created by zhaohaoting on 2018/11/14
 * email：526309416@qq.com
 * desc：
 */
public class SampleExtensionModule extends DefaultExtensionModule {

    private List<IPluginModule> mPluginModules;
    private String mTargetId;

    @Override
    public void onAttachedToExtension(RongExtension extension) {
        super.onAttachedToExtension(extension);
        mTargetId = extension.getTargetId();
    }

    @Override
    public List<IPluginModule> getPluginModules(Conversation.ConversationType conversationType) {
        mPluginModules = new ArrayList<>();
        List<IPluginModule> pluginModules = super.getPluginModules(conversationType);
        Iterator<IPluginModule> iterator = pluginModules.iterator();
        while (iterator.hasNext()) {
            IPluginModule next = iterator.next();
            if (next instanceof ImagePlugin) {
                mPluginModules.add(next);
            }
        }
        return mPluginModules;
    }

    @Override
    public List<IEmoticonTab> getEmoticonTabs() {
        return super.getEmoticonTabs();
    }
}
