Exemplo n.º 1
0
 /**
  * Use a name of place 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 cityAreaOrLocation A city name, like "Shanghai"; an area name, like "Mountain View"; a
  *     pair of city and country, like "Tokyo, Japan"; a location or view spot, like "Eiffel
  *     Tower"; Yahoo's apis will find a closest position for you.
  * @param result A {@link WeatherInfo} instance.
  */
 public void queryYahooWeatherByPlaceName(
     final Context context,
     final String cityAreaOrLocation,
     final YahooWeatherInfoListener result) {
   YahooWeatherLog.d("query yahoo weather by name of place");
   mContext = context;
   if (!NetworkUtils.isConnected(context)) {
     if (mExceptionListener != null)
       mExceptionListener.onFailConnection(new Exception("Network is not avaiable"));
     return;
   }
   final String convertedlocation = AsciiUtils.convertNonAscii(cityAreaOrLocation);
   mWeatherInfoResult = result;
   final WeatherQueryByPlaceTask task = new WeatherQueryByPlaceTask();
   task.execute(new String[] {convertedlocation});
 }