use of in.bugzy.data.remote.model.EditCaseData in project bugzy by cpunq.
the class CasesRepository method editCase.
public LiveData<Resource<Response<EditCaseData>>> editCase(final CaseEditRequest request, int mode, List<Attachment> attachments) {
NetworkBoundTask<Response<EditCaseData>> task = new NetworkBoundTask<Response<EditCaseData>>(mAppExecutors, mGson) {
@Override
public void saveCallResult(@NonNull Response<EditCaseData> result) {
// Save?? ;)
if (result.getData() == null) {
return;
}
}
@NonNull
@Override
protected Call<Response<EditCaseData>> createCall() {
List<MultipartBody.Part> fileParts = new ArrayList<>();
int i = 0;
for (Attachment attachment : attachments) {
fileParts.add(prepareFilePart("File" + i, attachment.getUri()));
i++;
}
request.setFileCount(fileParts.size());
request.setToken(mPrefs.getString(PrefsHelper.Key.ACCESS_TOKEN));
switch(mode) {
case CaseEditActivity.MODE_EDIT:
case CaseEditActivity.MODE_ASSIGN:
return mApiService.editCase(request, fileParts);
case CaseEditActivity.MODE_NEW:
return mApiService.newCase(request, fileParts);
case CaseEditActivity.MODE_CLOSE:
return mApiService.closeCase(request, fileParts);
case CaseEditActivity.MODE_RESOLVE:
return mApiService.resolveCase(request, fileParts);
case CaseEditActivity.MODE_REACTIVATE:
return mApiService.reactivateCase(request, fileParts);
case CaseEditActivity.MODE_REOPEN:
return mApiService.reopenCase(request, fileParts);
default:
return mApiService.editCase(request, fileParts);
}
}
};
mAppExecutors.networkIO().execute(task);
return task.asLiveData();
}
Aggregations