use of in.bugzy.data.model.Attachment in project bugzy by cpunq.
the class CaseEditActivity method setupEventsRecyclerView.
private void setupEventsRecyclerView() {
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
mEventsRecyclerView.setLayoutManager(layoutManager);
mAdapter = new CaseEventsAdapter(this);
mAdapter.setOnAttachmentClickListener(new CaseEventsAdapter.OnAttachmentClickListener() {
@Override
public void onAttachmentClick(View v, CaseEvent event, int attachmentPosition) {
Attachment attachment = event.getsAttachments().get(attachmentPosition);
String filename = attachment.getFilename().toLowerCase();
if (filename.endsWith("png") || filename.endsWith("jpg") || filename.endsWith("jpeg")) {
openImageActivity(v, attachment.getFullUrl());
return;
}
// For other attachments leave things to browser
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(attachment.getFullUrl()));
startActivity(i);
}
});
mEventsRecyclerView.setAdapter(mAdapter);
mEventsRecyclerView.setNestedScrollingEnabled(false);
}
use of in.bugzy.data.model.Attachment in project bugzy by cpunq.
the class CaseDetailsFragment method setupViews.
private void setupViews() {
mlinearLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mlinearLayoutManager);
mAdapter = new CaseEventsAdapter(getContext());
mRecyclerView.setAdapter(mAdapter);
mAdapter.setOnAttachmentClickListener((view, event, attachmentPosition) -> {
// TODO: Move this logic to ViewModel
Attachment attachment = event.getsAttachments().get(attachmentPosition);
String filename = attachment.getFilename().toLowerCase();
if (filename.endsWith("png") || filename.endsWith("jpg") || filename.endsWith("jpeg")) {
mParentActivity.openImageActivity(view, attachment.getFullUrl());
return;
}
// For other attachments leave things to browser
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(attachment.getFullUrl()));
startActivity(i);
});
prepareActionsButtons();
prepareRecyclerScrollListener();
}
use of in.bugzy.data.model.Attachment in project bugzy by cpunq.
the class CaseEditViewModel method addAttachment.
public void addAttachment(Uri fileUri) {
Attachment at = new Attachment();
at.setUri(fileUri);
mAttachmentsLiveData.getValue().add(at);
// Trigger update
mAttachmentsLiveData.setValue(mAttachmentsLiveData.getValue());
mScrollAttachmentsToLast.call();
}
use of in.bugzy.data.model.Attachment 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