public void setValues(String ip, TcpConnectionManager.ReceiverType type, int menu) { this.ip = ip; this.type = type; this.menu = menu; connection = tcpConnectionManager.requireConnection(this); int[] spinnerMenus = TcpConnectionManager.getDropdownMenuSubmenus(getResources(), type); String[] spinnerCommands = TcpConnectionManager.getDropdownMenuCommandValues(getResources(), type); String[] spinnerResponses = TcpConnectionManager.getDropdownMenuResponseValues(getResources(), type); String[] spinnerReadables = TcpConnectionManager.getDropdownMenuNames(getResources(), type); if (spinnerMenus.length != spinnerCommands.length || spinnerMenus.length != spinnerResponses.length || spinnerMenus.length != spinnerReadables.length) { Log.e(LOG_TAG, "setValues: Array lengths don't match"); return; } for (int i = 0; i < spinnerMenus.length; i++) { if (spinnerMenus[i] == menu) { responseClassifier = spinnerResponses[i]; command = spinnerCommands[i]; submenuReadable = spinnerReadables[i]; break; } } setSpinnerContent(); }
private void updateUI(TcpInformation information) { if (information == null) { return; } if (information.getType().equals(TcpInformation.InformationType.UPDATE_MENU) && information.isIntAvailable() && information.getIntValue() == menu) { // This means we should update the content of our spinner setSpinnerContent(); } else if (information.isClassifiedResponse() && information.getResponseClassifier().equals(responseClassifier) && information.getStringValue() != null) { int index = Arrays.asList(spinnerItemNames).indexOf(information.getStringValue()); if (index >= 0) { spinner.setSelection(index); } } }