Пример #1
0
  @Override
  public void onTextSet(String tag, String actualText) {

    if (ACTION_UPDATE_TAG.equals(tag)) {
      final ActionsManager actionsManager = new ActionsManager(this);
      final String timeStamp = TimeStampUtils.dateToTimeStamp(new Date());
      final UsersManager usersManager = new UsersManager(this);
      final UsersEntity currentUser = usersManager.getCurrentUser();

      ActionsEntity entity =
          new ActionsEntity(
              null,
              mIssuesEntity.getId(),
              timeStamp,
              "Atualização",
              actualText,
              currentUser.getId());
      actionsManager.refresh(entity);

    } else if (ACTION_CLOSE_TAG.equals(tag)) {
      final IssuesManager issuesManager = new IssuesManager(this);
      final ActionsManager actionsManager = new ActionsManager(this);
      final UsersManager usersManager = new UsersManager(this);
      final UsersEntity currentUser = usersManager.getCurrentUser();

      mIssuesEntity.setState(IssueUtils.STATE_CLOSED);
      issuesManager.refresh(mIssuesEntity);
      mImgFlagAndClockType.setImageResource(
          DashboardUtils.getImageResourceIdForStateFlagTypeAndClockType(
              mIssuesEntity.getState(),
              mIssuesEntity.getFlagType(),
              mIssuesEntity.getClockType(),
              true));

      final String timeStamp = TimeStampUtils.dateToTimeStamp(new Date());
      ActionsEntity entity =
          new ActionsEntity(
              null,
              mIssuesEntity.getId(),
              timeStamp,
              "Fechamento",
              actualText,
              currentUser.getId());
      actionsManager.refresh(entity);

    } else {
      throw new IllegalArgumentException("Invalid tag=" + tag);
    }
  }
Пример #2
0
  private void addActionAssignToOther() {
    final UsersManager usersManager = new UsersManager(this);
    final UsersEntity currentUser = usersManager.getCurrentUser();
    final IssuesManager issuesManager = new IssuesManager(this);
    final ActionsManager actionsManager = new ActionsManager(this);

    List<Long> excludeCandidates = new ArrayList<Long>();
    excludeCandidates.add(currentUser.getId());
    excludeCandidates.add(mIssuesEntity.getOwnerId());
    final List<String> candidates = usersManager.getAllUsersShortName(excludeCandidates);

    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
    adapter.addAll(candidates);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Atribuir a");
    builder.setSingleChoiceItems(
        adapter,
        0,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {

            final UsersEntity entity = usersManager.getUserFromShortName(candidates.get(which));
            mIssuesEntity.setOwnerId(entity.getId());
            issuesManager.refresh(mIssuesEntity);
            mTxtOwner.setText(candidates.get(which));

            final String timeStamp = TimeStampUtils.dateToTimeStamp(new Date());
            ActionsEntity actionsEntity =
                new ActionsEntity(
                    null,
                    mIssuesEntity.getId(),
                    timeStamp,
                    "Atribuição",
                    "Incidente atribuído a " + candidates.get(which),
                    currentUser.getId());
            actionsManager.refresh(actionsEntity);

            dialog.dismiss();
          }
        });
    builder.create().show();
  }
 public void newComment(View view) {
   final String newCommentString = mEdtNewComment.getText().toString().trim();
   if (!TextUtils.isEmpty(newCommentString)) {
     CommentsEntity entity =
         new CommentsEntity(
             null,
             mCurrentAction.getId(),
             TimeStampUtils.dateToTimeStamp(new Date()),
             newCommentString,
             mCurrentUser.getId());
     new CommentsManager(this).refresh(entity);
     finish();
   }
 }
Пример #4
0
 private void addActionAssignToMe() {
   final UsersManager usersManager = new UsersManager(this);
   final UsersEntity currentUser = usersManager.getCurrentUser();
   if (!currentUser.getId().equals(mIssuesEntity.getOwnerId())) {
     final IssuesManager issuesManager = new IssuesManager(this);
     mIssuesEntity.setOwnerId(currentUser.getId());
     issuesManager.refresh(mIssuesEntity);
     mTxtOwner.setText(currentUser.getShortName());
     final String timeStamp = TimeStampUtils.dateToTimeStamp(new Date());
     ActionsManager actionsManager = new ActionsManager(this);
     ActionsEntity actionsEntity =
         new ActionsEntity(
             null,
             mIssuesEntity.getId(),
             timeStamp,
             "Atribuição",
             currentUser.getShortName() + " assumiu o incidente",
             currentUser.getId());
     actionsManager.refresh(actionsEntity);
   }
 }