use of m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineReminderCmd in project a-medic-log by rh-id.
the class MedicineDetailPage method onEnableSwitchClick.
@Override
public void onEnableSwitchClick(MedicineReminder medicineReminder) {
// save only if this is update medicine AND save flag enabled
if (isUpdate() && shouldSave()) {
Context context = mSvProvider.getContext();
UpdateMedicineReminderCmd updateMedicineReminderCmd = mSvProvider.get(UpdateMedicineReminderCmd.class);
if (updateMedicineReminderCmd.valid(medicineReminder)) {
mRxDisposer.add("onEnableSwitchClick_saveMedicineReminder", updateMedicineReminderCmd.execute(medicineReminder).observeOn(AndroidSchedulers.mainThread()).subscribe((medicineState, throwable) -> {
String errorMessage = context.getString(R.string.error_failed_to_update_medicine_reminder);
String successMessage = context.getString(R.string.success_updating_medicine_reminder);
if (throwable != null) {
mSvProvider.get(ILogger.class).e(TAG, errorMessage, throwable);
} else {
mSvProvider.get(ILogger.class).i(TAG, successMessage);
}
}));
} else {
String error = updateMedicineReminderCmd.getValidationError();
mSvProvider.get(ILogger.class).i(TAG, error);
}
mSvProvider.get(UpdateMedicineReminderCmd.class).execute(medicineReminder);
} else {
mMedicineReminderRecyclerViewAdapter.notifyItemUpdated(medicineReminder);
}
}
use of m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineReminderCmd in project a-medic-log by rh-id.
the class CommandProviderModule method provides.
@Override
public void provides(Context context, ProviderRegistry providerRegistry, Provider provider) {
providerRegistry.registerLazy(NewProfileCmd.class, () -> new NewProfileCmd(context, provider));
providerRegistry.registerLazy(UpdateProfileCmd.class, () -> new UpdateProfileCmd(context, provider));
providerRegistry.registerLazy(DeleteProfileCmd.class, () -> new DeleteProfileCmd(context, provider));
providerRegistry.registerLazy(PagedProfileItemsCmd.class, () -> new PagedProfileItemsCmd(context, provider));
providerRegistry.registerLazy(DeleteNoteCmd.class, () -> new DeleteNoteCmd(context, provider));
providerRegistry.registerLazy(PagedNoteItemsCmd.class, () -> new PagedNoteItemsCmd(context, provider));
providerRegistry.registerLazy(NewNoteCmd.class, () -> new NewNoteCmd(context, provider));
providerRegistry.registerLazy(UpdateNoteCmd.class, () -> new UpdateNoteCmd(context, provider));
providerRegistry.registerLazy(QueryNoteCmd.class, () -> new QueryNoteCmd(provider));
providerRegistry.registerLazy(NewNoteTagCmd.class, () -> new NewNoteTagCmd(context, provider));
providerRegistry.registerLazy(DeleteNoteTagCmd.class, () -> new DeleteNoteTagCmd(context, provider));
providerRegistry.registerLazy(NewMedicineCmd.class, () -> new NewMedicineCmd(context, provider));
providerRegistry.registerLazy(UpdateMedicineCmd.class, () -> new UpdateMedicineCmd(context, provider));
providerRegistry.registerLazy(DeleteMedicineCmd.class, () -> new DeleteMedicineCmd(context, provider));
providerRegistry.registerLazy(QueryMedicineCmd.class, () -> new QueryMedicineCmd(provider));
providerRegistry.registerLazy(NewMedicineReminderCmd.class, () -> new NewMedicineReminderCmd(context, provider));
providerRegistry.registerLazy(UpdateMedicineReminderCmd.class, () -> new UpdateMedicineReminderCmd(context, provider));
providerRegistry.registerLazy(DeleteMedicineReminderCmd.class, () -> new DeleteMedicineReminderCmd(context, provider));
providerRegistry.registerLazy(NewMedicineIntakeCmd.class, () -> new NewMedicineIntakeCmd(context, provider));
providerRegistry.registerLazy(UpdateMedicineIntakeCmd.class, () -> new UpdateMedicineIntakeCmd(context, provider));
providerRegistry.registerLazy(DeleteMedicineIntakeCmd.class, () -> new DeleteMedicineIntakeCmd(context, provider));
providerRegistry.registerLazy(PagedMedicineIntakeItemsCmd.class, () -> new PagedMedicineIntakeItemsCmd(context, provider));
providerRegistry.registerLazy(NewNoteAttachmentCmd.class, () -> new NewNoteAttachmentCmd(context, provider));
providerRegistry.registerLazy(UpdateNoteAttachmentCmd.class, () -> new UpdateNoteAttachmentCmd(context, provider));
providerRegistry.registerLazy(DeleteNoteAttachmentCmd.class, () -> new DeleteNoteAttachmentCmd(provider));
providerRegistry.registerLazy(NewNoteAttachmentFileCmd.class, () -> new NewNoteAttachmentFileCmd(provider));
providerRegistry.registerLazy(DeleteNoteAttachmentFileCmd.class, () -> new DeleteNoteAttachmentFileCmd(provider));
}
Aggregations