public RegisterManager() { super(USE_ALL_WIDTH | VERTICAL_SCROLL | VERTICAL_SCROLLBAR); XYEdges boxEdges = new XYEdges(0, 20, 5, 20); XYEdges buttonEdges = new XYEdges(0, 20, 0, 20); userInput = new UserInput(); userInput.setDefaultText("E-mail as username"); userInput.setPadding(boxEdges); add(userInput); firstnameEdit = new TextInput("First name"); firstnameEdit.setPadding(boxEdges); add(firstnameEdit); lastnameEdit = new TextInput("Last name"); lastnameEdit.setPadding(boxEdges); add(lastnameEdit); passInput = new PassLockInput(); passInput.setPadding(boxEdges); add(passInput); confirmPassInput = new PassInput(); confirmPassInput.setPadding(boxEdges); add(confirmPassInput); GreenLabelField greenButton = new GreenLabelField("Submit"); greenButton.setMargin(buttonEdges); greenButton.setChangeListener(this); add(greenButton); }
public void fieldChanged(Field field, int context) { if (field instanceof GreenLabelField) { String pass = passInput.getValue(); String confirm = confirmPassInput.getValue(); String username = userInput.getValue().trim(); if (validateUsername(username) && validatePassword(pass, confirm)) { URLEncodedPostData postData = new URLEncodedPostData(null, false); String name = firstnameEdit.getValue().trim() + " " + lastnameEdit.getValue().trim(); postData.append("name", name); postData.append("email", username); postData.append("password", pass); RegisterConnector registerConnector = new RegisterConnector(postData); registerConnector.start(); UiApplication.getUiApplication().pushScreen(new LoadingScreen(registerConnector)); } } }