コード例 #1
0
  // 加载天气
  private void loadWeather() {
    try {
      setWeatherFromBaiduWeatherListVo(RemoteImpl.getInstance().getBaiduWeatherListVo(true));
    } catch (Exception e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    new AsyncTask<Void, Void, BaiduWeatherListVo>() {

      @Override
      protected BaiduWeatherListVo doInBackground(Void... params) {
        // TODO Auto-generated method stub
        try {
          return RemoteImpl.getInstance().getBaiduWeatherListVo(false);
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          return null;
        }
      }

      protected void onPostExecute(BaiduWeatherListVo result) {
        setWeatherFromBaiduWeatherListVo(result);
      }
    }.execute();
  }
コード例 #2
0
  private void loadFlightTime() {

    try {
      if (flightVo.getLeave()) {
        setViewFromFlightListVo(
            RemoteImpl.getInstance()
                .searchFlight(true, FlightActivity.DFLIGHT_NUMBER, flightVo.getFlightNumber()));
      } else {
        setViewFromFlightListVo(
            RemoteImpl.getInstance()
                .searchFlight(true, FlightActivity.AFLIGHT_NUMBER, flightVo.getFlightNumber()));
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    new ItktOtherAsyncTask<Void, Void, FlightListVo>() {

      @Override
      public FlightListVo before(Void... params) throws Exception {
        if (flightVo.getLeave()) {
          return RemoteImpl.getInstance()
              .searchFlight(false, FlightActivity.DFLIGHT_NUMBER, flightVo.getFlightNumber());
        } else {
          return RemoteImpl.getInstance()
              .searchFlight(false, FlightActivity.AFLIGHT_NUMBER, flightVo.getFlightNumber());
        }
      }

      @Override
      public void after(FlightListVo result) {
        if (result != null && result.getAir() != null && !result.getAir().isEmpty()) {
          setViewFromFlightListVo(result);
        }
      }

      @Override
      public void exception() {
        // TODO Auto-generated method stub

      }
    }.execute();
  }