use of m.co.rh.id.a_medic_log.app.ui.component.adapter.SuggestionAdapter in project a-medic-log by rh-id.
the class MedicineIntakeDetailPage method createView.
@Override
protected View createView(Activity activity, ViewGroup container) {
View rootLayout = activity.getLayoutInflater().inflate(R.layout.page_medicine_intake_detail, container, false);
ViewGroup containerAppBar = rootLayout.findViewById(R.id.container_app_bar);
containerAppBar.addView(mAppBarSv.buildView(activity, container));
EditText inputTakenDateTime = rootLayout.findViewById(R.id.input_text_taken_date_time);
inputTakenDateTime.setOnClickListener(this);
inputTakenDateTime.addTextChangedListener(mTakenDateTimeTextWatcher);
mSuggestionAdapter = new SuggestionAdapter(activity, android.R.layout.select_dialog_item, mSuggestionQuery);
AutoCompleteTextView inputDescription = rootLayout.findViewById(R.id.input_text_description);
inputDescription.addTextChangedListener(mDescriptionTextWatcher);
inputDescription.setThreshold(1);
inputDescription.setAdapter(mSuggestionAdapter);
mRxDisposer.add("createView_onMedicineIntakeUpdated", mMedicineIntakeSubject.getSubject().observeOn(AndroidSchedulers.mainThread()).subscribe(medicineReminder -> {
if (medicineReminder.takenDateTime != null) {
inputTakenDateTime.setText(mDateFormat.format(medicineReminder.takenDateTime));
} else {
inputTakenDateTime.setText(null);
}
inputDescription.setText(medicineReminder.description);
}));
mRxDisposer.add("createView_onTakenDateTimeValidated", mNewMedicineIntakeCmd.getTakenDateTimeValid().observeOn(AndroidSchedulers.mainThread()).subscribe(s -> {
if (s != null && !s.isEmpty()) {
inputDescription.setError(s);
} else {
inputDescription.setError(null);
}
}));
mRxDisposer.add("createView_onInputDescriptionValidated", mNewMedicineIntakeCmd.getDescriptionValid().observeOn(AndroidSchedulers.mainThread()).subscribe(s -> {
if (s != null && !s.isEmpty()) {
inputDescription.setError(s);
} else {
inputDescription.setError(null);
}
}));
return rootLayout;
}
use of m.co.rh.id.a_medic_log.app.ui.component.adapter.SuggestionAdapter in project a-medic-log by rh-id.
the class MedicineDetailPage method createView.
@Override
protected View createView(Activity activity, ViewGroup container) {
View rootLayout = activity.getLayoutInflater().inflate(R.layout.page_medicine_detail, container, false);
ViewGroup containerAppBar = rootLayout.findViewById(R.id.container_app_bar);
containerAppBar.addView(mAppBarSv.buildView(activity, container));
mSuggestionAdapter = new SuggestionAdapter(activity, android.R.layout.select_dialog_item, mSuggestionQuery);
AutoCompleteTextView inputName = rootLayout.findViewById(R.id.input_text_name);
inputName.addTextChangedListener(mNameTextWatcher);
inputName.setThreshold(1);
inputName.setAdapter(mSuggestionAdapter);
EditText inputDescription = rootLayout.findViewById(R.id.input_text_description);
inputDescription.addTextChangedListener(mDescriptionTextWatcher);
Button addMedicineReminderButton = rootLayout.findViewById(R.id.button_add_medicine_reminder);
addMedicineReminderButton.setOnClickListener(this);
RecyclerView medicineReminderRecyclerView = rootLayout.findViewById(R.id.recyclerView_medicine_reminder);
medicineReminderRecyclerView.addItemDecoration(new DividerItemDecoration(activity, DividerItemDecoration.VERTICAL));
medicineReminderRecyclerView.setAdapter(mMedicineReminderRecyclerViewAdapter);
mRxDisposer.add("createView_onMedicineChanged", mMedicineState.getMedicineFlow().observeOn(AndroidSchedulers.mainThread()).subscribe(medicine -> {
inputName.setText(medicine.name);
inputDescription.setText(medicine.description);
}));
mRxDisposer.add("createView_onInputNameValidated", mNewMedicineCmd.getNameValid().observeOn(AndroidSchedulers.mainThread()).subscribe(s -> {
if (s != null && !s.isEmpty()) {
inputName.setError(s);
} else {
inputName.setError(null);
}
}));
mRxDisposer.add("createView_onMedicineReminderListChanged", mMedicineState.getMedicineReminderListFlow().observeOn(AndroidSchedulers.mainThread()).subscribe(medicineReminders -> mMedicineReminderRecyclerViewAdapter.notifyItemRefreshed()));
mRxDisposer.add("createView_onMedicineReminderAdded", mMedicineReminderChangeNotifier.getAddedMedicineReminder().observeOn(Schedulers.from(mExecutorService)).subscribe(medicineReminder -> {
if (isUpdate() && shouldSave()) {
mMedicineState.addMedicineReminder(medicineReminder);
}
}));
mRxDisposer.add("createView_onMedicineReminderUpdated", mMedicineReminderChangeNotifier.getUpdatedMedicineReminder().observeOn(Schedulers.from(mExecutorService)).subscribe(updateMedicineReminderEvent -> {
if (isUpdate() && shouldSave()) {
mMedicineState.updateMedicineReminder(updateMedicineReminderEvent.getAfter());
}
}));
mRxDisposer.add("createView_onMedicineReminderDeleted", mMedicineReminderChangeNotifier.getDeletedMedicineReminder().observeOn(Schedulers.from(mExecutorService)).subscribe(medicineReminder -> {
if (isUpdate() && shouldSave()) {
mMedicineState.deleteMedicineReminder(medicineReminder);
}
}));
return rootLayout;
}
use of m.co.rh.id.a_medic_log.app.ui.component.adapter.SuggestionAdapter in project a-medic-log by rh-id.
the class NoteTagDetailSVDialog method createView.
@Override
protected View createView(Activity activity, ViewGroup container) {
View rootLayout = activity.getLayoutInflater().inflate(R.layout.dialog_note_tag_detail, container, false);
AutoCompleteTextView tagTextInput = rootLayout.findViewById(R.id.input_text_tag);
tagTextInput.addTextChangedListener(mTagTextWatcher);
tagTextInput.setThreshold(1);
tagTextInput.setAdapter(new SuggestionAdapter(activity, android.R.layout.select_dialog_item, mSuggestionQuery));
Button okButton = rootLayout.findViewById(R.id.button_ok);
okButton.setOnClickListener(this);
Button cancelButton = rootLayout.findViewById(R.id.button_cancel);
cancelButton.setOnClickListener(this);
mRxDisposer.add("createView_onTagValid", mNewNoteTagCmd.getTagValid().observeOn(AndroidSchedulers.mainThread()).subscribe(s -> {
if (!s.isEmpty()) {
tagTextInput.setError(s);
} else {
tagTextInput.setError(null);
}
}));
return rootLayout;
}
Aggregations