use of org.edx.mobile.module.registration.view.RegistrationSelectView in project edx-app-android by edx.
the class RegisterActivity method setupRegistrationForm.
private void setupRegistrationForm(RegistrationDescription form) {
try {
LayoutInflater inflater = getLayoutInflater();
List<RegistrationFormField> agreements = new ArrayList<>();
for (RegistrationFormField field : form.getFields()) {
if (field.getFieldType().equals(RegistrationFieldType.CHECKBOX) && field.getSupplementalLink() != null) {
// this is agreement field
// this must be added at the end of the form
// hold on it
agreements.add(field);
} else {
IRegistrationFieldView fieldView = IRegistrationFieldView.Factory.getInstance(inflater, field);
if (fieldView != null)
mFieldViews.add(fieldView);
// Add item selected listener for spinner views
if (field.getFieldType().equals(RegistrationFieldType.MULTI)) {
RegistrationSelectView selectView = (RegistrationSelectView) fieldView;
selectView.setOnSpinnerItemSelectedListener(this);
selectView.setOnSpinnerFocusedListener(this);
}
}
}
// add required and optional fields to the window
for (IRegistrationFieldView v : mFieldViews) {
if (v.getField().isRequired()) {
requiredFieldsLayout.addView(v.getView());
} else {
optionalFieldsLayout.addView(v.getView());
}
}
// add agreement fields to the window if available
for (RegistrationFormField agreement : agreements) {
IRegistrationFieldView agreementView = IRegistrationFieldView.Factory.getInstance(inflater, agreement);
agreementView.setActionListener(new IRegistrationFieldView.IActionListener() {
@Override
public void onClickAgreement() {
// show EULA license that is shipped with app
environment.getRouter().showWebViewActivity(RegisterActivity.this, getString(R.string.eula_file_link), getString(R.string.end_user_title));
}
});
agreementLayout.addView(agreementView.getView());
}
// enable all the views
tryToSetUIInteraction(true);
} catch (Exception ex) {
logger.error(ex);
}
}
Aggregations