Subversion Repositories ES

Rev

Rev 7 | Rev 13 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 8
Line 1... Line 1...
1
package ch.ffhs.converter.app;
1
package de.pointedears.converter.app;
2
2
3
import java.util.HashMap;
3
import java.util.HashMap;
4
4
5
import android.app.Activity;
5
import android.app.Activity;
6
import android.os.Bundle;
6
import android.os.Bundle;
Line 11... Line 11...
11
import android.widget.AdapterView;
11
import android.widget.AdapterView;
12
import android.widget.AdapterView.OnItemSelectedListener;
12
import android.widget.AdapterView.OnItemSelectedListener;
13
import android.widget.EditText;
13
import android.widget.EditText;
14
import android.widget.Spinner;
14
import android.widget.Spinner;
15
import android.widget.TextView;
15
import android.widget.TextView;
16
import ch.ffhs.converter.R;
16
import de.pointedears.converter.R;
17
17
18
/**
18
/**
19
 * Activity that implements length conversion
19
 * Activity that implements length conversion
20
 *
20
 *
21
 * @author pelinux
21
 * @author pelinux
22
 */
22
 */
23
public class TemperaturesActivity extends Activity
23
public class TemperaturesActivity extends Activity
24
{
24
{
25
  /**
-
 
26
   *
-
 
27
   */
-
 
28
  private static final String MSG_BELOW_ABS_ZERO = "K must be >= 0";
-
 
29
  /*
25
  /*
30
   * Constants for mapping value strings to internal IDs
26
   * Constants for mapping value strings to internal IDs
31
   */
27
   */
32
  private static final String VALUE_CELSIUS = "C"; //$NON-NLS-1$
28
  private static final String VALUE_CELSIUS = "C"; //$NON-NLS-1$
33
  private static final String VALUE_FAHRENHEIT = "F"; //$NON-NLS-1$
29
  private static final String VALUE_FAHRENHEIT = "F"; //$NON-NLS-1$
Line 238... Line 234...
238
            break;
234
            break;
239
        }
235
        }
240
        break;
236
        break;
241
237
242
      case ITEM_KELVIN:
238
      case ITEM_KELVIN:
243
        if (value < 0.0)
-
 
244
        {
-
 
245
          return TemperaturesActivity.MSG_BELOW_ABS_ZERO;
-
 
246
        }
-
 
247
-
 
248
        switch (itemId2)
239
        switch (itemId2)
249
        {
240
        {
250
          case ITEM_CELSIUS:
241
          case ITEM_CELSIUS:
251
            newValue = new Double(value - 273.15);
242
            newValue = new Double(value - 273.15);
252
            break;
243
            break;
253
244
254
          case ITEM_FAHRENHEIT:
245
          case ITEM_FAHRENHEIT:
255
            newValue = new Double(value * 9.0 / 5 - 459.67);
246
            newValue = new Double(value * 9.0 / 5 - 459.67);
256
            break;
247
            break;
257
        }
248
        }
-
 
249
-
 
250
        if (value < 0.0)
-
 
251
        {
-
 
252
          this.textOffScale.setVisibility(View.VISIBLE);
-
 
253
          return "*" + newValue.toString();
-
 
254
        }
258
        break;
255
        break;
259
    }
256
    }
260
257
261
    return newValue.toString();
258
    return newValue.toString();
262
  }
259
  }