コード例 #1
0
  void processPendingScheduleUpdates() {
    try {
      // Operate on a local copy of the schedule update list so as not to block
      // the main thread adding to this list
      List<Intent> scheduleUpdates = new ArrayList<Intent>();
      synchronized (mScheduleUpdates) {
        scheduleUpdates.addAll(mScheduleUpdates);
        mScheduleUpdates.clear();
      }

      SyncHelper syncHelper = new SyncHelper(this);
      for (Intent updateIntent : scheduleUpdates) {
        String sessionId = updateIntent.getStringExtra(EXTRA_SESSION_ID);
        boolean inSchedule = updateIntent.getBooleanExtra(EXTRA_IN_SCHEDULE, false);
        LOGI(
            TAG,
            "addOrRemoveSessionFromSchedule:"
                + " sessionId="
                + sessionId
                + " inSchedule="
                + inSchedule);
        syncHelper.addOrRemoveSessionFromSchedule(this, sessionId, inSchedule);
      }
    } catch (IOException e) {
      // TODO: do something useful here, like revert the changes locally in the
      // content provider to maintain client/server sync
      LOGE(TAG, "Error processing schedule update", e);
    }
  }