use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class CaseEditHospitalizationFragment method onLayoutBinding.
@Override
public void onLayoutBinding(final FragmentCaseEditHospitalizationLayoutBinding contentBinding) {
setUpControlListeners();
CaseValidator.initializeHospitalizationValidation(contentBinding, caze);
List<Item> hospitalizationReasons = DataUtils.getEnumItems(HospitalizationReasonType.class, true);
contentBinding.setData(record);
contentBinding.setCaze(caze);
contentBinding.setPreviousHospitalizationList(getPreviousHospitalizations());
contentBinding.setPrevHosItemClickCallback(onPrevHosItemClickListener);
getContentBinding().setPreviousHospitalizationBindCallback(this::setFieldVisibilitiesAndAccesses);
contentBinding.caseHospitalizationHospitalizationReason.initializeSpinner(hospitalizationReasons);
contentBinding.caseHospitalizationHospitalizedPreviously.addValueChangedListener(field -> {
YesNoUnknown value = (YesNoUnknown) field.getValue();
contentBinding.prevHospitalizationsLayout.setVisibility(value == YesNoUnknown.YES ? View.VISIBLE : View.GONE);
if (value != YesNoUnknown.YES) {
clearPreviousHospitalizations();
}
verifyPrevHospitalizationStatus();
});
}
use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class CaseListActivity method addFiltersToPageMenu.
@Override
public void addFiltersToPageMenu() {
View caseListFilterView = getLayoutInflater().inflate(R.layout.filter_case_list_layout, null);
filterBinding = DataBindingUtil.bind(caseListFilterView);
List<Item> diseases = DataUtils.toItems(DiseaseConfigurationCache.getInstance().getAllDiseases(true, true, true));
filterBinding.diseaseFilter.initializeSpinner(diseases);
List<Item> classifications = DataUtils.getEnumItems(CaseClassification.class);
filterBinding.classificationFilter.initializeSpinner(classifications);
List<Item> outcomes = DataUtils.getEnumItems(CaseOutcome.class);
filterBinding.outcomeFilter.initializeSpinner(outcomes);
if (UserRole.isPortHealthUser(ConfigProvider.getUser().getUserRoles())) {
filterBinding.originFilter.setVisibility(GONE);
} else {
List<Item> caseOrigins = DataUtils.getEnumItems(CaseOrigin.class);
filterBinding.originFilter.initializeSpinner(caseOrigins);
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
List<Item> epiWeeks = DataUtils.toItems(DateHelper.createEpiWeekList(calendar.get(Calendar.YEAR), calendar.get(Calendar.WEEK_OF_YEAR)));
filterBinding.epiWeekFromFilter.initializeSpinner(epiWeeks);
filterBinding.epiWeekToFilter.initializeSpinner(epiWeeks);
pageMenu.addFilter(caseListFilterView);
filterBinding.applyFilters.setOnClickListener(e -> {
showPreloader();
pageMenu.hideAll();
model.notifyCriteriaUpdated();
});
filterBinding.resetFilters.setOnClickListener(e -> {
showPreloader();
pageMenu.hideAll();
model.getCaseCriteria().setTextFilter(null);
model.getCaseCriteria().setDisease(null);
model.getCaseCriteria().setCaseClassification(null);
model.getCaseCriteria().setOutcome(null);
model.getCaseCriteria().setEpiWeekFrom(null);
model.getCaseCriteria().setEpiWeekTo(null);
model.getCaseCriteria().setCaseOrigin(null);
filterBinding.invalidateAll();
filterBinding.executePendingBindings();
model.notifyCriteriaUpdated();
});
}
use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class LocationDialog method initializeContentView.
@Override
protected void initializeContentView(ViewDataBinding rootBinding, ViewDataBinding buttonPanelBinding) {
List<Item> initialContinents = InfrastructureDaoHelper.loadContinents();
List<Item> initialSubcontinents = InfrastructureDaoHelper.loadSubcontinents();
List<Item> initialCountries = InfrastructureDaoHelper.loadCountries();
List<Item> initialRegions = InfrastructureDaoHelper.loadRegionsByServerCountry();
List<Item> initialDistricts = InfrastructureDaoHelper.loadDistricts(data.getRegion());
List<Item> initialCommunities = InfrastructureDaoHelper.loadCommunities(data.getDistrict());
List<Item> initialFacilities = InfrastructureDaoHelper.loadFacilities(data.getDistrict(), data.getCommunity(), data.getFacilityType());
List<Item> facilityTypeGroupList = DataUtils.toItems(Arrays.asList(FacilityTypeGroup.values()), true);
List<Item> facilityTypeList = data.getFacilityType() != null ? DataUtils.toItems(FacilityType.getTypes(data.getFacilityType().getFacilityTypeGroup())) : null;
InfrastructureDaoHelper.initializeHealthFacilityDetailsFieldVisibility(contentBinding.locationFacility, contentBinding.locationFacilityDetails);
if (data.getCountry() == null) {
String serverCountryName = ConfigProvider.getServerCountryName();
for (Item countryItem : initialCountries) {
Country country = (Country) countryItem.getValue();
if (country != null && serverCountryName != null && serverCountryName.equalsIgnoreCase(country.getName())) {
data.setCountry(country);
break;
}
}
}
InfrastructureFieldsDependencyHandler.instance.initializeFacilityFields(data, this.contentBinding.locationContinent, initialContinents, data.getContinent(), this.contentBinding.locationSubcontinent, initialSubcontinents, data.getSubcontinent(), this.contentBinding.locationCountry, initialCountries, data.getCountry(), this.contentBinding.locationRegion, initialRegions, data.getRegion(), this.contentBinding.locationDistrict, initialDistricts, data.getDistrict(), this.contentBinding.locationCommunity, initialCommunities, data.getCommunity(), null, null, this.contentBinding.facilityTypeGroup, facilityTypeGroupList, this.contentBinding.locationFacilityType, facilityTypeList, this.contentBinding.locationFacility, initialFacilities, data.getFacility(), this.contentBinding.locationFacilityDetails, true);
setFieldVisibilitiesAndAccesses(LocationDto.class, contentBinding.mainContent);
if (!isFieldAccessible(LocationDto.class, LocationDto.COMMUNITY)) {
this.contentBinding.locationRegion.setEnabled(false);
this.contentBinding.locationDistrict.setEnabled(false);
}
contentBinding.locationAreaType.initializeSpinner(DataUtils.getEnumItems(AreaType.class));
// "Pick GPS Coordinates" confirmation dialog
this.contentBinding.pickGpsCoordinates.setOnClickListener(v -> {
final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.confirmation_pick_gps, R.string.yes, R.string.no);
confirmationDialog.setPositiveCallback(() -> {
android.location.Location phoneLocation = LocationService.instance().getLocation(getActivity());
if (phoneLocation != null) {
contentBinding.locationLatitude.setDoubleValue(phoneLocation.getLatitude());
contentBinding.locationLongitude.setDoubleValue(phoneLocation.getLongitude());
contentBinding.locationLatLonAccuracy.setFloatValue(phoneLocation.getAccuracy());
} else {
NotificationHelper.showDialogNotification(LocationDialog.this, NotificationType.WARNING, R.string.message_gps_problem);
}
});
confirmationDialog.show();
});
if (data.getId() == null) {
setLiveValidationDisabled(true);
}
if (data.getFacility() == null) {
contentBinding.locationFacilityDetails.setVisibility(GONE);
} else {
contentBinding.facilityTypeGroup.setValue(data.getFacilityType().getFacilityTypeGroup());
}
if (data.getFacilityType() != null) {
contentBinding.locationFacilityType.setValue(data.getFacilityType());
contentBinding.facilityTypeGroup.setValue(data.getFacilityType().getFacilityTypeGroup());
} else {
setFacilityContactPersonFieldsVisible(false, true);
}
contentBinding.locationFacilityType.addValueChangedListener(field -> {
if (field.getValue() == null) {
setFacilityContactPersonFieldsVisible(false, true);
} else {
setFacilityContactPersonFieldsVisible(true, true);
}
});
contentBinding.locationFacility.addValueChangedListener(field -> {
final Facility facility = (Facility) field.getValue();
// field.isDirty() always return true making it not usable in our case
if (this.previousFacility != null && this.previousFacility.equals(facility)) {
// The field didn't changed
return;
}
this.previousFacility = facility;
if (facility != null && (StringUtils.isNotEmpty(facility.getCity()) || StringUtils.isNotEmpty(facility.getPostalCode()) || StringUtils.isNotEmpty(facility.getStreet()) || StringUtils.isNotEmpty(facility.getHouseNumber()) || StringUtils.isNotEmpty(facility.getAdditionalInformation()) || facility.getAreaType() != null || facility.getLatitude() != null || facility.getLongitude() != null || (StringUtils.isNotEmpty(facility.getContactPersonFirstName()) && StringUtils.isNotEmpty(facility.getContactPersonLastName())))) {
if ((StringUtils.isNotEmpty(contentBinding.locationCity.getValue()) && !contentBinding.locationCity.getValue().equals(facility.getCity())) || (StringUtils.isNotEmpty(contentBinding.locationPostalCode.getValue()) && !contentBinding.locationPostalCode.getValue().equals(facility.getPostalCode())) || (StringUtils.isNotEmpty(contentBinding.locationStreet.getValue()) && !contentBinding.locationStreet.getValue().equals(facility.getStreet())) || (StringUtils.isNotEmpty(contentBinding.locationHouseNumber.getValue()) && !contentBinding.locationHouseNumber.getValue().equals(facility.getHouseNumber())) || (StringUtils.isNotEmpty(contentBinding.locationAdditionalInformation.getValue()) && !contentBinding.locationAdditionalInformation.getValue().equals(facility.getAdditionalInformation())) || (contentBinding.locationAreaType.getValue() != null && contentBinding.locationAreaType.getValue() != facility.getAreaType()) || (StringUtils.isNotEmpty(contentBinding.locationContactPersonFirstName.getValue()) && StringUtils.isNotEmpty(contentBinding.locationContactPersonLastName.getValue())) || (StringUtils.isNotEmpty(contentBinding.locationLatitude.getValue()) && !Double.valueOf(contentBinding.locationLatitude.getValue()).equals(facility.getLatitude())) || (StringUtils.isNotEmpty(contentBinding.locationLongitude.getValue()) && !Double.valueOf(contentBinding.locationLongitude.getValue()).equals(facility.getLongitude()))) {
ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_location, -1, R.string.yes, R.string.no);
confirmationDialog.getConfig().setSubHeading(I18nProperties.getString(Strings.confirmationLocationFacilityAddressOverride));
confirmationDialog.setPositiveCallback(() -> overrideLocationDetailsWithFacilityOnes(facility));
confirmationDialog.show();
} else {
overrideLocationDetailsWithFacilityOnes(facility);
}
}
});
ValidationHelper.initEmailValidator(contentBinding.locationContactPersonEmail);
ValidationHelper.initPhoneNumberValidator(contentBinding.locationContactPersonPhone);
}
use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class ControlSpinnerAdapter method getView.
@Override
@NonNull
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
final View view;
final TextView textView;
if (convertView == null) {
view = inflater.inflate(this.layoutResourceId, parent, false);
} else {
view = convertView;
}
final Item item = getItem(position);
textView = (TextView) view.findViewById(textViewResourceId);
if (item != null) {
textView.setText(item.toString());
}
if (textView != null && (StringUtils.isEmpty(textView.getText()))) {
if (spinner.getHint() != null) {
textView.setHint(spinner.getHint());
} else {
textView.setHint(getContext().getResources().getString(R.string.hint_select_entry));
}
textView.setTextColor(getContext().getResources().getColor(R.color.hintText));
}
return view;
}
use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class ControlSpinnerField method setFieldValue.
@Override
protected void setFieldValue(Object value) {
if (input == null) {
return;
}
if (value == null) {
removeSelection();
return;
}
SpinnerAdapter adapter = input.getAdapter();
valueOnBind = value;
if (adapter != null) {
for (int i = 0; i < adapter.getCount(); i++) {
Object itemValue = ((Item) adapter.getItem(i)).getValue();
if (value.equals(itemValue)) {
input.setSelection(i);
break;
}
}
} else {
removeSelection();
}
}
Aggregations