Search in sources :

Example 6 with Provider

use of m.co.rh.id.aprovider.Provider 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 7 with Provider

use of m.co.rh.id.aprovider.Provider in project a-medic-log by rh-id.

the class NotificationDeleteReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    Provider provider = BaseApplication.of(context).getProvider();
    AppNotificationHandler appNotificationHandler = provider.get(AppNotificationHandler.class);
    appNotificationHandler.removeNotification(intent);
}
Also used : AppNotificationHandler(m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler) Provider(m.co.rh.id.aprovider.Provider)

Example 8 with Provider

use of m.co.rh.id.aprovider.Provider in project a-medic-log by rh-id.

the class NotificationDisableMedicineReminderReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    Provider provider = BaseApplication.of(context).getProvider();
    AppNotificationHandler appNotificationHandler = provider.get(AppNotificationHandler.class);
    appNotificationHandler.disableMedicineReminder(intent);
}
Also used : AppNotificationHandler(m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler) Provider(m.co.rh.id.aprovider.Provider)

Example 9 with Provider

use of m.co.rh.id.aprovider.Provider 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)

Example 10 with Provider

use of m.co.rh.id.aprovider.Provider in project a-medic-log by rh-id.

the class ProfileItemSV method onClick.

@Override
public void onClick(View view) {
    int id = view.getId();
    if (id == R.id.root_layout) {
        if (mListMode != null) {
            mIsSelected = true;
            if (mSelectedUiButton != null) {
                mSelectedUiButton.setChecked(mIsSelected);
            }
            if (mOnItemSelectListener != null) {
                mOnItemSelectListener.onItemSelect(mProfile, mIsSelected);
            }
        } else {
            mNavigator.push(Routes.NOTES_PAGE, NoteListPage.Args.withProfileId(mProfile.id));
        }
    } else if (id == R.id.button_edit) {
        mNavigator.push(Routes.PROFILE_DETAIL_PAGE, ProfileDetailPage.Args.forUpdate(mProfile.clone()), (navigator, navRoute, activity, currentView) -> {
            ProfileDetailPage.Result result = ProfileDetailPage.Result.of(navRoute.getRouteResult());
            if (result != null) {
                setProfile(result.getProfile());
            }
        });
    } 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_profile, mProfile.name);
        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(DeleteProfileCmd.class).execute(mProfile).observeOn(AndroidSchedulers.mainThread()).subscribe((card, throwable) -> {
                    Context deleteContext = provider.getContext();
                    if (throwable != null) {
                        provider.get(ILogger.class).e(TAG, deleteContext.getString(R.string.error_deleting_profile), throwable);
                    } else {
                        provider.get(ILogger.class).i(TAG, deleteContext.getString(R.string.success_deleting_profile, card.name));
                    }
                    compositeDisposable.dispose();
                }));
            }
        });
    }
}
Also used : Context(android.content.Context) RadioButton(android.widget.RadioButton) ILogger(m.co.rh.id.alogger.ILogger) BehaviorSubject(io.reactivex.rxjava3.subjects.BehaviorSubject) NavInject(m.co.rh.id.anavigator.annotation.NavInject) NoteListPage(m.co.rh.id.a_medic_log.app.ui.page.NoteListPage) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) View(android.view.View) Button(android.widget.Button) INavigator(m.co.rh.id.anavigator.component.INavigator) DeleteProfileCmd(m.co.rh.id.a_medic_log.app.provider.command.DeleteProfileCmd) StatefulView(m.co.rh.id.anavigator.StatefulView) Provider(m.co.rh.id.aprovider.Provider) CompoundButton(android.widget.CompoundButton) ProfileDetailPage(m.co.rh.id.a_medic_log.app.ui.page.ProfileDetailPage) 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) 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) RequireComponent(m.co.rh.id.anavigator.component.RequireComponent) RxDisposer(m.co.rh.id.a_medic_log.app.rx.RxDisposer) Profile(m.co.rh.id.a_medic_log.base.entity.Profile) R(m.co.rh.id.a_medic_log.R) Activity(android.app.Activity) Context(android.content.Context) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) Provider(m.co.rh.id.aprovider.Provider) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider)

Aggregations

Provider (m.co.rh.id.aprovider.Provider)14 StatefulViewProvider (m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider)10 NavExtDialogConfig (m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig)10 Context (android.content.Context)8 Activity (android.app.Activity)5 View (android.view.View)5 ViewGroup (android.view.ViewGroup)5 TextView (android.widget.TextView)5 AndroidSchedulers (io.reactivex.rxjava3.android.schedulers.AndroidSchedulers)5 R (m.co.rh.id.a_medic_log.R)5 RxDisposer (m.co.rh.id.a_medic_log.app.rx.RxDisposer)5 ILogger (m.co.rh.id.alogger.ILogger)5 StatefulView (m.co.rh.id.anavigator.StatefulView)5 NavInject (m.co.rh.id.anavigator.annotation.NavInject)5 Button (android.widget.Button)4 CompositeDisposable (io.reactivex.rxjava3.disposables.CompositeDisposable)4 Date (java.util.Date)4 Chip (com.google.android.material.chip.Chip)3 ChipGroup (com.google.android.material.chip.ChipGroup)3 Schedulers (io.reactivex.rxjava3.schedulers.Schedulers)3