Beispiel #1
0
  public void refreshData() {
    if (!task.containsNonNullValue(Task.UUID)) {
      return;
    }

    ActFmSyncThread.getInstance()
        .enqueueMessage(
            new BriefMe<UserActivity>(
                UserActivity.class,
                null,
                task.getValue(Task.USER_ACTIVITIES_PUSHED_AT),
                BriefMe.TASK_ID_KEY,
                task.getUuid()),
            callback);
    ActFmSyncThread.getInstance()
        .enqueueMessage(
            new BriefMe<TaskAttachment>(
                TaskAttachment.class,
                null,
                task.getValue(Task.ATTACHMENTS_PUSHED_AT),
                BriefMe.TASK_ID_KEY,
                task.getUuid()),
            new SyncMessageCallback() {
              @Override
              public void runOnSuccess() {
                if (activity != null) {
                  activity.runOnUiThread(
                      new Runnable() {
                        @Override
                        public void run() {
                          TaskEditFragment tef = activity.getTaskEditFragment();
                          if (tef != null) {
                            tef.refreshFilesDisplay();
                          }
                        }
                      });
                }
              }

              @Override
              public void runOnErrors(List<JSONArray> errors) {
                /**/
              }
            });
    new FetchHistory<Task>(
            taskDao,
            Task.HISTORY_FETCH_DATE,
            Task.HISTORY_HAS_MORE,
            NameMaps.TABLE_ID_TASKS,
            task.getUuid(),
            task.getValue(Task.TITLE),
            task.getValue(Task.HISTORY_FETCH_DATE),
            0,
            callback)
        .execute();
  }
Beispiel #2
0
 @Override
 public void onReceive(Context context, Intent intent) {
   lastSyncFromNetworkChange = Preferences.getLong(PREF_LAST_SYNC_FROM_NETWORK_CHANGE, 0L);
   if (DateUtilities.now() - lastSyncFromNetworkChange > DateUtilities.ONE_MINUTE * 10) {
     NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
     if (info != null
         && NetworkInfo.State.CONNECTED.equals(info.getState())
         && PluginServices.getActFmPreferenceService().isLoggedIn()) {
       ActFmSyncThread syncThread = ActFmSyncThread.getInstance();
       syncThread.repopulateQueueFromOutstandingTables();
       Preferences.setLong(PREF_LAST_SYNC_FROM_NETWORK_CHANGE, DateUtilities.now());
     }
   }
 }