From ed42fde7860916e3c5b88bad572844b8b6dd6f0d Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Wed, 12 Nov 2014 21:43:49 +0100 Subject: [PATCH] WeatherInformation: removing TODOs --- .../java/de/example/exampletdd/MapActivity.java | 17 ++----- .../de/example/exampletdd/dummy/DummyContent.java | 55 ---------------------- .../fragment/current/CurrentFragment.java | 19 ++------ .../fragment/overview/OverviewFragment.java | 7 --- .../fragment/specific/SpecificFragment.java | 8 +--- .../exampletdd/model/WeatherLocationDbQueries.java | 1 - app/src/main/res/values/strings.xml | 3 +- 7 files changed, 11 insertions(+), 99 deletions(-) delete mode 100644 app/src/main/java/de/example/exampletdd/dummy/DummyContent.java diff --git a/app/src/main/java/de/example/exampletdd/MapActivity.java b/app/src/main/java/de/example/exampletdd/MapActivity.java index 4bfa6a2..2edbcf9 100644 --- a/app/src/main/java/de/example/exampletdd/MapActivity.java +++ b/app/src/main/java/de/example/exampletdd/MapActivity.java @@ -224,7 +224,7 @@ public class MapActivity extends FragmentActivity implements this.mLocationManager.requestSingleUpdate(criteria, this, null); } else { // TODO: string resource - Toast.makeText(this, "You do not have enabled location.", Toast.LENGTH_LONG).show(); + Toast.makeText(this, this.getString(R.string.weather_map_not_enabled_location), Toast.LENGTH_LONG).show(); } // Trying to use the synchronous calls. Problems: mGoogleApiClient read/store from different threads. // new GetLocationTask(this).execute(); @@ -391,20 +391,11 @@ public class MapActivity extends FragmentActivity implements } @Override - public void onStatusChanged(String provider, int status, Bundle extras) { - // TODO Auto-generated method stub - - } + public void onStatusChanged(String provider, int status, Bundle extras) {} @Override - public void onProviderEnabled(String provider) { - // TODO Auto-generated method stub - - } + public void onProviderEnabled(String provider) {} @Override - public void onProviderDisabled(String provider) { - // TODO Auto-generated method stub - - } + public void onProviderDisabled(String provider) {} } diff --git a/app/src/main/java/de/example/exampletdd/dummy/DummyContent.java b/app/src/main/java/de/example/exampletdd/dummy/DummyContent.java deleted file mode 100644 index 6c09241..0000000 --- a/app/src/main/java/de/example/exampletdd/dummy/DummyContent.java +++ /dev/null @@ -1,55 +0,0 @@ -package de.example.exampletdd.dummy; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Helper class for providing sample content for user interfaces created by - * Android template wizards. - *

- * TODO: Replace all uses of this class before publishing your app. - */ -public class DummyContent { - - /** - * An array of sample (dummy) items. - */ - public static List ITEMS = new ArrayList(); - - /** - * A map of sample (dummy) items, by ID. - */ - public static Map ITEM_MAP = new HashMap(); - - static { - // Add 3 sample items. - addItem(new DummyItem("1", "Item 1")); - addItem(new DummyItem("2", "Item 2")); - addItem(new DummyItem("3", "Item 3")); - } - - private static void addItem(DummyItem item) { - ITEMS.add(item); - ITEM_MAP.put(item.id, item); - } - - /** - * A dummy item representing a piece of content. - */ - public static class DummyItem { - public String id; - public String content; - - public DummyItem(String id, String content) { - this.id = id; - this.content = content; - } - - @Override - public String toString() { - return content; - } - } -} diff --git a/app/src/main/java/de/example/exampletdd/fragment/current/CurrentFragment.java b/app/src/main/java/de/example/exampletdd/fragment/current/CurrentFragment.java index 5a85320..dbec00e 100644 --- a/app/src/main/java/de/example/exampletdd/fragment/current/CurrentFragment.java +++ b/app/src/main/java/de/example/exampletdd/fragment/current/CurrentFragment.java @@ -176,7 +176,6 @@ public class CurrentFragment extends Fragment { new ServiceParser(new JPOSWeatherParser())); task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude()); - // TODO: make sure UI thread keeps running in parallel after that. I guess. } } @@ -340,13 +339,11 @@ public class CurrentFragment extends Fragment { R.drawable.weather_severe_alert); } - // TODO: static resource - String description = "no description available"; + String description = this.getString(R.string.test_field_description_when_error); if (current.getWeather().size() > 0) { description = current.getWeather().get(0).getDescription(); } - // TODO: units!!!! String humidityValue = ""; if ((current.getMain() != null) && (current.getMain().getHumidity() != null)) { @@ -468,11 +465,7 @@ public class CurrentFragment extends Fragment { return false; } - - // TODO: How could I show just one progress dialog when I have two fragments in tabs - // activity doing the same in background? - // I mean, if OverviewTask shows one progress dialog and CurrentTask does the same I will have - // have two progress dialogs... How may I solve this problem? I HATE ANDROID. + private class CurrentTask extends AsyncTask { // Store the context passed to the AsyncTask when the system instantiates it. private final Context localContext; @@ -520,18 +513,12 @@ public class CurrentFragment extends Fragment { final String url = weatherService.createURIAPICurrent(urlAPI, APIVersion, latitude, longitude); final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis()); final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache)); - final Current current = weatherService.retrieveCurrentFromJPOS(jsonData); - // TODO: what is this for? I guess I could skip it :/ - final Calendar now = Calendar.getInstance(); - current.setDate(now.getTime()); - return current; + return weatherService.retrieveCurrentFromJPOS(jsonData); } @Override protected void onPostExecute(final Current current) { - // TODO: Is AsyncTask calling this method even when RunTimeException in doInBackground method? - // I hope so, otherwise I must catch(Throwable) in doInBackground method :( // Call updateUI on the UI thread. final Intent currentData = new Intent("de.example.exampletdd.UPDATECURRENT"); diff --git a/app/src/main/java/de/example/exampletdd/fragment/overview/OverviewFragment.java b/app/src/main/java/de/example/exampletdd/fragment/overview/OverviewFragment.java index 139afe9..c46940d 100644 --- a/app/src/main/java/de/example/exampletdd/fragment/overview/OverviewFragment.java +++ b/app/src/main/java/de/example/exampletdd/fragment/overview/OverviewFragment.java @@ -154,7 +154,6 @@ public class OverviewFragment extends ListFragment { new ServiceParser(new JPOSWeatherParser())); task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude()); - // TODO: make sure thread UI keeps running in parallel after that. I guess. } } @@ -340,10 +339,6 @@ public class OverviewFragment extends ListFragment { return false; } - // TODO: How could I show just one progress dialog when I have two fragments in tabs - // activity doing the same in background? - // I mean, if OverviewTask shows one progress dialog and CurrentTask does the same I will have - // have two progress dialogs... How may I solve this problem? I HATE ANDROID. private class OverviewTask extends AsyncTask { // Store the context passed to the AsyncTask when the system instantiates it. private final Context localContext; @@ -399,8 +394,6 @@ public class OverviewFragment extends ListFragment { @Override protected void onPostExecute(final Forecast forecast) { - // TODO: Is AsyncTask calling this method even when RunTimeException in doInBackground method? - // I hope so, otherwise I must catch(Throwable) in doInBackground method :( // Call updateUI on the UI thread. final Intent forecastData = new Intent("de.example.exampletdd.UPDATEFORECAST"); diff --git a/app/src/main/java/de/example/exampletdd/fragment/specific/SpecificFragment.java b/app/src/main/java/de/example/exampletdd/fragment/specific/SpecificFragment.java index 4912fe2..fa4c6a3 100644 --- a/app/src/main/java/de/example/exampletdd/fragment/specific/SpecificFragment.java +++ b/app/src/main/java/de/example/exampletdd/fragment/specific/SpecificFragment.java @@ -247,15 +247,13 @@ public class SpecificFragment extends Fragment { } else { picture = BitmapFactory.decodeResource(this.getResources(), R.drawable.weather_severe_alert); - } + } - // TODO: string resource - String description = "no description available"; + String description = this.getString(R.string.test_field_description_when_error); if (forecast.getWeather().size() > 0) { description = forecast.getWeather().get(0).getDescription(); } - // TODO: units!!!! String humidityValue = ""; if (forecast.getHumidity() != null) { final double conversion = (Double) forecast.getHumidity(); @@ -354,7 +352,5 @@ public class SpecificFragment extends Fragment { if (forecast != null) { this.updateUI(forecast, this.mChosenDay); } - - // TODO: Overview is doing things with mListState... Why not here? } } diff --git a/app/src/main/java/de/example/exampletdd/model/WeatherLocationDbQueries.java b/app/src/main/java/de/example/exampletdd/model/WeatherLocationDbQueries.java index a4f3f56..e35dc18 100644 --- a/app/src/main/java/de/example/exampletdd/model/WeatherLocationDbQueries.java +++ b/app/src/main/java/de/example/exampletdd/model/WeatherLocationDbQueries.java @@ -139,7 +139,6 @@ public class WeatherLocationDbQueries { private WeatherLocation queryDataBase(final String table, final String[] projection, final String[] selectionArgs, final String selection, final DoQuery doQuery) { - // TODO: execute around idiom? I miss try/finally with resources final SQLiteDatabase db = this.mDbHelper.getReadableDatabase(); try { final Cursor cursor = db.query(table, projection, selection, selectionArgs, null, null, null); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5a54a68..970879e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,6 +17,7 @@ mm 3h % No data available + no description available Settings @@ -76,6 +77,7 @@ Please wait… Save Location Get Location + You do not have enabled location. About @@ -100,7 +102,6 @@ http://gumartinm.name http://openweathermap.org/ About - Hello world! Settings -- 2.1.4