From: Gustavo Martin Morcuende Date: Thu, 13 Nov 2014 01:50:50 +0000 (+0100) Subject: WeatherInformation: removing TODOs X-Git-Tag: weatherinformation-1.0~70 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=95ab6c9d90f925a807aae262cf825c1b3b220156;p=AndroidWeatherInformation WeatherInformation: removing TODOs --- diff --git a/app/src/main/java/de/example/exampletdd/MapActivity.java b/app/src/main/java/de/example/exampletdd/MapActivity.java index 2edbcf9..2d8d234 100644 --- a/app/src/main/java/de/example/exampletdd/MapActivity.java +++ b/app/src/main/java/de/example/exampletdd/MapActivity.java @@ -82,8 +82,7 @@ public class MapActivity extends FragmentActivity implements super.onResume(); final ActionBar actionBar = this.getActionBar(); - // TODO: string resource - actionBar.setTitle("Mark your location"); + actionBar.setTitle(this.getString(R.string.weather_map_mark_location)); WeatherLocation weatherLocation; if (this.mRestoreUI != null) { @@ -223,7 +222,6 @@ public class MapActivity extends FragmentActivity implements this.mLocationManager.requestSingleUpdate(criteria, this, null); } else { - // TODO: string resource 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. @@ -279,8 +277,7 @@ public class MapActivity extends FragmentActivity implements this.removeProgressFragment(); this.addButtonsFragment(); // No geocoder is present. Issue an error message. - // TODO: string resource - Toast.makeText(this, "Cannot get address. No geocoder available.", Toast.LENGTH_LONG).show(); + Toast.makeText(this, this.getString(R.string.weather_map_no_geocoder_available), Toast.LENGTH_LONG).show(); // Default values final String city = this.getString(R.string.city_not_found); diff --git a/app/src/main/java/de/example/exampletdd/NotificationIntentService.java b/app/src/main/java/de/example/exampletdd/NotificationIntentService.java index 6f4f311..794b761 100644 --- a/app/src/main/java/de/example/exampletdd/NotificationIntentService.java +++ b/app/src/main/java/de/example/exampletdd/NotificationIntentService.java @@ -91,12 +91,8 @@ public class NotificationIntentService extends IntentService { weatherLocation.getLatitude(), weatherLocation.getLongitude()); 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); } private interface UnitsConversor { diff --git a/app/src/main/java/de/example/exampletdd/SpecificActivity.java b/app/src/main/java/de/example/exampletdd/SpecificActivity.java index 3cb5da4..6689409 100644 --- a/app/src/main/java/de/example/exampletdd/SpecificActivity.java +++ b/app/src/main/java/de/example/exampletdd/SpecificActivity.java @@ -3,6 +3,10 @@ package de.example.exampletdd; import android.app.ActionBar; import android.os.Bundle; import android.support.v4.app.FragmentActivity; + +import java.text.MessageFormat; +import java.util.Locale; + import de.example.exampletdd.model.DatabaseQueries; import de.example.exampletdd.model.WeatherLocation; @@ -30,8 +34,12 @@ public class SpecificActivity extends FragmentActivity { final WeatherLocation weatherLocation = query.queryDataBase(); if (weatherLocation != null) { final ActionBar actionBar = this.getActionBar(); - // TODO: I18N and comma :/ - actionBar.setTitle(weatherLocation.getCity() + "," + weatherLocation.getCountry()); + final String[] array = new String[2]; + array[0] = weatherLocation.getCity(); + array[1] = weatherLocation.getCountry(); + final MessageFormat message = new MessageFormat("{0},{1}", Locale.US); + final String cityCountry = message.format(array); + actionBar.setTitle(cityCountry); } } } diff --git a/app/src/main/java/de/example/exampletdd/WeatherTabsActivity.java b/app/src/main/java/de/example/exampletdd/WeatherTabsActivity.java index 384e759..6ab1e11 100644 --- a/app/src/main/java/de/example/exampletdd/WeatherTabsActivity.java +++ b/app/src/main/java/de/example/exampletdd/WeatherTabsActivity.java @@ -15,6 +15,10 @@ import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; import android.view.MenuItem; + +import java.text.MessageFormat; +import java.util.Locale; + import de.example.exampletdd.fragment.current.CurrentFragment; import de.example.exampletdd.fragment.overview.OverviewFragment; import de.example.exampletdd.model.DatabaseQueries; @@ -134,11 +138,14 @@ public class WeatherTabsActivity extends FragmentActivity { final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); if (weatherLocation != null) { - // TODO: I18N and comma :/ - actionBar.setTitle(weatherLocation.getCity() + "," + weatherLocation.getCountry()); + final String[] array = new String[2]; + array[0] = weatherLocation.getCity(); + array[1] = weatherLocation.getCountry(); + final MessageFormat message = new MessageFormat("{0},{1}", Locale.US); + final String cityCountry = message.format(array); + actionBar.setTitle(cityCountry); } else { - // TODO: static resource - actionBar.setTitle("no chosen location"); + actionBar.setTitle(this.getString(R.string.text_field_no_chosen_location)); } // 2. Update forecast tab text. @@ -175,12 +182,9 @@ public class WeatherTabsActivity extends FragmentActivity { @Override public Fragment getItem(final int position) { if (position == 0) { - // TODO: new instance every time I click on tab? return new CurrentFragment(); } else { - // TODO: new instance every time I click on tab? - final Fragment fragment = new OverviewFragment(); - return fragment; + return new OverviewFragment(); } } diff --git a/app/src/main/java/de/example/exampletdd/WidgetIntentService.java b/app/src/main/java/de/example/exampletdd/WidgetIntentService.java index ab27004..df2b36f 100644 --- a/app/src/main/java/de/example/exampletdd/WidgetIntentService.java +++ b/app/src/main/java/de/example/exampletdd/WidgetIntentService.java @@ -145,12 +145,8 @@ public class WidgetIntentService extends IntentService { weatherLocation.getLatitude(), weatherLocation.getLongitude()); 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); } private interface UnitsConversor { @@ -248,7 +244,7 @@ public class WidgetIntentService extends IntentService { if (!isCountry) { remoteView.setViewVisibility(R.id.weather_appwidget_country, View.GONE); } else { - // TODO: It is as if Android has a view cache. If I did not set VISIBLE value, + // TODO: It is as if Android had a view cache. If I did not set VISIBLE value, // the country field would be gone forever... :/ remoteView.setViewVisibility(R.id.weather_appwidget_country, View.VISIBLE); remoteView.setTextViewText(R.id.weather_appwidget_country, country); 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 dbec00e..b63b0aa 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 @@ -72,8 +72,6 @@ public class CurrentFragment extends Fragment { // Restore UI state final Current current = (Current) savedInstanceState.getSerializable("Current"); - // TODO: Could it be better to store in global forecast data even if it is null value? - // So, perhaps do not check for null value and always store in global variable. if (current != null) { final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); store.saveCurrent(current); @@ -186,8 +184,6 @@ public class CurrentFragment extends Fragment { final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); final Current current = store.getCurrent(); - // TODO: Could it be better to save current data even if it is null value? - // So, perhaps do not check for null value. if (current != null) { savedInstanceState.putSerializable("Current", current); } @@ -339,7 +335,7 @@ public class CurrentFragment extends Fragment { R.drawable.weather_severe_alert); } - String description = this.getString(R.string.test_field_description_when_error); + String description = this.getString(R.string.text_field_description_when_error); if (current.getWeather().size() > 0) { description = current.getWeather().get(0).getDescription(); } diff --git a/app/src/main/java/de/example/exampletdd/fragment/map/MapProgressFragment.java b/app/src/main/java/de/example/exampletdd/fragment/map/MapProgressFragment.java index aa4b6e4..2beca53 100644 --- a/app/src/main/java/de/example/exampletdd/fragment/map/MapProgressFragment.java +++ b/app/src/main/java/de/example/exampletdd/fragment/map/MapProgressFragment.java @@ -121,8 +121,6 @@ public class MapProgressFragment extends Fragment { @Override protected void onPostExecute(final WeatherLocation weatherLocation) { - // 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. if (mCallbacks != null) { 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 c46940d..56af654 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 @@ -66,8 +66,6 @@ public class OverviewFragment extends ListFragment { // Restore UI state final Forecast forecast = (Forecast) savedInstanceState.getSerializable("Forecast"); - // TODO: Could it be better to store in global forecast data even if it is null value? - // So, perhaps do not check for null value and always store in global variable. if (forecast != null) { final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); store.saveForecast(forecast); @@ -141,7 +139,6 @@ public class OverviewFragment extends ListFragment { final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); final Forecast forecast = store.getForecast(); - // TODO: store forecast data in permanent storage and check here if there is data in permanent storage if (forecast != null && this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) { this.updateUI(forecast); } else { @@ -164,8 +161,6 @@ public class OverviewFragment extends ListFragment { final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); final Forecast forecast = store.getForecast(); - // TODO: Could it be better to save forecast data even if it is null value? - // So, perhaps do not check for null value. if (forecast != null) { savedInstanceState.putSerializable("Forecast", forecast); } 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 fa4c6a3..a44a462 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 @@ -59,8 +59,6 @@ public class SpecificFragment extends Fragment { // Restore UI state final Forecast forecast = (Forecast) savedInstanceState.getSerializable("Forecast"); - // TODO: Could it be better to store in global data forecast even if it is null value? - // So, perhaps do not check for null value and always store in global variable. if (forecast != null) { final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); store.saveForecast(forecast); @@ -79,8 +77,6 @@ public class SpecificFragment extends Fragment { final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); final Forecast forecast = store.getForecast(); - // TODO: Could it be better to save forecast data even if it is null value? - // So, perhaps do not check for null value. if (forecast != null) { savedInstanceState.putSerializable("Forecast", forecast); } @@ -249,7 +245,7 @@ public class SpecificFragment extends Fragment { R.drawable.weather_severe_alert); } - String description = this.getString(R.string.test_field_description_when_error); + String description = this.getString(R.string.text_field_description_when_error); if (forecast.getWeather().size() > 0) { description = forecast.getWeather().get(0).getDescription(); } diff --git a/app/src/main/java/de/example/exampletdd/service/PermanentStorage.java b/app/src/main/java/de/example/exampletdd/service/PermanentStorage.java index db64873..1c39e8f 100644 --- a/app/src/main/java/de/example/exampletdd/service/PermanentStorage.java +++ b/app/src/main/java/de/example/exampletdd/service/PermanentStorage.java @@ -16,10 +16,6 @@ import de.example.exampletdd.model.currentweather.Current; import de.example.exampletdd.model.forecastweather.Forecast; -/** - * TODO: show some error message when there is no enough space for saving files. :/ - * - */ public class PermanentStorage { private static final String TAG = "PermanentStorage"; private static final String CURRENT_DATA_FILE = "current.file"; diff --git a/app/src/main/res/layout-land/weather_specific_fragment.xml b/app/src/main/res/layout-land/weather_specific_fragment.xml index e1f17d9..86cd5d7 100644 --- a/app/src/main/res/layout-land/weather_specific_fragment.xml +++ b/app/src/main/res/layout-land/weather_specific_fragment.xml @@ -4,7 +4,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - - - mm 3h % No data available - no description available + no description available + no chosen location Settings @@ -78,6 +79,8 @@ Save Location Get Location You do not have enabled location. + Cannot get address. No geocoder available. + Mark your location About