| | |
| | | package cn.flightfeather.thirdapp.repository |
| | | |
| | | import cn.flightfeather.thirdapp.common.net.ResultCallBack |
| | | import cn.flightfeather.thirdapp.common.net.ResultObserver |
| | | import cn.flightfeather.thirdapp.common.net.RetrofitFactory |
| | | import cn.flightfeather.thirdapp.httpservice.CommonService |
| | | import cn.flightfeather.thirdapp.model.enumreation.MediaFileType |
| | | import cn.flightfeather.thirdapp.repository.dao.MediaTypeAliasDao |
| | | import io.reactivex.schedulers.Schedulers |
| | | import okhttp3.MediaType |
| | | import okhttp3.MultipartBody |
| | | import okhttp3.RequestBody |
| | | import retrofit2.Response |
| | | import java.io.File |
| | | |
| | | /** |
| | |
| | | * Date: 2020/4/23 |
| | | */ |
| | | class CommonRepository { |
| | | private val mediaTypeAliasDao = MediaTypeAliasDao() |
| | | |
| | | fun upLoadCrashInfo(accountName: String, file: File, resultCallBack: ResultCallBack<Boolean>) { |
| | | val builder = MultipartBody.Builder() |
| | |
| | | .upLoadCrashInfo(accountName, partList) |
| | | .subscribeOn(Schedulers.io()) |
| | | .observeOn(Schedulers.trampoline()) |
| | | .subscribe() |
| | | .subscribe({ |
| | | resultCallBack.onSuccess(it.body()) |
| | | }, { |
| | | resultCallBack.onFailure() |
| | | }) |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取“任意拍”模块展示的图片类型 |
| | | */ |
| | | fun getMediaFileTypes(sceneTypeId: Int, resultCallBack: ResultCallBack<List<MediaFileType>>) { |
| | | resultCallBack.onSuccess(MediaFileType.getList(sceneTypeId)) |
| | | } |
| | | |
| | | /** |
| | | * 获取媒体文件类型的别名 |
| | | * @param sceneTypeId 场景id |
| | | * @param mediaFileType 媒体文件类型id |
| | | */ |
| | | fun getAlias(sceneTypeId: Int, mediaFileType: MediaFileType, resultCallBack: ResultCallBack<String>) { |
| | | val dbService = mediaTypeAliasDao.getAlias(sceneTypeId, mediaFileType) |
| | | .map { Response.success(it) } |
| | | |
| | | RetrofitFactory.executeResult(dbService, object : ResultObserver<String>() { |
| | | override fun onSuccess(result: String?) { |
| | | resultCallBack.onSuccess(result) |
| | | } |
| | | |
| | | override fun onFailure(e: Throwable, isNetWorkError: Boolean) { |
| | | resultCallBack.onFailure() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 更新媒体文件类型的别名 |
| | | * @param sceneTypeId 场景id |
| | | * @param mediaFileType 媒体文件类型id |
| | | * @param alias 别名 |
| | | */ |
| | | fun updateAlias(sceneTypeId: Int, mediaFileType: MediaFileType, alias: String, resultCallBack: ResultCallBack<Boolean>) { |
| | | val dbService = mediaTypeAliasDao.updateAlias(sceneTypeId, mediaFileType, alias) |
| | | .map { Response.success(it) } |
| | | |
| | | RetrofitFactory.executeResult(dbService, object : ResultObserver<Boolean>() { |
| | | override fun onSuccess(result: Boolean?) { |
| | | resultCallBack.onSuccess(result) |
| | | } |
| | | |
| | | override fun onFailure(e: Throwable, isNetWorkError: Boolean) { |
| | | resultCallBack.onFailure() |
| | | } |
| | | }) |
| | | } |
| | | } |