package com.bc_chat.bc_base.presenter

import com.bc_chat.bc_base.contract.SetUserInfoContract
import com.bc_chat.bc_base.task.UserNoticeInfoTask
import com.google.gson.JsonObject
import com.zhaohaoting.framework.requset.NetWorkCallBack
import java.lang.Exception

/**
 * author：Created by zhaohaoting on 2019/3/19
 * email：526309416@qq.com
 * desc：
 */
class SetUserInfoPresenter(view: SetUserInfoContract.View) : UserInfoPresenter<SetUserInfoContract.View>(view), SetUserInfoContract.Presenter {
    override fun setUserNotice(cuid: String, type: String) {
        taskHelper.execute<Any>(UserNoticeInfoTask(cuid, type), 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.userNoticeFailure(exception)
            }

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