コード例 #1
0
  @Override
  public void onUpdate(SyncAccount syncAccount, Map<String, Object> originalValues) {

    if (!originalValues.containsKey("active")) {
      return;
    }

    List<Long> activeSyncAccountIds = SyncAccountService.getActiveSyncAccountIds();

    if ((Boolean) originalValues.get("active")) {
      activeSyncAccountIds.remove(syncAccount.getSyncAccountId());

      try {
        SyncEngine.cancelSyncAccountTasks(syncAccount.getSyncAccountId());
      } catch (Exception e) {
        _logger.error(e.getMessage(), e);
      }
    } else {
      activeSyncAccountIds.add(syncAccount.getSyncAccountId());

      try {
        SyncEngine.scheduleSyncAccountTasks(syncAccount.getSyncAccountId());
      } catch (Exception e) {
        _logger.error(e.getMessage(), e);
      }
    }

    SyncAccountService.setActiveSyncAccountIds(activeSyncAccountIds);
  }
コード例 #2
0
  @Override
  public void onRemove(SyncAccount syncAccount) {
    List<Long> activeSyncAccountIds = SyncAccountService.getActiveSyncAccountIds();

    activeSyncAccountIds.remove(syncAccount.getSyncAccountId());

    SyncAccountService.setActiveSyncAccountIds(activeSyncAccountIds);

    try {
      SyncEngine.cancelSyncAccountTasks(syncAccount.getSyncAccountId());
    } catch (Exception e) {
      _logger.error(e.getMessage(), e);
    }
  }