WeatherInformation WP8: city and country by default.
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Sat, 16 Aug 2014 21:32:51 +0000 (23:32 +0200)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Sat, 16 Aug 2014 21:32:51 +0000 (23:32 +0200)
Default values: City not found/Country not found

WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs
WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml.cs
WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.Designer.cs
WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.es.resx
WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.es.xlf
WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.qps-ploc.xlf
WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.resx
WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs
WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs

index 8a009ce..005e5e4 100644 (file)
@@ -151,13 +151,13 @@ namespace WeatherInformation
                 country = PhoneApplicationService.Current.State["Country"] as string;
             }
             
-            if (!string.IsNullOrEmpty(JSONRemoteCurrentWeather) && !string.IsNullOrEmpty(JSONRemoteForecastWeather))
+            if (!string.IsNullOrEmpty(JSONRemoteCurrentWeather) && !string.IsNullOrEmpty(JSONRemoteForecastWeather) &&
+                !string.IsNullOrEmpty(city) && !string.IsNullOrEmpty(country))
             {
-                // TODO: I am repeating this code 2 times. What could I do to improve it?
                 var parser = new ServiceParser(new JsonParser());
                 weatherData = parser.WeatherDataParser(JSONRemoteForecastWeather, JSONRemoteCurrentWeather);
-                weatherData.City = city ?? "";
-                weatherData.Country = country ?? "";
+                weatherData.City = city;
+                weatherData.Country = country;
             }
 
             ApplicationDataObject = weatherData;
index 822847c..e2d936d 100644 (file)
@@ -99,7 +99,6 @@ namespace WeatherInformation
             {
                 if (eventData.Result.Count > 0)
                 {
-                    // TODO: What if there is no city or country. Is there null value or empty string?
                     MapAddress address = eventData.Result[0].Information.Address;
                     GeoCoordinate currentGeoCoordinate = eventData.Result[0].GeoCoordinate;
 
@@ -132,9 +131,15 @@ namespace WeatherInformation
             this.mapWeatherInformation.Center = geoCoordinate;
             this.mapWeatherInformation.ZoomLevel = 13;
 
-            // TODO: What if there is no city or country. Is there null value or empty string?
-            string cityCountry = String.Format(CultureInfo.InvariantCulture, "{0}, {1}", city, country);
-            this.LocationTextCityCountry.Text = cityCountry;
+            if (string.IsNullOrEmpty(city))
+            {
+                city = AppResources.DefaultCity;
+            }
+            if (string.IsNullOrEmpty(country))
+            {
+                country = AppResources.DefaultCountry;
+            }
+            this.LocationTextCityCountry.Text = String.Format(CultureInfo.InvariantCulture, "{0}, {1}", city, country);
             _city = city;
             _country = country;
             // Add the MapLayer to the Map.
index d05d572..35806cd 100644 (file)
@@ -106,6 +106,24 @@ namespace WeatherInformation.Resources {
         }
         
         /// <summary>
+        ///   Busca una cadena traducida similar a City not found.
+        /// </summary>
+        public static string DefaultCity {
+            get {
+                return ResourceManager.GetString("DefaultCity", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Busca una cadena traducida similar a Country not found.
+        /// </summary>
+        public static string DefaultCountry {
+            get {
+                return ResourceManager.GetString("DefaultCountry", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Busca una cadena traducida similar a City, country.
         /// </summary>
         public static string LocationPageSubTitle {
index 4841556..64e05c9 100644 (file)
     <value>Detección automática de la ubicación parece estar desactivada en el teléfono o el servicio no está disponible.</value>
     <comment>Message box error: while trying to get automatic current location</comment>
   </data>
+  <data name="DefaultCountry" xml:space="preserve">
+    <value>País no encontrado</value>
+    <comment>Country, default value.</comment>
+  </data>
+  <data name="DefaultCity" xml:space="preserve">
+    <value>Ciudad no encontrada</value>
+    <comment>City, default value.</comment>
+  </data>
 </root>
\ No newline at end of file
index 5325aac..5ca1bae 100644 (file)
           <target state="translated">Posición actual</target>
           <note from="MultilingualBuild" annotates="source" priority="2">Map page, button get the user's current location</note>
           </trans-unit>
+        <trans-unit id="Resx/DefaultCountry" translate="yes" xml:space="preserve">
+          <source>Country not found</source>
+          <target state="translated">País no encontrado</target>
+          <note from="MultilingualBuild" annotates="source" priority="2">Country, default value.</note>
+          </trans-unit>
+        <trans-unit id="Resx/DefaultCity" translate="yes" xml:space="preserve">
+          <source>City not found</source>
+          <target state="translated">Ciudad no encontrada</target>
+          <note from="MultilingualBuild" annotates="source" priority="2">City, default value.</note>
+          </trans-unit>
         <trans-unit id="Resx/SelectedDatePageMorning" translate="yes" xml:space="preserve">
           <source>MORNING</source>
           <target state="translated">MAÑANA</target>
index 6106e3e..d40fbf3 100644 (file)
           <target state="new">Current Location</target>
           <note from="MultilingualBuild" annotates="source" priority="2">Map page, button get the user's current location</note>
         </trans-unit>
+        <trans-unit id="Resx/DefaultCountry" translate="yes" xml:space="preserve">
+          <source>Country not found</source>
+          <target state="new">Country not found</target>
+          <note from="MultilingualBuild" annotates="source" priority="2">Country, default value.</note>
+        </trans-unit>
+        <trans-unit id="Resx/DefaultCity" translate="yes" xml:space="preserve">
+          <source>City not found</source>
+          <target state="new">City not found</target>
+          <note from="MultilingualBuild" annotates="source" priority="2">City, default value.</note>
+        </trans-unit>
         <trans-unit id="Resx/SelectedDatePageMorning" translate="yes" xml:space="preserve">
           <source>MORNING</source>
           <target state="new">MORNING</target>
index 65e2de4..232519c 100644 (file)
     <value>Current Location</value>
     <comment>Map page, button get the user's current location</comment>
   </data>
+  <data name="DefaultCity" xml:space="preserve">
+    <value>City not found</value>
+    <comment>City, default value.</comment>
+  </data>
+  <data name="DefaultCountry" xml:space="preserve">
+    <value>Country not found</value>
+    <comment>Country, default value.</comment>
+  </data>
 </root>
\ No newline at end of file
index f6bf463..8cb7891 100644 (file)
@@ -308,7 +308,6 @@ namespace WeatherInformation.ViewModels
                 NotifyPropertyChanged("CurrentSunSet");
                 NotifyPropertyChanged("CurrentSunSetText");
 
-                // TODO: What if address is not available? I should show something like "Address not found" by default...
                 string country = weatherData.Country;
                 string city = weatherData.City;
                 string cityCountry = String.Format(CultureInfo.InvariantCulture, "{0}, {1}", city, country);
index cb2e009..1e27dee 100644 (file)
@@ -222,7 +222,6 @@ namespace WeatherInformation.ViewModels
             this.SelectedDateNightTempUnits = selectedDateTempUnits;
             NotifyPropertyChanged("SelectedDateNightTempUnits");
 
-            // TODO: What if address is not available? I should show something like "Address not found" by default...
             string country = weatherData.Country;
             string city = weatherData.City;
             string cityCountry = String.Format(CultureInfo.InvariantCulture, "{0}, {1}", city, country);