Search in sources :

Example 1 with NavExtDialogConfig

use of m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig in project a-medic-log by rh-id.

the class NoteDetailPage method noteAttachment_onDeleteClick.

@Override
public void noteAttachment_onDeleteClick(NoteAttachmentState noteAttachmentState) {
    if (isUpdate()) {
        Context context = mSvProvider.getContext();
        String title = context.getString(R.string.title_confirm);
        String content = context.getString(R.string.confirm_delete_attachment);
        NavExtDialogConfig navExtDialogConfig = mSvProvider.get(NavExtDialogConfig.class);
        mNavigator.push(navExtDialogConfig.route_confirmDialog(), navExtDialogConfig.args_confirmDialog(title, content), (navigator, navRoute, activity, currentView) -> {
            Provider provider = (Provider) navigator.getNavConfiguration().getRequiredComponent();
            Boolean result = provider.get(NavExtDialogConfig.class).result_confirmDialog(navRoute);
            if (result != null && result) {
                deleteNoteAttachment(noteAttachmentState);
            }
        });
    } else {
        mNoteAttachmentRecyclerViewAdapter.notifyItemDeleted(noteAttachmentState);
    }
}
Also used : Context(android.content.Context) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider) Provider(m.co.rh.id.aprovider.Provider)

Example 2 with NavExtDialogConfig

use of m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig in project a-medic-log by rh-id.

the class NoteDetailPage method medicineItem_onDeleteClick.

@Override
public void medicineItem_onDeleteClick(MedicineState medicineState) {
    if (isUpdate()) {
        Context context = mSvProvider.getContext();
        String title = context.getString(R.string.title_confirm);
        String content = context.getString(R.string.confirm_delete_medicine, medicineState.getMedicineName());
        NavExtDialogConfig navExtDialogConfig = mSvProvider.get(NavExtDialogConfig.class);
        mNavigator.push(navExtDialogConfig.route_confirmDialog(), navExtDialogConfig.args_confirmDialog(title, content), (navigator, navRoute, activity, currentView) -> {
            Provider provider = (Provider) navigator.getNavConfiguration().getRequiredComponent();
            Boolean result = provider.get(NavExtDialogConfig.class).result_confirmDialog(navRoute);
            if (result != null && result) {
                confirmDeleteMedicine(medicineState);
            }
        });
    } else {
        mMedicineRecyclerViewAdapter.notifyItemDeleted(medicineState);
    }
}
Also used : Context(android.content.Context) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider) Provider(m.co.rh.id.aprovider.Provider)

Example 3 with NavExtDialogConfig

use of m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig in project a-medic-log by rh-id.

the class MedicineIntakeDetailPage method onClick.

@Override
public void onClick(View view) {
    int id = view.getId();
    if (id == R.id.input_text_taken_date_time) {
        NavExtDialogConfig navExtDialogConfig = mSvProvider.get(NavExtDialogConfig.class);
        mNavigator.push(navExtDialogConfig.route_dateTimePickerDialog(), navExtDialogConfig.args_dateTimePickerDialog(true, mMedicineIntakeSubject.getValue().takenDateTime), (navigator, navRoute, activity, currentView) -> {
            Provider provider = (Provider) navigator.getNavConfiguration().getRequiredComponent();
            NavExtDialogConfig navExtDialogConfig1 = provider.get(NavExtDialogConfig.class);
            Date result = navExtDialogConfig1.result_dateTimePickerDialog(navRoute);
            if (result != null) {
                updateTakenDateTime(result);
            }
        });
    }
}
Also used : NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) Date(java.util.Date) Provider(m.co.rh.id.aprovider.Provider) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider)

Example 4 with NavExtDialogConfig

use of m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig in project a-medic-log by rh-id.

the class MedicineIntakeListSV method onDeleteClick.

@Override
public void onDeleteClick(MedicineIntake medicineIntake) {
    Context context = mSvProvider.getContext();
    String title = context.getString(R.string.title_confirm);
    String content = context.getString(R.string.confirm_delete_medicine_intake, medicineIntake.description);
    NavExtDialogConfig navExtDialogConfig = mSvProvider.get(NavExtDialogConfig.class);
    mNavigator.push(navExtDialogConfig.route_confirmDialog(), navExtDialogConfig.args_confirmDialog(title, content), (navigator, navRoute, activity, currentView) -> {
        Provider provider = (Provider) navigator.getNavConfiguration().getRequiredComponent();
        Boolean result = provider.get(NavExtDialogConfig.class).result_confirmDialog(navRoute);
        if (result != null && result) {
            confirmDeleteMedicineIntake(medicineIntake);
        }
    });
}
Also used : Context(android.content.Context) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) Provider(m.co.rh.id.aprovider.Provider) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider)

