use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder in project a-medic-log by rh-id.
the class MedicineReminderItemSV method onClick.
@Override
public void onClick(View view) {
int id = view.getId();
MedicineReminder medicineReminder = mMedicineReminderSubject.getValue();
if (id == R.id.root_layout) {
if (mOnEditClick != null) {
mOnEditClick.onEditClick(medicineReminder);
}
} else if (id == R.id.button_enabled) {
medicineReminder.reminderEnabled = !medicineReminder.reminderEnabled;
if (mOnEnableSwitchClick != null) {
mOnEnableSwitchClick.onEnableSwitchClick(medicineReminder);
}
} else if (id == R.id.button_delete) {
if (mOnDeleteClick != null) {
mOnDeleteClick.onDeleteClick(medicineReminder);
}
}
}
use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder in project a-medic-log by rh-id.
the class MedicineReminderRecyclerViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ItemViewHolder) {
ArrayList<MedicineReminder> itemArrayList = mMedicineState.getMedicineReminderList();
MedicineReminder item = itemArrayList.get(position);
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
itemViewHolder.setItem(item);
}
}
use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder in project a-medic-log by rh-id.
the class AppNotificationHandler method takeMedicine.
public void takeMedicine(Intent intent) {
Serializable serializable = intent.getSerializableExtra(KEY_INT_REQUEST_ID);
if (serializable instanceof Integer) {
mExecutorService.get().execute(() -> {
mLock.lock();
try {
AndroidNotification androidNotification = mAndroidNotificationRepo.get().findByRequestId((int) serializable);
if (androidNotification != null && androidNotification.groupKey.equals(GROUP_KEY_MEDICINE_REMINDER)) {
MedicineReminder medicineReminder = mMedicineDao.get().findMedicineReminderById(androidNotification.refId);
MedicineIntake medicineIntake = new MedicineIntake();
medicineIntake.medicineId = medicineReminder.medicineId;
medicineIntake.description = medicineReminder.message;
mNewMedicineIntakeCmd.get().execute(medicineIntake);
cancelNotificationSync(medicineReminder);
}
} catch (Exception e) {
mLogger.get().d(TAG, "Failed to take medicine: " + e.getMessage(), e);
} finally {
mLock.unlock();
}
});
}
}
use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder in project a-medic-log by rh-id.
the class MedicineReminderDetailPage method onMenuItemClick.
@Override
public boolean onMenuItemClick(MenuItem item) {
int id = item.getItemId();
if (id == R.id.menu_save) {
MedicineReminder medicineReminder = mMedicineReminderSubject.getValue();
if (shouldSave()) {
boolean isUpdate = isUpdate();
Context context = mSvProvider.getContext();
if (mNewMedicineReminderCmd.valid(medicineReminder)) {
mRxDisposer.add("onMenuItemClick_saveNewMedicineReminder", mNewMedicineReminderCmd.execute(medicineReminder).observeOn(AndroidSchedulers.mainThread()).subscribe((medicineState, throwable) -> {
String errorMessage;
String successMessage;
if (isUpdate) {
errorMessage = context.getString(R.string.error_failed_to_update_medicine_reminder);
successMessage = context.getString(R.string.success_updating_medicine_reminder);
} else {
errorMessage = context.getString(R.string.error_failed_to_add_medicine_reminder);
successMessage = context.getString(R.string.success_adding_medicine_reminder);
}
if (throwable != null) {
mSvProvider.get(ILogger.class).e(TAG, errorMessage, throwable);
mNavigator.pop();
} else {
mSvProvider.get(ILogger.class).i(TAG, successMessage);
mNavigator.pop(Result.with(medicineReminder));
}
}));
} else {
String error = mNewMedicineReminderCmd.getValidationError();
mSvProvider.get(ILogger.class).i(TAG, error);
}
} else {
if (mNewMedicineReminderCmd.valid(medicineReminder)) {
mNavigator.pop(Result.with(medicineReminder));
} else {
String error = mNewMedicineReminderCmd.getValidationError();
mSvProvider.get(ILogger.class).i(TAG, error);
}
}
return true;
}
return false;
}
use of m.co.rh.id.a_medic_log.base.entity.MedicineReminder in project a-medic-log by rh-id.
the class MedicineReminderDetailPage method getMedicineReminder.
private MedicineReminder getMedicineReminder() {
MedicineReminder medicineReminder;
Args args = Args.of(mNavRoute);
if (args != null && args.mMedicineReminder != null) {
medicineReminder = args.mMedicineReminder;
} else {
medicineReminder = new MedicineReminder();
medicineReminder.medicineId = getMedicineId();
}
return medicineReminder;
}
Aggregations