Пример #1
0
  private void firstEnter() {

    if (mLiteBlueService != null) {

      // 确认蓝牙
      if (!mLiteBlueService.isEnable()) {
        showIosDialog();
      } else {
        if (mLiteBlueService.isBinded()) { // 当本地绑定时,开启搜索。
          mLiteBlueService.startScanUsePeriodScanCallback();
        }
      }
    }

    // 加载天气
    LoadWeatherJsonTask taskFirst = new LoadWeatherJsonTask(MSG_FORECAST, this, mHandler);
    taskFirst.setOnProgressChangeListener(this);
    String city = (String) SharedPreferenceUtil.get(this, Constant.SHARE_PLACE, "beijing");
    if (!city.equals("")) {
      taskFirst.execute(YahooUtil.getForecastUrl(city));
      tvWeatherAddress.setText(city);
    } else {

    }
  }
Пример #2
0
 /**
  * 解析天气并更新视图
  *
  * @param json
  */
 private void parseForecastJsonAndUpdateView(String json) {
   if (json == null) {
     return;
   }
   if (json.trim().equals("")) {
     return;
   }
   try {
     ConditionWeather weather = YahooUtil.parseConditionWeatherFromJson(json);
     tvWeatherText.setText(weather.getText());
     tvWeatherTemp.setText(weather.getTemp() + "度");
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }