package com.bc_chat.circle.presenter

import com.bc_chat.bc_base.presenter.UpLoadPicturePresenter
import com.bc_chat.circle.contract.ReleaseTopicContract
import com.bc_chat.circle.task.ReleaseTopicTask
import com.google.gson.JsonObject
import com.zhaohaoting.framework.requset.NetWorkCallBack
import java.lang.Exception

/**
 * author：Created by zhaohaoting on 2019/8/28
 * email：526309416@qq.com
 * desc：
 */
class ReleaseTopicPresenter(view: ReleaseTopicContract.View) : UpLoadPicturePresenter<ReleaseTopicContract.View>(view), ReleaseTopicContract.Presenter {
    override fun releaseTopic(title: String, content: String, imgs: String) {
        taskHelper.execute<Any>(ReleaseTopicTask(title, content, imgs), object : NetWorkCallBack<JsonObject>() {

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

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

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