Subversion Repositories ES

Rev

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

Rev 12 Rev 13
Line 25... Line 25...
25
  private static final String TABLE = "currency"; //$NON-NLS-1$
25
  private static final String TABLE = "currency"; //$NON-NLS-1$
26
  private static final String COLUMN_CURRENCY1 = "currency1"; //$NON-NLS-1$
26
  private static final String COLUMN_CURRENCY1 = "currency1"; //$NON-NLS-1$
27
  private static final String COLUMN_CURRENCY2 = "currency2"; //$NON-NLS-1$
27
  private static final String COLUMN_CURRENCY2 = "currency2"; //$NON-NLS-1$
28
  private static final String COLUMN_FACTOR = "factor"; //$NON-NLS-1$
28
  private static final String COLUMN_FACTOR = "factor"; //$NON-NLS-1$
29
29
30
  private static HashMap<String, HashMap<String, Double>> currencyConversions =
30
  private static HashMap<String, HashMap<String, Double>> conversionRates =
31
    new HashMap<String, HashMap<String, Double>>();
31
    new HashMap<String, HashMap<String, Double>>();
32
  static
32
  static
33
  {
33
  {
34
    HashMap<String, Double> conversionFactors = new HashMap<String, Double>();
34
    HashMap<String, Double> conversionFactors = new HashMap<String, Double>();
35
    conversionFactors.put(CurrenciesActivity.VALUE_EUR, 0.767842293);
35
    conversionFactors.put(CurrenciesActivity.VALUE_EUR, 0.767842293);
36
    conversionFactors.put(CurrenciesActivity.VALUE_USD, 1.03413);
36
    conversionFactors.put(CurrenciesActivity.VALUE_USD, 1.03413);
37
    CurrenciesDatabase.currencyConversions.put(CurrenciesActivity.VALUE_CHF,
37
    CurrenciesDatabase.conversionRates.put(CurrenciesActivity.VALUE_CHF,
38
      conversionFactors);
38
      conversionFactors);
39
39
40
    conversionFactors = new HashMap<String, Double>();
40
    conversionFactors = new HashMap<String, Double>();
41
    conversionFactors.put(CurrenciesActivity.VALUE_CHF, 1.30235077);
41
    conversionFactors.put(CurrenciesActivity.VALUE_CHF, 1.30235077);
42
    conversionFactors.put(CurrenciesActivity.VALUE_USD, 1.3468);
42
    conversionFactors.put(CurrenciesActivity.VALUE_USD, 1.3468);
43
    CurrenciesDatabase.currencyConversions.put(CurrenciesActivity.VALUE_EUR,
43
    CurrenciesDatabase.conversionRates.put(CurrenciesActivity.VALUE_EUR,
44
      conversionFactors);
44
      conversionFactors);
45
45
46
    conversionFactors = new HashMap<String, Double>();
46
    conversionFactors = new HashMap<String, Double>();
47
    conversionFactors.put(CurrenciesActivity.VALUE_CHF, 0.966996412);
47
    conversionFactors.put(CurrenciesActivity.VALUE_CHF, 0.966996412);
48
    conversionFactors.put(CurrenciesActivity.VALUE_EUR, 0.742500743);
48
    conversionFactors.put(CurrenciesActivity.VALUE_EUR, 0.742500743);
49
    CurrenciesDatabase.currencyConversions.put(CurrenciesActivity.VALUE_USD,
49
    CurrenciesDatabase.conversionRates.put(CurrenciesActivity.VALUE_USD,
50
      conversionFactors);
50
      conversionFactors);
51
  }
51
  }
52
  private final CurrenciesActivity context;
52
  private final CurrenciesActivity context;
53
53
54
  /**
54
  /**
Line 109... Line 109...
109
   */
109
   */
110
  @SuppressWarnings("nls")
110
  @SuppressWarnings("nls")
111
  @Override
111
  @Override
112
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
112
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
113
  {
113
  {
114
    /* NOTE: Should migrate database instead */
114
    /* NOTE: We should migrate an existing database instead */
115
    db.execSQL("DROP TABLE IF EXISTS " + CurrenciesDatabase.TABLE);
115
    db.execSQL("DROP TABLE IF EXISTS " + CurrenciesDatabase.TABLE);
116
    this.onCreate(db);
116
    this.onCreate(db);
117
  }
117
  }
118
118
119
  /**
119
  /**
120
   * @return
120
   * @return
121
   */
121
   */
122
  public HashMap<String, HashMap<String, Double>> getConversionRates()
122
  public HashMap<String, HashMap<String, Double>> getConversionRates()
123
  {
123
  {
124
    return CurrenciesDatabase.currencyConversions;
124
    return CurrenciesDatabase.conversionRates;
125
  }
125
  }
126
126
127
  /**
127
  /**
128
   * Reads currency conversions and updates the static currencyConversions field
128
   * Reads currency conversions and updates the static currencyConversions field
129
   * of this class
129
   * of this class
Line 207... Line 207...
207
             * NOTE: Update from last table row; cursor not empty, so we can
207
             * NOTE: Update from last table row; cursor not empty, so we can
208
             * skip the test for null
208
             * skip the test for null
209
             */
209
             */
210
            newCurrencyConversions.put(currency1Str, mapForCurrency);
210
            newCurrencyConversions.put(currency1Str, mapForCurrency);
211
211
212
            CurrenciesDatabase.currencyConversions = newCurrencyConversions;
212
            CurrenciesDatabase.conversionRates = newCurrencyConversions;
213
          }
213
          }
214
        }
214
        }
215
        catch (IllegalArgumentException e)
215
        catch (IllegalArgumentException e)
216
        {
216
        {
217
          /* Could not retrieve column index */
217
          /* Could not retrieve column index */