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);
}
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);
}
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);
}
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));
}
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();
}
Aggregations