@Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { String hostName = mHostNameEdit.getText().toString(); int port = net.cattaka.libgeppa.Constants.DEFAULT_SERVER_PORT; try { port = Integer.parseInt(mPortEdit.getText().toString()); } catch (NumberFormatException e) { // Ignore } MySocketAddress addr = new MySocketAddress(); addr.setId(mCurrentId); addr.setHostName(hostName); addr.setPort(port); mListener.onEditAddrresDialogFinished(addr); } else if (which == DialogInterface.BUTTON_NEGATIVE) { dialog.cancel(); } else if (which == DialogInterface.BUTTON_NEUTRAL) { mListener.onEditAddrresDialogDelete(mCurrentId); } }