use of m.co.rh.id.a_medic_log.base.state.NoteAttachmentState in project a-medic-log by rh-id.
the class NoteAttachmentDetailPage method provideComponent.
@Override
public void provideComponent(Provider provider) {
mSvProvider = provider.get(StatefulViewProvider.class);
mExecutorService = mSvProvider.get(ExecutorService.class);
mRxDisposer = mSvProvider.get(RxDisposer.class);
mFileHelper = mSvProvider.get(FileHelper.class);
mLogger = mSvProvider.get(ILogger.class);
mNewNoteAttachmentFileCmd = mSvProvider.get(NewNoteAttachmentFileCmd.class);
mDeleteNoteAttachmentFileCmd = mSvProvider.get(DeleteNoteAttachmentFileCmd.class);
boolean isUpdate = isUpdate();
if (isUpdate) {
mNewNoteAttachmentCmd = mSvProvider.get(UpdateNoteAttachmentCmd.class);
} else {
mNewNoteAttachmentCmd = mSvProvider.get(NewNoteAttachmentCmd.class);
}
if (mAppBarSV == null) {
mAppBarSV = new AppBarSV(R.menu.page_note_attachment_detail);
}
if (mNoteAttachmentState == null) {
if (isUpdate) {
mNoteAttachmentState = getNoteAttachmentState();
} else {
mNoteAttachmentState = new NoteAttachmentState();
if (shouldSave()) {
mNoteAttachmentState.setNoteId(getNoteId());
}
}
}
mNameTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
// leave blank
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
// leave blank
}
@Override
public void afterTextChanged(Editable editable) {
String name = editable.toString();
mNoteAttachmentState.setName(name);
mNewNoteAttachmentCmd.valid(mNoteAttachmentState);
}
};
mNoteAttachmentFileRecyclerViewAdapter = new NoteAttachmentFileRecyclerViewAdapter(mNoteAttachmentState, this, mNavigator, this);
}
use of m.co.rh.id.a_medic_log.base.state.NoteAttachmentState in project a-medic-log by rh-id.
the class NoteDao method insertNote.
@Transaction
public void insertNote(NoteState noteState) {
Note note = noteState.getNote();
Set<NoteTag> noteTags = noteState.getNoteTagSet();
List<NoteAttachmentState> noteAttachmentStates = noteState.getNoteAttachmentStates();
List<MedicineState> medicineStates = noteState.getMedicineList();
long noteId = insert(note);
note.id = noteId;
if (noteTags != null && !noteTags.isEmpty()) {
for (NoteTag noteTag : noteTags) {
noteTag.noteId = noteId;
noteTag.id = insert(noteTag);
}
}
if (noteAttachmentStates != null && !noteAttachmentStates.isEmpty()) {
for (NoteAttachmentState noteAttachmentState : noteAttachmentStates) {
NoteAttachment noteAttachment = noteAttachmentState.getNoteAttachment();
noteAttachment.noteId = noteId;
insertNoteAttachment(noteAttachmentState);
}
}
if (medicineStates != null && !medicineStates.isEmpty()) {
for (MedicineState medicineState : medicineStates) {
Medicine medicine = medicineState.getMedicine();
medicine.noteId = noteId;
long medicineId = insert(medicine);
medicine.id = medicineId;
List<MedicineReminder> medicineReminders = medicineState.getMedicineReminderList();
if (medicineReminders != null && !medicineReminders.isEmpty()) {
for (MedicineReminder medicineReminder : medicineReminders) {
medicineReminder.medicineId = medicineId;
medicineReminder.id = insert(medicineReminder);
}
}
}
}
}
use of m.co.rh.id.a_medic_log.base.state.NoteAttachmentState in project a-medic-log by rh-id.
the class NoteAttachmentItemSV method onClick.
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.button_edit) {
if (mNoteAttachmentItemOnEditClick != null) {
mNoteAttachmentItemOnEditClick.noteAttachment_onEditClick(mNoteAttachmentStateSubject.getValue());
}
} else if (id == R.id.button_delete) {
if (mNoteAttachmentItemOnDeleteClick != null) {
mNoteAttachmentItemOnDeleteClick.noteAttachment_onDeleteClick(mNoteAttachmentStateSubject.getValue());
}
} else if (id == R.id.button_share) {
Activity activity = mNavigator.getActivity();
NoteAttachmentState noteAttachmentState = mNoteAttachmentStateSubject.getValue();
String text = noteAttachmentState.getName();
ArrayList<NoteAttachmentFile> attachmentFiles = noteAttachmentState.getNoteAttachmentFiles();
ArrayList<Uri> imageUris = new ArrayList<>();
if (!attachmentFiles.isEmpty()) {
for (NoteAttachmentFile noteAttachmentFile : attachmentFiles) {
Uri fileUri = FileProvider.getUriForFile(activity, Constants.FILE_PROVIDER_AUTHORITY, mFileHelper.getNoteAttachmentImage(noteAttachmentFile.fileName));
imageUris.add(fileUri);
}
}
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
sendIntent.putExtra(Intent.EXTRA_TEXT, text);
sendIntent.setType("image/*");
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
Intent shareIntent = Intent.createChooser(sendIntent, null);
activity.startActivity(shareIntent);
}
}
use of m.co.rh.id.a_medic_log.base.state.NoteAttachmentState in project a-medic-log by rh-id.
the class NoteAttachmentItemSV method createView.
@Override
protected View createView(Activity activity, ViewGroup container) {
ViewGroup rootLayout = (ViewGroup) activity.getLayoutInflater().inflate(R.layout.item_note_attachment, container, false);
rootLayout.setOnClickListener(this);
Button buttonShare = rootLayout.findViewById(R.id.button_share);
Button buttonEdit = rootLayout.findViewById(R.id.button_edit);
Button buttonDelete = rootLayout.findViewById(R.id.button_delete);
buttonEdit.setOnClickListener(this);
buttonDelete.setOnClickListener(this);
buttonShare.setOnClickListener(this);
TextView nameText = rootLayout.findViewById(R.id.text_name);
RecyclerView noteAttachmentFileRecyclerView = rootLayout.findViewById(R.id.recyclerView_note_attachment_file);
mRxDisposer.add("createView_onNoteAttachmentChanged", mNoteAttachmentStateSubject.getSubject().observeOn(AndroidSchedulers.mainThread()).subscribe(noteAttachmentState -> {
int size = noteAttachmentState.getNoteAttachmentFiles().size();
nameText.setText(noteAttachmentState.getName() + " (" + size + ") ");
if (mNoteAttachmentFileRecyclerViewAdapter != null) {
noteAttachmentFileRecyclerView.setAdapter(null);
mNoteAttachmentFileRecyclerViewAdapter.dispose(activity);
}
if (!noteAttachmentState.getNoteAttachmentFiles().isEmpty()) {
mNoteAttachmentFileRecyclerViewAdapter = new NoteAttachmentFileRecyclerViewAdapter(getNoteAttachmentState(), null, true, mNavigator, this);
noteAttachmentFileRecyclerView.setAdapter(mNoteAttachmentFileRecyclerViewAdapter);
noteAttachmentFileRecyclerView.setVisibility(View.VISIBLE);
} else {
noteAttachmentFileRecyclerView.setVisibility(View.GONE);
}
}));
return rootLayout;
}
use of m.co.rh.id.a_medic_log.base.state.NoteAttachmentState in project a-medic-log by rh-id.
the class NoteAttachmentRecyclerViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ItemViewHolder) {
ArrayList<NoteAttachmentState> itemArrayList = mNoteState.getNoteAttachmentStates();
NoteAttachmentState item = itemArrayList.get(position);
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
itemViewHolder.setItem(item);
}
}
Aggregations