Пример #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 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);
   }
 }
Пример #3
0
  @Override
  public void onStringSelected(String tag, int chosenIndex) {
    if (ACTION_TYPE_DIALOG.equals(tag)) {
      addNewAction(chosenIndex);
    } else if (CHANGE_FLAG_DIALOG.equals(tag)) {
      final IssuesManager issuesManager = new IssuesManager(this);
      final ActionsManager actionsManager = new ActionsManager(this);
      final UsersManager usersManager = new UsersManager(this);
      final int oldFlagType = mIssuesEntity.getFlagType();
      mIssuesEntity.setFlagType(chosenIndex);
      issuesManager.refresh(mIssuesEntity);
      mImgFlagAndClockType.setImageResource(
          DashboardUtils.getImageResourceIdForStateFlagTypeAndClockType(
              mIssuesEntity.getState(),
              mIssuesEntity.getFlagType(),
              mIssuesEntity.getClockType(),
              true));

      final String timeStamp = TimeStampUtils.dateToTimeStamp(new Date());
      final String[] flagMeaningArray = getResources().getStringArray(R.array.flags_meaning_list);
      ActionsEntity actionsEntity =
          new ActionsEntity(
              null,
              mIssuesEntity.getId(),
              timeStamp,
              "Mudança de importância",
              "Incidente mudou de '"
                  + flagMeaningArray[oldFlagType]
                  + "' para '"
                  + flagMeaningArray[mIssuesEntity.getFlagType()]
                  + "'",
              usersManager.getCurrentUser().getId());
      actionsManager.refresh(actionsEntity);
    } else {
      throw new IllegalArgumentException("Invalid tag=" + tag);
    }
  }