/** * Use lat & lon pair to query Yahoo weather apis for weather information. Querying will be run on * a separated thread to accessing Yahoo's apis. When it is completed, a callback will be fired. * See {@link YahooWeatherInfoListener} for detail. * * @param context app's context * @param lat A string of latitude value * @param lon A string of longitude value * @param result A {@link WeatherInfo} instance */ public void queryYahooWeatherByLatLon( final Context context, final String lat, final String lon, final YahooWeatherInfoListener result) { YahooWeatherLog.d("query yahoo weather by lat lon"); mContext = context; if (!NetworkUtils.isConnected(context)) { if (mExceptionListener != null) mExceptionListener.onFailConnection(new Exception("Network is not avaiable")); return; } mWeatherInfoResult = result; final WeatherQueryByLatLonTask task = new WeatherQueryByLatLonTask(); task.execute(new String[] {lat, lon}); }
@Override public void gotLocation(Location location) { YahooWeatherLog.d( "gotLocation, location=" + location + ", lat=" + location.getLatitude() + ",lon=" + location.getLongitude()); if (location == null) { if (mExceptionListener != null) mExceptionListener.onFailFindLocation(new Exception("Location cannot be found")); return; } final String lat = String.valueOf(location.getLatitude()); final String lon = String.valueOf(location.getLongitude()); final WeatherQueryByLatLonTask task = new WeatherQueryByLatLonTask(); task.execute(new String[] {lat, lon}); }