Example #1
0
 /** 查农历 */
 private void searchNongli() {
   if (System.currentTimeMillis() - mLastNongliUpdateTime < CustomConstant.QUARTER_HOUR) {
     DebugLog.d(TAG, "searchNongli: the time is too short");
     return;
   }
   BaseUtil.excute(
       new Runnable() {
         @Override
         public void run() {
           String nongli = RequestUtil.getInstance().searchNongli();
           if (!StringUtil.isEmpty(nongli)) {
             mLastNongliUpdateTime = System.currentTimeMillis();
             myHandler.sendMessage(
                 myHandler.obtainMessage(MessageWhat.NET_REQUEST_NONGLI, nongli));
           }
         }
       });
 }
Example #2
0
  private void searchWeather() {
    if (SharedPreferencesHelper.getInstance()
            .getString(SharedPreferencesHelper.WEATHER, "")
            .length()
        > 0) {
      if (System.currentTimeMillis() - mLastWeatherUpdateTime < CustomConstant.ONE_HOUR) {
        DebugLog.d(TAG, "searchWeather: the time is too short");
        return;
      }
    }
    if (null == BDMapListener.getInstance().getBdLocation()) {
      MapUtil.getInstance().getLocationClient().requestLocation();
      return;
    }

    BaseUtil.excute(
        new Runnable() {
          @Override
          public void run() {
            // 最多7天
            String weather =
                RequestUtil.getInstance()
                    .searchWeather(
                        7,
                        BDMapListener.getInstance().getBdLocation().getCity(),
                        ServerUtil.getInstance(mContext).getUserID());
            if (!StringUtil.isEmpty(weather)) {
              mLastWeatherUpdateTime = System.currentTimeMillis();
              myHandler.sendMessage(
                  myHandler.obtainMessage(MessageWhat.NET_REQUEST_WEATHER, weather));
            }
            // 获取空气质量
            String air =
                RequestUtil.getInstance()
                    .searchAir(BDMapListener.getInstance().getBdLocation().getCity());
            if (!StringUtil.isEmpty(air)) {
              myHandler.sendMessage(myHandler.obtainMessage(MessageWhat.NET_REQUEST_AIR, air));
            }
          }
        });
  }