Compare Revisions
Last modification
- Rev 11 2011-01-21 14:22:57
- Author: PointedEars
- Log message:
Added currencies database (currently only for debugging)
/trunk/src/de/pointedears/converter/db/CurrenciesDatabase.java |
File deleted |
|
Property changes: |
Deleted: svn:mime-type |
## -1 +0,0 ## |
-text/plain |
\ No newline at end of property |
Index: src/de/pointedears/converter/app/CurrenciesActivity.java |
=================================================================== |
--- src/de/pointedears/converter/app/CurrenciesActivity.java (revision 11) |
+++ src/de/pointedears/converter/app/CurrenciesActivity.java (revision 10) |
@@ -3,9 +3,6 @@ |
import java.util.HashMap; |
import android.app.Activity; |
-import android.database.Cursor; |
-import android.database.sqlite.SQLiteDatabase; |
-import android.database.sqlite.SQLiteException; |
import android.os.Bundle; |
import android.text.Editable; |
import android.view.KeyEvent; |
@@ -19,7 +16,6 @@ |
import android.widget.EditText; |
import android.widget.Spinner; |
import de.pointedears.converter.R; |
-import de.pointedears.converter.db.CurrenciesDatabase; |
|
/** |
* Activity that implements currency conversion |
@@ -35,7 +31,7 @@ |
private static final String VALUE_EUR = "EUR"; //$NON-NLS-1$ |
private static final String VALUE_USD = "USD"; //$NON-NLS-1$ |
|
- protected static HashMap<String, HashMap<String, Double>> currencyConversions; |
+ private static HashMap<String, HashMap<String, Double>> currencyConversions; |
|
/* Unit spinners (dropdowns) */ |
private Spinner spinnerUnit1; |
@@ -49,7 +45,7 @@ |
super.onCreate(savedInstanceState); |
this.setContentView(R.layout.activity_currencies); |
|
- /* Set up currency database */ |
+ /* TODO: Set up currency database */ |
CurrenciesActivity.currencyConversions = |
new HashMap<String, HashMap<String, Double>>(); |
|
@@ -61,7 +57,7 @@ |
|
conversionFactors = new HashMap<String, Double>(); |
conversionFactors.put(CurrenciesActivity.VALUE_CHF, 1.30235077); |
- conversionFactors.put(CurrenciesActivity.VALUE_USD, 1.3468); |
+ conversionFactors.put(CurrenciesActivity.VALUE_CHF, 1.3468); |
CurrenciesActivity.currencyConversions.put(CurrenciesActivity.VALUE_EUR, |
conversionFactors); |
|
@@ -71,64 +67,6 @@ |
CurrenciesActivity.currencyConversions.put(CurrenciesActivity.VALUE_USD, |
conversionFactors); |
|
- /* Create database with values above if it does not exist */ |
- CurrenciesDatabase db = new CurrenciesDatabase(this); |
- try |
- { |
- SQLiteDatabase dbConn = db.getReadableDatabase(); |
- |
- @SuppressWarnings("nls") |
- Cursor myCursor = |
- dbConn.query(true, CurrenciesDatabase.TABLE, null, null, null, null, |
- null, CurrenciesDatabase.COLUMN_CURRENCY1 + "," |
- + CurrenciesDatabase.COLUMN_CURRENCY2, null); |
- |
- @SuppressWarnings({ "unused", "nls" }) |
- String queryResult = ""; |
- if (myCursor != null) |
- { |
- try |
- { |
- int currency1Id = |
- myCursor |
- .getColumnIndexOrThrow(CurrenciesDatabase.COLUMN_CURRENCY1); |
- int currency2Id = |
- myCursor |
- .getColumnIndexOrThrow(CurrenciesDatabase.COLUMN_CURRENCY2); |
- int factorId = |
- myCursor.getColumnIndexOrThrow(CurrenciesDatabase.COLUMN_FACTOR); |
- |
- if (myCursor.moveToFirst()) |
- { |
- do |
- { |
- String currency1Str = myCursor.getString(currency1Id); |
- String currency2Str = myCursor.getString(currency2Id); |
- Double factor = myCursor.getDouble(factorId); |
- |
- /* DEBUG */ |
- queryResult += |
- currency1Str + " --> " + currency2Str + ": " + factor + "\n"; |
- } |
- while (myCursor.moveToNext()); |
- } |
- } |
- catch (IllegalArgumentException e) |
- { |
- /* Could not retrieve column index */ |
- e.printStackTrace(); |
- } |
- } |
- |
- /* TODO: Close only on exit */ |
- dbConn.close(); |
- } |
- catch (SQLiteException e1) |
- { |
- /* Could not open database */ |
- e1.printStackTrace(); |
- } |
- |
final EditText editValue1 = |
(EditText) this.findViewById(R.id.currencies_edit_value1); |
final EditText editValue2 = |
@@ -291,12 +229,4 @@ |
/* update here */ |
return super.onOptionsItemSelected(item); |
} |
- |
- /** |
- * @return |
- */ |
- public HashMap<String, HashMap<String, Double>> getCurrencyConversions() |
- { |
- return CurrenciesActivity.currencyConversions; |
} |
-} |