package com.bc_chat.bc_base.presenter

import com.bc_chat.bc_base.contract.UpdateVersonContract
import com.bc_chat.bc_base.entity.ApkVersion
import com.bc_chat.bc_base.task.UpdateVersonTask
import com.zhaohaoting.framework.abs.presenter.BasePresenter
import com.zhaohaoting.framework.requset.NetWorkCallBack

/**
 * author：Created by zhaohaoting on 2019/7/19
 * email：526309416@qq.com
 * desc：
 */
class UpdateVersonPresenter<VIEW : UpdateVersonContract.View>(view: VIEW) : BasePresenter<VIEW>(view), UpdateVersonContract.Presenter {

    override fun getUpdateVerson(isShowDialog: Boolean?) {
        taskHelper.execute<Any>(UpdateVersonTask(), object : NetWorkCallBack<ApkVersion>() {
            override fun onPreExecute(task: Any) {
                if (isShowDialog!!) {
                    view.showLoading(task)
                }
            }

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

            override fun onPostExecuteSuccess(task: Any, verson: ApkVersion) {
                view.dismissLoading(task)
                view.getUpdateVersonSuccess(verson)
            }
        })
    }
}
