Пример #1
0
  public void createWeatherView(JSONObject data, boolean createCache) {
    try {
      SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHH", Locale.US);
      df.setTimeZone(TimeZone.getTimeZone("GMT+0"));
      Date reportTime = df.parse(data.getString("init"));
      SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm 'UTC'Z", Locale.US);
      updatetimeTextView.setText(df2.format(reportTime));

      if (createCache) {
        cacheManager.createWeatherCache(longitude, latitude, reportTime, data.toString());
      }
      WeatherView wv = new WeatherView(longitude, latitude, reportTime, userPrefs.isUseCen());
      wv.setData(data);
      forecastScrollView.removeAllViews();
      forecastScrollView.addView(wv.getView(context));
      weatherUpdated = true;
      if (SettingsProvider.getInstance(context).isNewLaunch()) {
        Toast.makeText(getApplicationContext(), R.string.toast_cloud_info, Toast.LENGTH_LONG)
            .show();
      }
    } catch (ParseException e) {
      e.printStackTrace();
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
Пример #2
0
 private void loadSettings() {
   this.userPrefs = SettingsProvider.getInstance(context).getPrefs();
   this.latitude = userPrefs.getCurrentLocation().getLatitude();
   this.longitude = userPrefs.getCurrentLocation().getLongitude();
   this.locationName = userPrefs.getCurrentLocation().getName();
   this.locator =
       LocatorFactory.createLocator(
           this, userPrefs.isUseBaidu() ? LocatorType.BAIDU : LocatorType.GOOGLE);
   this.locator.setOnLocationUpdateListener(this);
   if (!locationName.equals(getText(R.string.text_current_location))) {
     locationTextView.setText(
         String.format("%s (%.3f, %.3f)", this.locationName, this.longitude, this.latitude));
   }
   this.templabelTextView.setText(
       String.format(
           getText(R.string.format_temperature).toString(), this.userPrefs.getTempUnitString()));
 }
Пример #3
0
 @Override
 public void onLocationUpdate(LocationInfo location, long costTime, int locator) {
   if (location == null) {
     return;
   }
   latitude = location.getLatitude();
   longitude = location.getLongitude();
   locationName = location.toString();
   userPrefs.setCurrentLocation(longitude, latitude, locationName);
   locationTextView.setText(String.format("%s (%.3f, %.3f)", locationName, longitude, latitude));
   weatherUpdated = false;
   satelliteUpdated = false;
   StatManager.getInstance().sendLocationStat(location, costTime, locator);
   updateButton.performClick();
 }