Example 5 with NavExtDialogConfig

use of m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig in project a-medic-log by rh-id.

the class NoteItemSV method onClick.

@Override
public void onClick(View view) {
    int id = view.getId();
    if (id == R.id.button_edit) {
        mNavigator.push(Routes.NOTE_DETAIL_PAGE, NoteDetailPage.Args.forUpdate(mNoteSubject.getValue().id));
    } else if (id == R.id.button_delete) {
        Context context = mSvProvider.getContext();
        String title = context.getString(R.string.title_confirm);
        String content = context.getString(R.string.confirm_delete_note);
        NavExtDialogConfig navExtDialogConfig = mSvProvider.get(NavExtDialogConfig.class);
        mNavigator.push(navExtDialogConfig.route_confirmDialog(), navExtDialogConfig.args_confirmDialog(title, content), (navigator, navRoute, activity, currentView) -> {
            Provider provider = (Provider) navigator.getNavConfiguration().getRequiredComponent();
            Boolean result = provider.get(NavExtDialogConfig.class).result_confirmDialog(navRoute);
            if (result != null && result) {
                CompositeDisposable compositeDisposable = new CompositeDisposable();
                compositeDisposable.add(provider.get(DeleteNoteCmd.class).execute(mNoteSubject.getValue()).observeOn(AndroidSchedulers.mainThread()).subscribe((note, throwable) -> {
                    Context deleteContext = provider.getContext();
                    if (throwable != null) {
                        provider.get(ILogger.class).e(TAG, deleteContext.getString(R.string.error_deleting_note), throwable);
                    } else {
                        provider.get(ILogger.class).i(TAG, deleteContext.getString(R.string.success_deleting_note));
                    }
                    compositeDisposable.dispose();
                }));
            }
        });
    }
}
Also used : Context(android.content.Context) Context(android.content.Context) Chip(com.google.android.material.chip.Chip) ILogger(m.co.rh.id.alogger.ILogger) ChipGroup(com.google.android.material.chip.ChipGroup) SimpleDateFormat(java.text.SimpleDateFormat) NoteTagChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.NoteTagChangeNotifier) QueryNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.QueryNoteCmd) TreeSet(java.util.TreeSet) NavInject(m.co.rh.id.anavigator.annotation.NavInject) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) Note(m.co.rh.id.a_medic_log.base.entity.Note) View(android.view.View) Button(android.widget.Button) INavigator(m.co.rh.id.anavigator.component.INavigator) DateFormat(java.text.DateFormat) SerialBehaviorSubject(m.co.rh.id.a_medic_log.base.rx.SerialBehaviorSubject) StatefulView(m.co.rh.id.anavigator.StatefulView) Provider(m.co.rh.id.aprovider.Provider) Routes(m.co.rh.id.a_medic_log.app.constants.Routes) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) ViewGroup(android.view.ViewGroup) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) TextView(android.widget.TextView) 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) NoteDetailPage(m.co.rh.id.a_medic_log.app.ui.page.NoteDetailPage) R(m.co.rh.id.a_medic_log.R) NoteTag(m.co.rh.id.a_medic_log.base.entity.NoteTag) Activity(android.app.Activity) DeleteNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteNoteCmd) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) ILogger(m.co.rh.id.alogger.ILogger) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) DeleteNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteNoteCmd) Provider(m.co.rh.id.aprovider.Provider) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider)

Aggregations

NavExtDialogConfig (m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig)10 StatefulViewProvider (m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider)9 Provider (m.co.rh.id.aprovider.Provider)9 Context (android.content.Context)7 Activity (android.app.Activity)3 View (android.view.View)3 ViewGroup (android.view.ViewGroup)3 Button (android.widget.Button)3 TextView (android.widget.TextView)3 AndroidSchedulers (io.reactivex.rxjava3.android.schedulers.AndroidSchedulers)3 CompositeDisposable (io.reactivex.rxjava3.disposables.CompositeDisposable)3 Date (java.util.Date)3 R (m.co.rh.id.a_medic_log.R)3 Routes (m.co.rh.id.a_medic_log.app.constants.Routes)3 RxDisposer (m.co.rh.id.a_medic_log.app.rx.RxDisposer)3 ILogger (m.co.rh.id.alogger.ILogger)3 StatefulView (m.co.rh.id.anavigator.StatefulView)3 NavInject (m.co.rh.id.anavigator.annotation.NavInject)3 INavigator (m.co.rh.id.anavigator.component.INavigator)3 RequireComponent (m.co.rh.id.anavigator.component.RequireComponent)3