@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); } }
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); } }
@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); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.issue_activity); final Long id; if (savedInstanceState != null) { id = savedInstanceState.getLong(ISSUE_ID_KEY); } else { id = getIntent().getExtras().getLong(ISSUE_ID_KEY); } final IssuesManager manager = new IssuesManager(this); mIssuesEntity = manager.issuesFromId(id); final ActionBar actionBar = getActionBar(); //noinspection ConstantConditions actionBar.setDisplayHomeAsUpEnabled(true); mAdapter = new ActionsAdapter(this); getLoaderManager().restartLoader(ACTIONS_LOADER_ID, null, this); bindScreen(); refreshScreen(); }