/** * This method uses the URI scheme for showing a location found on a map in conjunction with * an implicit Intent. This super-handy intent is detailed in the "Common Intents" page of * Android's developer site: * * @see "http://developer.android.com/guide/components/intents-common.html#Maps" * <p> * Protip: Hold Command on Mac or Control on Windows and click that link to automagically * open the Common Intents page */ private void openLocationInMap() { String addressString = SunshinePreferences.getPreferredWeatherLocation(this); Uri geoLocation = Uri.parse("geo:0,0?q=" + addressString); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(geoLocation); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!"); } }
/** * This method uses the URI scheme for showing a location found on a map in conjunction with * an implicit Intent. This super-handy intent is detailed in the "Common Intents" page of * Android's developer site: * * @see "http://developer.android.com/guide/components/intents-common.html#Maps" * <p> * Protip: Hold Command on Mac or Control on Windows and click that link to automagically * open the Common Intents page */ private void openLocationInMap() { String addressString = SunshinePreferences.getPreferredWeatherLocation(this); Uri geoLocation = Uri.parse("geo:0,0?q=" + addressString); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(geoLocation); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!"); } }
/** * This method uses the URI scheme for showing a location found on a map in conjunction with * an implicit Intent. This super-handy intent is detailed in the "Common Intents" page of * Android's developer site: * * @see "http://developer.android.com/guide/components/intents-common.html#Maps" * <p> * Protip: Hold Command on Mac or Control on Windows and click that link to automagically * open the Common Intents page */ private void openLocationInMap() { String addressString = SunshinePreferences.getPreferredWeatherLocation(this); Uri geoLocation = Uri.parse("geo:0,0?q=" + addressString); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(geoLocation); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!"); } }
/** * This method uses the URI scheme for showing a location found on a map in conjunction with * an implicit Intent. This super-handy intent is detailed in the "Common Intents" page of * Android's developer site: * * @see "http://developer.android.com/guide/components/intents-common.html#Maps" * <p> * Protip: Hold Command on Mac or Control on Windows and click that link to automagically * open the Common Intents page */ private void openLocationInMap() { String addressString = SunshinePreferences.getPreferredWeatherLocation(this); Uri geoLocation = Uri.parse("geo:0,0?q=" + addressString); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(geoLocation); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!"); } }
/** * This method uses the URI scheme for showing a location found on a map in conjunction with * an implicit Intent. This super-handy intent is detailed in the "Common Intents" page of * Android's developer site: * * @see "http://developer.android.com/guide/components/intents-common.html#Maps" * <p> * Protip: Hold Command on Mac or Control on Windows and click that link to automagically * open the Common Intents page */ private void openLocationInMap() { String addressString = SunshinePreferences.getPreferredWeatherLocation(this); Uri geoLocation = Uri.parse("geo:0,0?q=" + addressString); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(geoLocation); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!"); } }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { showWeatherDataView(); String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { showWeatherDataView(); String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { showWeatherDataView(); String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { showWeatherDataView(); String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { showWeatherDataView(); String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { showWeatherDataView(); String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This method will get the user's preferred location for weather, and then tell some * background method to get the weather data in the background. */ private void loadWeatherData() { // COMPLETED (20) Call showWeatherDataView before executing the AsyncTask showWeatherDataView(); String location = SunshinePreferences.getPreferredWeatherLocation(this); new FetchWeatherTask().execute(location); }
/** * This is the method of the AsyncTaskLoader that will load and parse the JSON data * from OpenWeatherMap in the background. * * @return Weather data from OpenWeatherMap as an array of Strings. * null if an error occurs */ @Override public String[] loadInBackground() { String locationQuery = SunshinePreferences .getPreferredWeatherLocation(MainActivity.this); URL weatherRequestUrl = NetworkUtils.buildUrl(locationQuery); try { String jsonWeatherResponse = NetworkUtils .getResponseFromHttpUrl(weatherRequestUrl); String[] simpleJsonWeatherData = OpenWeatherJsonUtils .getSimpleWeatherStringsFromJson(MainActivity.this, jsonWeatherResponse); return simpleJsonWeatherData; } catch (Exception e) { e.printStackTrace(); return null; } }
/** * This is the method of the AsyncTaskLoader that will load and parse the JSON data * from OpenWeatherMap in the background. * * @return Weather data from OpenWeatherMap as an array of Strings. * null if an error occurs */ @Override public String[] loadInBackground() { String locationQuery = SunshinePreferences .getPreferredWeatherLocation(MainActivity.this); URL weatherRequestUrl = NetworkUtils.buildUrl(locationQuery); try { String jsonWeatherResponse = NetworkUtils .getResponseFromHttpUrl(weatherRequestUrl); String[] simpleJsonWeatherData = OpenWeatherJsonUtils .getSimpleWeatherStringsFromJson(MainActivity.this, jsonWeatherResponse); return simpleJsonWeatherData; } catch (Exception e) { e.printStackTrace(); return null; } }
/** * This is the method of the AsyncTaskLoader that will load and parse the JSON data * from OpenWeatherMap in the background. * * @return Weather data from OpenWeatherMap as an array of Strings. * null if an error occurs */ @Override public String[] loadInBackground() { String locationQuery = SunshinePreferences .getPreferredWeatherLocation(MainActivity.this); URL weatherRequestUrl = NetworkUtils.buildUrl(locationQuery); try { String jsonWeatherResponse = NetworkUtils .getResponseFromHttpUrl(weatherRequestUrl); String[] simpleJsonWeatherData = OpenWeatherJsonUtils .getSimpleWeatherStringsFromJson(MainActivity.this, jsonWeatherResponse); return simpleJsonWeatherData; } catch (Exception e) { e.printStackTrace(); return null; } }
/** * Retrieves the proper URL to query for the weather data. The reason for both this method as * well as {@link #buildUrlWithLocationQuery(String)} is two fold. * <p> * 1) You should be able to just use one method when you need to create the URL within the * app instead of calling both methods. * 2) Later in Sunshine, you are going to add an alternate method of allowing the user * to select their preferred location. Once you do so, there will be another way to form * the URL using a latitude and longitude rather than just a location String. This method * will "decide" which URL to build and return it. * * @param context used to access other Utility methods * @return URL to query weather service */ public static URL getUrl(Context context) { if (SunshinePreferences.isLocationLatLonAvailable(context)) { double[] preferredCoordinates = SunshinePreferences.getLocationCoordinates(context); double latitude = preferredCoordinates[0]; double longitude = preferredCoordinates[1]; return buildUrlWithLatitudeLongitude(latitude, longitude); } else { String locationQuery = SunshinePreferences.getPreferredWeatherLocation(context); return buildUrlWithLocationQuery(locationQuery); } }
/** * Retrieves the proper URL to query for the weather data. The reason for both this method as * well as {@link #buildUrlWithLocationQuery(String)} is two fold. * <p> * 1) You should be able to just use one method when you need to create the URL within the * app instead of calling both methods. * 2) Later in Sunshine, you are going to add an alternate method of allowing the user * to select their preferred location. Once you do so, there will be another way to form * the URL using a latitude and longitude rather than just a location String. This method * will "decide" which URL to build and return it. * * @param context used to access other Utility methods * @return URL to query weather service */ public static URL getUrl(Context context) { if (SunshinePreferences.isLocationLatLonAvailable(context)) { double[] preferredCoordinates = SunshinePreferences.getLocationCoordinates(context); double latitude = preferredCoordinates[0]; double longitude = preferredCoordinates[1]; return buildUrlWithLatitudeLongitude(latitude, longitude); } else { String locationQuery = SunshinePreferences.getPreferredWeatherLocation(context); return buildUrlWithLocationQuery(locationQuery); } }
/** * Retrieves the proper URL to query for the weather data. The reason for both this method as * well as {@link #buildUrlWithLocationQuery(String)} is two fold. * <p> * 1) You should be able to just use one method when you need to create the URL within the * app instead of calling both methods. * 2) Later in Sunshine, you are going to add an alternate method of allowing the user * to select their preferred location. Once you do so, there will be another way to form * the URL using a latitude and longitude rather than just a location String. This method * will "decide" which URL to build and return it. * * @param context used to access other Utility methods * @return URL to query weather service */ public static URL getUrl(Context context) { if (SunshinePreferences.isLocationLatLonAvailable(context)) { double[] preferredCoordinates = SunshinePreferences.getLocationCoordinates(context); double latitude = preferredCoordinates[0]; double longitude = preferredCoordinates[1]; return buildUrlWithLatitudeLongitude(latitude, longitude); } else { String locationQuery = SunshinePreferences.getPreferredWeatherLocation(context); return buildUrlWithLocationQuery(locationQuery); } }