Search in sources :

Example 1 with UpdateMedicineReminderCmd

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);
    }
}
Also used : Context(android.content.Context) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Context(android.content.Context) NewMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.NewMedicineCmd) MedicineReminderChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.MedicineReminderChangeNotifier) ILogger(m.co.rh.id.alogger.ILogger) AppBarSV(m.co.rh.id.a_medic_log.app.ui.component.AppBarSV) Function(java.util.function.Function) Editable(android.text.Editable) MedicineReminder(m.co.rh.id.a_medic_log.base.entity.MedicineReminder) MenuItem(android.view.MenuItem) Schedulers(io.reactivex.rxjava3.schedulers.Schedulers) NavInject(m.co.rh.id.anavigator.annotation.NavInject) NavRoute(m.co.rh.id.anavigator.NavRoute) SuggestionAdapter(m.co.rh.id.a_medic_log.app.ui.component.adapter.SuggestionAdapter) View(android.view.View) Button(android.widget.Button) RequireNavigator(m.co.rh.id.anavigator.component.RequireNavigator) UpdateMedicineReminderCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineReminderCmd) RecyclerView(androidx.recyclerview.widget.RecyclerView) INavigator(m.co.rh.id.anavigator.component.INavigator) QueryMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.QueryMedicineCmd) ExecutorService(java.util.concurrent.ExecutorService) DeleteMedicineReminderCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteMedicineReminderCmd) MedicineReminderRecyclerViewAdapter(m.co.rh.id.a_medic_log.app.ui.component.medicine.reminder.MedicineReminderRecyclerViewAdapter) UpdateMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineCmd) StatefulView(m.co.rh.id.anavigator.StatefulView) Provider(m.co.rh.id.aprovider.Provider) MedicineState(m.co.rh.id.a_medic_log.base.state.MedicineState) Collection(java.util.Collection) RequireNavRoute(m.co.rh.id.anavigator.component.RequireNavRoute) Routes(m.co.rh.id.a_medic_log.app.constants.Routes) MedicineReminderItemSV(m.co.rh.id.a_medic_log.app.ui.component.medicine.reminder.MedicineReminderItemSV) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) ViewGroup(android.view.ViewGroup) AutoCompleteTextView(android.widget.AutoCompleteTextView) Serializable(java.io.Serializable) ArrayAdapter(android.widget.ArrayAdapter) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider) RequireComponent(m.co.rh.id.anavigator.component.RequireComponent) RxDisposer(m.co.rh.id.a_medic_log.app.rx.RxDisposer) Toolbar(androidx.appcompat.widget.Toolbar) R(m.co.rh.id.a_medic_log.R) Activity(android.app.Activity) EditText(android.widget.EditText) TextWatcher(android.text.TextWatcher) UpdateMedicineReminderCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineReminderCmd) ILogger(m.co.rh.id.alogger.ILogger)

Example 2 with UpdateMedicineReminderCmd

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));
}
Also used : DeleteNoteAttachmentFileCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteNoteAttachmentFileCmd) NewNoteAttachmentFileCmd(m.co.rh.id.a_medic_log.app.provider.command.NewNoteAttachmentFileCmd) UpdateMedicineReminderCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineReminderCmd) DeleteMedicineReminderCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteMedicineReminderCmd) DeleteNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteNoteCmd) UpdateMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineCmd) DeleteMedicineIntakeCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteMedicineIntakeCmd) QueryMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.QueryMedicineCmd) NewMedicineIntakeCmd(m.co.rh.id.a_medic_log.app.provider.command.NewMedicineIntakeCmd) UpdateNoteAttachmentCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateNoteAttachmentCmd) NewProfileCmd(m.co.rh.id.a_medic_log.app.provider.command.NewProfileCmd) DeleteProfileCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteProfileCmd) PagedNoteItemsCmd(m.co.rh.id.a_medic_log.app.provider.command.PagedNoteItemsCmd) UpdateProfileCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateProfileCmd) QueryNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.QueryNoteCmd) PagedMedicineIntakeItemsCmd(m.co.rh.id.a_medic_log.app.provider.command.PagedMedicineIntakeItemsCmd) UpdateNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateNoteCmd) NewNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.NewNoteCmd) NewMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.NewMedicineCmd) DeleteNoteTagCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteNoteTagCmd) DeleteMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteMedicineCmd) NewNoteTagCmd(m.co.rh.id.a_medic_log.app.provider.command.NewNoteTagCmd) PagedProfileItemsCmd(m.co.rh.id.a_medic_log.app.provider.command.PagedProfileItemsCmd) DeleteNoteAttachmentCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteNoteAttachmentCmd) NewNoteAttachmentCmd(m.co.rh.id.a_medic_log.app.provider.command.NewNoteAttachmentCmd) UpdateMedicineIntakeCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineIntakeCmd) NewMedicineReminderCmd(m.co.rh.id.a_medic_log.app.provider.command.NewMedicineReminderCmd)

Aggregations

DeleteMedicineReminderCmd (m.co.rh.id.a_medic_log.app.provider.command.DeleteMedicineReminderCmd)2 NewMedicineCmd (m.co.rh.id.a_medic_log.app.provider.command.NewMedicineCmd)2 QueryMedicineCmd (m.co.rh.id.a_medic_log.app.provider.command.QueryMedicineCmd)2 UpdateMedicineCmd (m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineCmd)2 UpdateMedicineReminderCmd (m.co.rh.id.a_medic_log.app.provider.command.UpdateMedicineReminderCmd)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ArrayAdapter (android.widget.ArrayAdapter)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 Toolbar (androidx.appcompat.widget.Toolbar)1 DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 AndroidSchedulers (io.reactivex.rxjava3.android.schedulers.AndroidSchedulers)1