use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder in project a-medic-log by rh-id.
the class MedicineDao method updateMedicine.
@Transaction
public void updateMedicine(Medicine medicine, ArrayList<MedicineReminder> medicineReminders) {
update(medicine);
long medsId = medicine.id;
if (medicineReminders != null && !medicineReminders.isEmpty()) {
for (MedicineReminder medicineReminder : medicineReminders) {
medicineReminder.medicineId = medsId;
if (medicineReminder.id == null) {
insertMedicineReminder(medicineReminder);
} else {
update(medicineReminder);
}
}
}
}
use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder 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.entity.MedicineReminder in project a-medic-log by rh-id.
the class MedicineState method readObject.
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
Medicine medicine = (Medicine) in.readObject();
ArrayList<MedicineReminder> medicineReminders = (ArrayList<MedicineReminder>) in.readObject();
mMedicineSubject = BehaviorSubject.createDefault(medicine);
mMedicineReminderListSubject = BehaviorSubject.createDefault(medicineReminders);
}
use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder in project a-medic-log by rh-id.
the class MedicineState method clone.
@Override
public MedicineState clone() {
MedicineState medicineState = new MedicineState();
Medicine medicine = mMedicineSubject.getValue();
if (medicine != null) {
medicine = medicine.clone();
}
medicineState.updateMedicine(medicine);
ArrayList<MedicineReminder> medicineReminders = mMedicineReminderListSubject.getValue();
if (medicineReminders != null) {
ArrayList<MedicineReminder> clonedList = new ArrayList<>(medicineReminders.size());
for (MedicineReminder medicineReminder : medicineReminders) {
clonedList.add(medicineReminder.clone());
}
medicineReminders = clonedList;
} else {
medicineReminders = new ArrayList<>();
}
medicineState.updateMedicineReminderList(medicineReminders);
return medicineState;
}
use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder in project a-medic-log by rh-id.
the class MedicineReminderItemSV method createView.
@Override
protected View createView(Activity activity, ViewGroup container) {
View rootLayout = activity.getLayoutInflater().inflate(R.layout.item_medicine_reminder, container, false);
rootLayout.findViewById(R.id.root_layout).setOnClickListener(this);
TextView startDateText = rootLayout.findViewById(R.id.text_start_date);
TextView messageText = rootLayout.findViewById(R.id.text_message);
SwitchCompat enabledButton = rootLayout.findViewById(R.id.button_enabled);
enabledButton.setOnClickListener(this);
Button deleteButton = rootLayout.findViewById(R.id.button_delete);
deleteButton.setOnClickListener(this);
mSvProvider.get(RxDisposer.class).add("createView_onMedicineReminderChanged", mMedicineReminderSubject.getSubject().observeOn(AndroidSchedulers.mainThread()).subscribe(medicineReminder -> {
startDateText.setText(mDateFormat.format(medicineReminder.startDateTime));
messageText.setText(medicineReminder.message);
enabledButton.setChecked(medicineReminder.reminderEnabled);
}));
return rootLayout;
}
Aggregations