Search in sources :

Example 1 with NavRoute

use of m.co.rh.id.anavigator.NavRoute in project a-medic-log by rh-id.

the class NoteDetailPage method onClick.

@Override
public void onClick(View view) {
    int id = view.getId();
    if (id == R.id.input_text_entry_date_time) {
        NavExtDialogConfig navExtDialogConfig = mSvProvider.get(NavExtDialogConfig.class);
        mNavigator.push(navExtDialogConfig.route_dateTimePickerDialog(), navExtDialogConfig.args_dateTimePickerDialog(true, mNoteState.getNoteEntryDateTime()), (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) {
                updateEntryDateTime(result);
            }
        });
    } else if (id == R.id.button_clear_entry_date_time) {
        updateEntryDateTime(null);
    } else if (id == R.id.button_share_medicine) {
        mRxDisposer.add("onClick_shareMedicine", mQueryNoteCmd.createShareMedicineText(mNoteState).observeOn(AndroidSchedulers.mainThread()).subscribe((s, throwable) -> {
            if (throwable != null) {
                Throwable cause = throwable.getCause();
                if (cause == null)
                    cause = throwable;
                mLogger.e(TAG, cause.getMessage(), cause);
            } else {
                Context context = mSvProvider.getContext();
                UiUtils.shareText(context, s, context.getString(R.string.share_text));
            }
        }));
    } else if (id == R.id.button_add_medicine) {
        MedicineDetailPage.Args args;
        if (isUpdate()) {
            args = MedicineDetailPage.Args.save(getNoteId());
        } else {
            args = MedicineDetailPage.Args.dontSave();
        }
        mNavigator.push(Routes.MEDICINE_DETAIL_PAGE, args, (navigator, navRoute, activity, currentView) -> {
            MedicineDetailPage.Result result = MedicineDetailPage.Result.of(navRoute);
            if (result != null) {
                addMedicineState(result.getMedicineState());
            }
        });
    } else if (id == R.id.container_medicine_text || id == R.id.button_expand_medicine) {
        mMedicineListShow.onNext(!mMedicineListShow.getValue());
    } else if (id == R.id.button_add_note_tag) {
        NoteTagDetailSVDialog.Args args;
        if (isUpdate()) {
            args = NoteTagDetailSVDialog.Args.save(getNoteId());
        } else {
            args = NoteTagDetailSVDialog.Args.dontSave();
        }
        mNavigator.push(Routes.NOTE_TAG_DETAIL_DIALOG, args, (navigator, navRoute, activity, currentView) -> {
            NoteTagDetailSVDialog.Result result = NoteTagDetailSVDialog.Result.of(navRoute);
            if (result != null) {
                addNoteTag(result.getNoteTag());
            }
        });
    } else if (id == R.id.container_note_tag_text || id == R.id.button_expand_note_tag) {
        mNoteTagShow.onNext(!mNoteTagShow.getValue());
    } else if (id == R.id.button_add_attachment) {
        NoteAttachmentDetailPage.Args args;
        if (isUpdate()) {
            args = NoteAttachmentDetailPage.Args.save(getNoteId());
        } else {
            args = NoteAttachmentDetailPage.Args.dontSave();
        }
        mNavigator.push(Routes.NOTE_ATTACHMENT_DETAIL_PAGE, args, (navigator, navRoute, activity, currentView) -> {
            NoteAttachmentDetailPage.Result result = NoteAttachmentDetailPage.Result.of(navRoute);
            if (result != null) {
                addNoteAttachment(result.getNoteAttachmentState());
            }
        });
    } else if (id == R.id.container_attachment_text || id == R.id.button_expand_attachment) {
        mAttachmentShow.onNext(!mAttachmentShow.getValue());
    }
}
Also used : DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Chip(com.google.android.material.chip.Chip) Date(java.util.Date) NoteState(m.co.rh.id.a_medic_log.base.state.NoteState) ILogger(m.co.rh.id.alogger.ILogger) AppBarSV(m.co.rh.id.a_medic_log.app.ui.component.AppBarSV) NoteAttachmentItemSV(m.co.rh.id.a_medic_log.app.ui.component.note.attachment.NoteAttachmentItemSV) MedicineRecyclerViewAdapter(m.co.rh.id.a_medic_log.app.ui.component.medicine.MedicineRecyclerViewAdapter) UiUtils(m.co.rh.id.a_medic_log.app.util.UiUtils) View(android.view.View) Button(android.widget.Button) RecyclerView(androidx.recyclerview.widget.RecyclerView) NoteAttachmentRecyclerViewAdapter(m.co.rh.id.a_medic_log.app.ui.component.note.attachment.NoteAttachmentRecyclerViewAdapter) SerialBehaviorSubject(m.co.rh.id.a_medic_log.base.rx.SerialBehaviorSubject) StatefulView(m.co.rh.id.anavigator.StatefulView) MedicineState(m.co.rh.id.a_medic_log.base.state.MedicineState) DeleteNoteTagCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteNoteTagCmd) NoteAttachmentFileChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.NoteAttachmentFileChangeNotifier) ViewGroup(android.view.ViewGroup) Serializable(java.io.Serializable) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) TextView(android.widget.TextView) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider) DeleteMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteMedicineCmd) Toolbar(androidx.appcompat.widget.Toolbar) NoteTag(m.co.rh.id.a_medic_log.base.entity.NoteTag) TextWatcher(android.text.TextWatcher) Context(android.content.Context) MedicineItemSV(m.co.rh.id.a_medic_log.app.ui.component.medicine.MedicineItemSV) NewNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.NewNoteCmd) NoteAttachmentState(m.co.rh.id.a_medic_log.base.state.NoteAttachmentState) MedicineReminderChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.MedicineReminderChangeNotifier) ChipGroup(com.google.android.material.chip.ChipGroup) QueryNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.QueryNoteCmd) Editable(android.text.Editable) TreeSet(java.util.TreeSet) 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) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) RequireNavigator(m.co.rh.id.anavigator.component.RequireNavigator) INavigator(m.co.rh.id.anavigator.component.INavigator) ExecutorService(java.util.concurrent.ExecutorService) Provider(m.co.rh.id.aprovider.Provider) RequireNavRoute(m.co.rh.id.anavigator.component.RequireNavRoute) Routes(m.co.rh.id.a_medic_log.app.constants.Routes) UpdateNoteCmd(m.co.rh.id.a_medic_log.app.provider.command.UpdateNoteCmd) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) RequireComponent(m.co.rh.id.anavigator.component.RequireComponent) DeleteNoteAttachmentCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteNoteAttachmentCmd) RxDisposer(m.co.rh.id.a_medic_log.app.rx.RxDisposer) R(m.co.rh.id.a_medic_log.R) Activity(android.app.Activity) EditText(android.widget.EditText) Context(android.content.Context) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) Date(java.util.Date) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider) Provider(m.co.rh.id.aprovider.Provider)

Aggregations

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 Button (android.widget.Button)1 EditText (android.widget.EditText)1 TextView (android.widget.TextView)1 Toolbar (androidx.appcompat.widget.Toolbar)1 DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 Chip (com.google.android.material.chip.Chip)1 ChipGroup (com.google.android.material.chip.ChipGroup)1 AndroidSchedulers (io.reactivex.rxjava3.android.schedulers.AndroidSchedulers)1 CompositeDisposable (io.reactivex.rxjava3.disposables.CompositeDisposable)1 Schedulers (io.reactivex.rxjava3.schedulers.Schedulers)1 Serializable (java.io.Serializable)1 Date (java.util.Date)1