/**
   * Show success message for verifying MQTT broker access.
   *
   * @param message
   */
  protected void handleMqttSuccess() {
    mqttVerifyProgress.setVisibility(View.GONE);
    mqttVerifyCheck.setVisibility(View.VISIBLE);
    mqttVerifyMessage.setTextColor(Color.parseColor(SUCCESS_COLOR));
    mqttVerifyMessage.setText("MQTT broker connectivity verified.");

    // Update preferences with new values.
    String uri = mqttUri.getText().toString();
    String[] parts = uri.split("[:]+");
    if (parts.length > 0) {
      MqttServicePreferences updated = new MqttServicePreferences();
      updated.setBrokerHostname(parts[0]);
      if (parts.length > 1) {
        try {
          updated.setBrokerPort(Integer.parseInt(parts[1]));
        } catch (NumberFormatException e) {
          // Ignore invalid integers.
        }
      }
      MqttServicePreferences.update(updated, getActivity());
    }

    // Make "finish" button visible.
    wizardComplete.setVisibility(View.VISIBLE);
  }
  /** Set up field for verifying API access. */
  protected void setupMqttFields() {
    // Get reference MQTT title.
    mqttDivider = (View) getActivity().findViewById(R.id.sitewhere_mqtt_divider);

    // Get reference MQTT title.
    mqttTitle = (TextView) getActivity().findViewById(R.id.sitewhere_mqtt_title);

    // Get reference MQTT title.
    mqttLabel = (TextView) getActivity().findViewById(R.id.sitewhere_mqtt_label);

    // Get reference MQTT host group.
    mqttHostGroup = (LinearLayout) getActivity().findViewById(R.id.sitewhere_mqtt_host_grp);

    // Get reference to MQTT host text field.
    mqttUri = (EditText) getActivity().findViewById(R.id.sitewhere_mqtt);

    // Load URI from preferences if available.
    IMqttServicePreferences prefs = MqttServicePreferences.read(getActivity());
    String prefMqttUri = prefs.getBrokerHostname() + ":" + prefs.getBrokerPort();
    mqttUri.setText(prefMqttUri);

    // Get reference to 'verify' button.
    mqttVerifyButton = (Button) getActivity().findViewById(R.id.sitewhere_mqtt_submit);
    mqttVerifyButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            onMqttVerifyButtonClicked(v);
          }
        });

    // Get reference API verify group.
    mqttVerifyGroup = (LinearLayout) getActivity().findViewById(R.id.sitewhere_mqtt_verify_grp);

    // Get reference 'verify message' text view.
    mqttVerifyMessage = (TextView) getActivity().findViewById(R.id.sitewhere_mqtt_verify);

    // Get reference to check indicator for MQTT verify.
    mqttVerifyCheck = (ImageView) getActivity().findViewById(R.id.sitewhere_mqtt_verify_check);

    // Get reference to progress indicator for MQTT verify.
    mqttVerifyProgress =
        (ProgressBar) getActivity().findViewById(R.id.sitewhere_mqtt_verify_progress);
  }