示例#1
0
 @Override
 public void run() {
   Date lastSync = new Date();
   ChangedCollections cols = getChangedCollections(lastSync);
   lastSync = cols.getLastSync();
   logger.info("DB lastSync: " + lastSync);
   while (!stopped) {
     try {
       Thread.sleep(freqMillisec);
     } catch (InterruptedException e) {
       stopped = true;
       continue;
     }
     synchronized (ccls) {
       if (ccls.isEmpty()) {
         continue;
       }
     }
     cols = getChangedCollections(lastSync);
     lastSync = cols.getLastSync();
     LinkedList<PushNotification> toNotify = new LinkedList<PushNotification>();
     synchronized (ccls) {
       for (ICollectionChangeListener ccl : ccls) {
         Set<SyncCollection> monitoredCollections = ccl.getMonitoredCollections();
         Set<SyncCollection> changes =
             getChangedCollections(ccl.getSession(), cols, monitoredCollections);
         if (!changes.isEmpty()) {
           toNotify.add(new PushNotification(changes, ccl));
         }
       }
     }
     for (PushNotification pn : toNotify) {
       pn.emit();
     }
   }
 }
  public void ChangeParams(
      String login, String password, Activity activity, OnComplete onComplete) {
    boolean status = GetStatus();
    if (login.isEmpty() || password.isEmpty()) {
      onComplete.Error(activity.getBaseContext().getString(R.string.error_empty_field));
    } else {
      options.setParams(login, password);

      if (status) {
        options.setNotificationId("");
        onComplete.Complete();
      } else {
        pushNotification.register(
            activity, Options.SENDER_ID, options.getNotificationId(), onComplete);
      }
    }
  }