@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_temperature_converter);

    EditNumber celsiusEditNumber = (EditNumber) findViewById(R.id.converter_celsius_input);
    EditNumber fahrenheitEditNumber = (EditNumber) findViewById(R.id.converter_fahrenheit_input);
    celsiusEditNumber.addTextChangedListener(
        newCelciusToFehrenheitWatcher(celsiusEditNumber, fahrenheitEditNumber));
    fahrenheitEditNumber.addTextChangedListener(
        newFehrenheitToCelciusWatcher(fahrenheitEditNumber, celsiusEditNumber));
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    if (DEBUG) {
      Log.d(TAG, "onCreate(" + savedInstanceState + ")");
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mCelsius = (EditNumber) findViewById(R.id.celsius);
    mFahrenheit = (EditNumber) findViewById(R.id.fahrenheit);

    mCelsius.addTextChangedListener(
        new TemperatureChangeWatcher(mCelsius, mFahrenheit) {

          @Override
          protected double convert(double temp) {
            return TemperatureConverter.celsiusToFahrenheit(temp);
          }
        });

    mFahrenheit.addTextChangedListener(
        new TemperatureChangeWatcher(mFahrenheit, mCelsius) {

          @Override
          protected double convert(double temp) {
            return TemperatureConverter.fahrenheitToCelsius(temp);
          }
        });

    if (savedInstanceState != null) {
      if (savedInstanceState.containsKey(CELSIUS_KEY)) {
        final double c = savedInstanceState.getDouble(CELSIUS_KEY);
        final double f = TemperatureConverter.celsiusToFahrenheit(c);
        if (DEBUG) {
          Log.d(TAG, "onCreate: restoring celsius: " + c);
        }
        mCelsius.setNumber(c);
        mFahrenheit.setNumber(f);
      } else if (savedInstanceState.containsKey(FAHRENHEIT_KEY)) {
        final double f = savedInstanceState.getDouble(FAHRENHEIT_KEY);
        final double c = TemperatureConverter.fahrenheitToCelsius(f);
        if (DEBUG) {
          Log.d(TAG, "onCreate: restoring fahrenheit: " + f);
        }
        mFahrenheit.setNumber(f);
        mCelsius.setNumber(c);
      }
    }

    mCelsius.setOnFocusChangeListener(mTemperatureEntryFocusChangeListener);
    mFahrenheit.setOnFocusChangeListener(mTemperatureEntryFocusChangeListener);
  }