package com.bc_chat.bc_base.presenter

import android.arch.lifecycle.LifecycleOwner
import com.bc_chat.bc_base.contract.ChatContract
import com.bc_chat.bc_base.contract.GroupInfoContract
import com.bc_chat.bc_base.contract.UserInfoContract
import com.zhaohaoting.framework.abs.contract.BaseContract
import com.zhaohaoting.framework.abs.presenter.BasePresenter

/**
 * author：Created by zhaohaoting on 2019/3/12
 * email：526309416@qq.com
 * desc：
 */
class ChatPresenter constructor(view: ChatContract.View) : BasePresenter<BaseContract.BaseView>(view), ChatContract.Presenter {

    private var groupMemberPresenter: GroupMemberPresenter<Any?>? = null
    private var groupInfoPresenter: GroupInfoPresenter<GroupInfoContract.View>? = null
    private var userInfoPresenter: UserInfoPresenter<UserInfoContract.View>? = null

    override fun onCreate(owner: LifecycleOwner?) {
        super.onCreate(owner)
        owner?.lifecycle?.addObserver(groupMemberPresenter!!)
        owner?.lifecycle?.addObserver(groupInfoPresenter!!)
        owner?.lifecycle?.addObserver(userInfoPresenter!!)
    }

    init {
        groupMemberPresenter = GroupMemberPresenter(view)
        groupInfoPresenter = GroupInfoPresenter(view)
        userInfoPresenter = UserInfoPresenter(view)
    }

    override fun queryGroupMember(groupId: String, isShowDialog: Boolean?) {
        groupMemberPresenter?.queryGroupMember(groupId, isShowDialog)
    }

    override fun groupinfoTask(groupId: String) {
        groupInfoPresenter?.groupinfoTask(groupId, false)
    }

    override fun userInfoTask(cuid: String) {
        userInfoPresenter?.userInfoTask(cuid)
    }
}