package com.bc_chat.bc_base.presenter

import com.bc_chat.bc_base.contract.GroupMemberContract
import com.bc_chat.bc_base.entity.ListModel
import com.bc_chat.bc_base.entity.group.MemberBean
import com.bc_chat.bc_base.task.GroupMemberDataSource
import com.zhaohaoting.framework.abs.presenter.BasePresenter
import com.zhaohaoting.framework.requset.NetWorkCallBack
import java.lang.Exception

/**
 * author：Created by zhaohaoting on 2019/3/8
 * email：526309416@qq.com
 * desc：
 */
class GroupMemberPresenter<T>(view: GroupMemberContract.View) : BasePresenter<GroupMemberContract.View>(view), GroupMemberContract.Presenter {

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

        taskHelper.execute<Any>(GroupMemberDataSource(groupId!!), object : NetWorkCallBack<ListModel<MemberBean>>() {

            override fun onPreExecute(task: Any?) {
                super.onPreExecute(task)
                if (isShowDialog!!) {
                    view.showLoading(task)
                }
            }

            override fun onPostExecuteFailure(task: Any?, exception: Exception) {
                super.onPostExecuteFailure(task, exception)
                view.dismissLoading(task)
                view.queryGroupMemberFailure(exception)
            }

            override fun onPostExecuteSuccess(task: Any, memberModel: ListModel<MemberBean>) {
                view.dismissLoading(task)
                view.queryGroupMemberSuccess(memberModel)
            }
        })
    }
}
