package com.bc_chat.contacts.presenter

import com.bc_chat.contacts.contract.ModifyGroupNickContract
import com.bc_chat.contacts.task.ModifyGroupNickTask
import com.google.gson.JsonObject
import com.zhaohaoting.framework.abs.presenter.BasePresenter
import com.zhaohaoting.framework.requset.NetWorkCallBack
import java.lang.Exception

/**
 * author：Created by zhaohaoting on 2019/3/6
 * email：526309416@qq.com
 * desc：修改群名称
 */
open class ModifyGroupNickPresenter(view: ModifyGroupNickContract.View) : BasePresenter<ModifyGroupNickContract.View>(view), ModifyGroupNickContract.Presenter {

    override fun modifyGroupNick(groupId: String?, groupName: String?, userName: String?, uids: String) {
        taskHelper.execute<Any>(ModifyGroupNickTask(groupId, groupName, userName, uids), object : NetWorkCallBack<JsonObject>() {
            override fun onPreExecute(task: Any?) {
                super.onPreExecute(task)
                view.showLoading(task)
            }

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

            override fun onPostExecuteSuccess(task: Any?, data: JsonObject?) {
                view.dismissLoading(task)
                view.modifyGroupNickSuccess()
            }
        })
    }

}
