Esempio n. 1
0
 public void show(MySocketAddress addr) {
   mDialog.show();
   if (addr != null) {
     mDialog.setTitle(R.string.title_edit_socket_address);
     mDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setVisibility(View.VISIBLE);
     mCurrentId = addr.getId();
     mHostNameEdit.setText(addr.getHostName());
     if (addr.getPort() != null) {
       mPortEdit.setText(String.valueOf(addr.getPort()));
     } else {
       mPortEdit.setText(String.valueOf(net.cattaka.libgeppa.Constants.DEFAULT_SERVER_PORT));
     }
   } else {
     mDialog.setTitle(R.string.title_input_socket_address);
     mDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setVisibility(View.INVISIBLE);
     mHostNameEdit.setText("");
     mPortEdit.setText(String.valueOf(net.cattaka.libgeppa.Constants.DEFAULT_SERVER_PORT));
     mCurrentId = null;
   }
 }
Esempio n. 2
0
 @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);
   }
 }