use of in.bugzy.ui.caseevents.AttachmentsAdapter in project bugzy by cpunq.
the class CaseEditActivity method setupAttachmentsRecyclerView.
private void setupAttachmentsRecyclerView() {
mAttachmentsLayoutManager = new LinearLayoutManager(this);
mAttachmentsLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
mAttachmentsRecyclerView.setLayoutManager(mAttachmentsLayoutManager);
mAttachmentsRecyclerView.addItemDecoration(new ItemOffsetDecoration((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8f, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0f, getResources().getDisplayMetrics())));
mAttachmentsRecyclerView.setHasFixedSize(true);
mAttachmentsAdapter = new AttachmentsAdapter(null, this, "");
mAttachmentsRecyclerView.setAdapter(mAttachmentsAdapter);
mAttachmentsAdapter.setOnItemClickListener(new AttachmentsAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
PopupMenu popupMenu = new PopupMenu(CaseEditActivity.this, view);
popupMenu.setOnMenuItemClickListener(item -> {
if (item.getTitle().equals("Remove")) {
mCaseEditViewModel.removeAttachment(position);
} else {
openImageActivity(view, mAttachments.get(position).getUri().getPath());
}
return true;
});
popupMenu.getMenu().add("View");
popupMenu.getMenu().add("Remove");
popupMenu.show();
}
@Override
public void onItemLongClick(View view, int position) {
}
});
}
Aggregations