Search in sources :

Example 1 with AppNotificationHandler

use of m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler 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 2 with AppNotificationHandler

use of m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler 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 3 with AppNotificationHandler

use of m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler in project a-medic-log by rh-id.

the class NotificationTakeMedicineReceiver method onReceive.

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

Example 4 with AppNotificationHandler

use of m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler in project a-medic-log by rh-id.

the class AppProviderModule method provides.

@Override
public void provides(Context context, ProviderRegistry providerRegistry, Provider provider) {
    providerRegistry.registerModule(new BaseProviderModule());
    providerRegistry.registerModule(new DatabaseProviderModule());
    providerRegistry.registerModule(new CommandProviderModule());
    providerRegistry.registerAsync(WorkManager.class, () -> WorkManager.getInstance(context));
    providerRegistry.registerAsync(AppSharedPreferences.class, () -> new AppSharedPreferences(context, provider));
    providerRegistry.registerAsync(ProfileChangeNotifier.class, ProfileChangeNotifier::new);
    providerRegistry.registerAsync(NoteChangeNotifier.class, NoteChangeNotifier::new);
    providerRegistry.registerAsync(NoteTagChangeNotifier.class, NoteTagChangeNotifier::new);
    providerRegistry.registerAsync(MedicineChangeNotifier.class, MedicineChangeNotifier::new);
    providerRegistry.registerAsync(MedicineReminderChangeNotifier.class, MedicineReminderChangeNotifier::new);
    providerRegistry.registerAsync(MedicineIntakeChangeNotifier.class, MedicineIntakeChangeNotifier::new);
    providerRegistry.registerAsync(NoteAttachmentFileChangeNotifier.class, NoteAttachmentFileChangeNotifier::new);
    providerRegistry.registerAsync(FileCleanUpTask.class, () -> new FileCleanUpTask(provider));
    providerRegistry.registerLazy(AppNotificationHandler.class, () -> new AppNotificationHandler(context, provider));
    providerRegistry.registerPool(StatefulViewProvider.class, () -> new StatefulViewProvider(provider));
    providerRegistry.registerAsync(MedicineReminderEventHandler.class, () -> new MedicineReminderEventHandler(provider));
    // it is safer to register navigator last in case it needs dependency from all above, provider can be passed here
    providerRegistry.register(NavExtDialogConfig.class, new NavExtDialogConfig(context));
    providerRegistry.register(INavigator.class, getNavigator(provider));
}
Also used : MedicineReminderEventHandler(m.co.rh.id.a_medic_log.app.provider.component.MedicineReminderEventHandler) NoteAttachmentFileChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.NoteAttachmentFileChangeNotifier) FileCleanUpTask(m.co.rh.id.a_medic_log.app.provider.component.FileCleanUpTask) NoteChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.NoteChangeNotifier) AppNotificationHandler(m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler) NoteTagChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.NoteTagChangeNotifier) MedicineChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.MedicineChangeNotifier) MedicineIntakeChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.MedicineIntakeChangeNotifier) DatabaseProviderModule(m.co.rh.id.a_medic_log.base.provider.DatabaseProviderModule) NavExtDialogConfig(m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig) AppSharedPreferences(m.co.rh.id.a_medic_log.app.provider.component.AppSharedPreferences) ProfileChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.ProfileChangeNotifier) MedicineReminderChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.MedicineReminderChangeNotifier) BaseProviderModule(m.co.rh.id.a_medic_log.base.provider.BaseProviderModule)

Example 5 with AppNotificationHandler

use of m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler in project a-medic-log by rh-id.

the class MedicineReminderNotificationWorker method doWork.

@NonNull
@Override
public Result doWork() {
    long medicineReminderId = getInputData().getLong(Keys.LONG_MEDICINE_REMINDER_ID, -1);
    MedicineReminder medicineReminder = mMedicineDao.get().findMedicineReminderById(medicineReminderId);
    if (medicineReminder != null) {
        Date today = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(today);
        int currentDay = calendar.get(Calendar.DAY_OF_WEEK);
        if (medicineReminder.reminderDays.contains(currentDay)) {
            AppNotificationHandler appNotificationHandler = mAppNotificationHandler.get();
            appNotificationHandler.cancelNotificationSync(medicineReminder);
            appNotificationHandler.postMedicineReminder(medicineReminder);
        }
        mMedicineReminderEventHandler.get().startMedicineReminderNotificationWork(Collections.singletonList(medicineReminder));
    }
    // previously this worker is enqueued as periodic work, so remove it
    Set<String> tags = getTags();
    String tag = tags.iterator().next();
    mWorkManager.get().cancelUniqueWork(tag);
    return Result.success();
}
Also used : Calendar(java.util.Calendar) AppNotificationHandler(m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler) MedicineReminder(m.co.rh.id.a_medic_log.base.entity.MedicineReminder) Date(java.util.Date) NonNull(androidx.annotation.NonNull)

Aggregations

AppNotificationHandler (m.co.rh.id.a_medic_log.app.provider.component.AppNotificationHandler)5 Provider (m.co.rh.id.aprovider.Provider)3 NonNull (androidx.annotation.NonNull)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 AppSharedPreferences (m.co.rh.id.a_medic_log.app.provider.component.AppSharedPreferences)1 FileCleanUpTask (m.co.rh.id.a_medic_log.app.provider.component.FileCleanUpTask)1 MedicineReminderEventHandler (m.co.rh.id.a_medic_log.app.provider.component.MedicineReminderEventHandler)1 MedicineChangeNotifier (m.co.rh.id.a_medic_log.app.provider.notifier.MedicineChangeNotifier)1 MedicineIntakeChangeNotifier (m.co.rh.id.a_medic_log.app.provider.notifier.MedicineIntakeChangeNotifier)1 MedicineReminderChangeNotifier (m.co.rh.id.a_medic_log.app.provider.notifier.MedicineReminderChangeNotifier)1 NoteAttachmentFileChangeNotifier (m.co.rh.id.a_medic_log.app.provider.notifier.NoteAttachmentFileChangeNotifier)1 NoteChangeNotifier (m.co.rh.id.a_medic_log.app.provider.notifier.NoteChangeNotifier)1 NoteTagChangeNotifier (m.co.rh.id.a_medic_log.app.provider.notifier.NoteTagChangeNotifier)1 ProfileChangeNotifier (m.co.rh.id.a_medic_log.app.provider.notifier.ProfileChangeNotifier)1 MedicineReminder (m.co.rh.id.a_medic_log.base.entity.MedicineReminder)1 BaseProviderModule (m.co.rh.id.a_medic_log.base.provider.BaseProviderModule)1 DatabaseProviderModule (m.co.rh.id.a_medic_log.base.provider.DatabaseProviderModule)1 NavExtDialogConfig (m.co.rh.id.anavigator.extension.dialog.ui.NavExtDialogConfig)1