示例#1
0
  public static ActFmSyncThread initializeSyncComponents(
      TaskDao taskDao,
      TagDataDao tagDataDao,
      UserActivityDao userActivityDao,
      TaskAttachmentDao taskAttachmentDao,
      TaskListMetadataDao taskListMetadataDao) {
    if (instance == null) {
      synchronized (ActFmSyncThread.class) {
        if (instance == null) {
          List<ClientToServerMessage<?>> syncQueue =
              Collections.synchronizedList(new LinkedList<ClientToServerMessage<?>>());
          ActFmSyncMonitor monitor = ActFmSyncMonitor.getInstance();
          ActFmSyncWaitingPool waitingPool = ActFmSyncWaitingPool.getInstance();

          instance = new ActFmSyncThread(syncQueue, monitor);

          taskDao.addListener(new SyncDatabaseListener<Task>(instance, ModelType.TYPE_TASK));
          tagDataDao.addListener(new SyncDatabaseListener<TagData>(instance, ModelType.TYPE_TAG));
          userActivityDao.addListener(
              new SyncDatabaseListener<UserActivity>(instance, ModelType.TYPE_ACTIVITY));
          taskAttachmentDao.addListener(
              new SyncDatabaseListener<TaskAttachment>(instance, ModelType.TYPE_ATTACHMENT));
          taskListMetadataDao.addListener(
              new TaskListMetadataSyncDatabaseListener(
                  instance, waitingPool, ModelType.TYPE_TASK_LIST_METADATA));

          instance.startSyncThread();
        }
      }
    }
    return instance;
  }
示例#2
0
  @SuppressWarnings("nls")
  private void addComment(
      String message, String actionCode, String uuid, String title, boolean usePicture) {
    // Allow for users to just add picture
    if (TextUtils.isEmpty(message) && usePicture) {
      message = " ";
    }
    UserActivity userActivity = new UserActivity();
    userActivity.setValue(UserActivity.MESSAGE, message);
    userActivity.setValue(UserActivity.ACTION, actionCode);
    userActivity.setValue(UserActivity.USER_UUID, Task.USER_ID_SELF);
    userActivity.setValue(UserActivity.TARGET_ID, uuid);
    userActivity.setValue(UserActivity.TARGET_NAME, title);
    userActivity.setValue(UserActivity.CREATED_AT, DateUtilities.now());
    if (usePicture && pendingCommentPicture != null) {
      JSONObject pictureJson =
          RemoteModel.PictureHelper.savePictureJson(activity, pendingCommentPicture);
      if (pictureJson != null) userActivity.setValue(UserActivity.PICTURE, pictureJson.toString());
    }

    userActivityDao.createNew(userActivity);
    if (commentField != null) commentField.setText(""); // $NON-NLS-1$

    pendingCommentPicture = usePicture ? null : pendingCommentPicture;
    if (usePicture) {
      if (activity != null)
        activity.getIntent().removeExtra(TaskEditFragment.TOKEN_PICTURE_IN_PROGRESS);
    }
    if (pictureButton != null) pictureButton.setImageResource(cameraButton);
    StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMMENT);

    setUpListAdapter();
    for (UpdatesChangedListener l : listeners) {
      l.commentAdded();
    }
  }