Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cu_te);

    mTitleView = (TextInputEditText) findViewById(R.id.cu_title);
    mDescriptionView = (TextInputEditText) findViewById(R.id.cu_description);
    mDateView = (SpinnerLikeDateSelect) findViewById(R.id.cu_date);
    mSgroupView = (UtuSpinner<Sgroup>) findViewById(R.id.cu_sgroup_selector);
    mSubjectView = (UtuSpinner<Subject>) findViewById(R.id.cu_subject_selector);
    mAISelectView =
        (SpinnerLikeAdditionalInfoDialoger) findViewById(R.id.cu_additional_info_select);
    mSubmitView = (Button) findViewById(R.id.cu_submit);

    mDateView.setFragmentManager(getFragmentManager());
    mAISelectView.setFragmentManager(getFragmentManager());

    int itemId = getIntent().getIntExtra("item_id", -1);
    if (itemId != -1) {
      mLoaded = CollectionUtil.findById(Bullshit.dataLoader.getTasksList(), itemId);
      mTitleView.setText(mLoaded.getTitle());
      mDescriptionView.setText(mLoaded.getDescription());
      mDateView.setSelectedDate(mLoaded.getDate());
      mSgroupView.setItem(mLoaded.getSgroup());
      mSubjectView.setItem(mLoaded.getSubject());

      ArrayList<Integer> selectedInfoIds = new ArrayList<>();
      List<AdditionalInfo> selectedInfos = mLoaded.getAdditionalInfos();
      for (AdditionalInfo info : selectedInfos) selectedInfoIds.add(info.getId());
      mAISelectView.setSelectedAIIds(selectedInfoIds);

      setTitle(
          TextUtil.capitalize(
              getString(R.string.operation_edit_x, getString(R.string.item_task)).toLowerCase()));
    } else {
      setTitle(
          TextUtil.capitalize(
              getString(R.string.operation_new_x, getString(R.string.item_task)).toLowerCase()));
    }

    mSubmitView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mTitleView.setError(null);
            if (TextUtils.isEmpty(mTitleView.getText())) {
              mTitleView.setError(getString(R.string.error_field_required));
              mTitleView.requestFocus();
            } else new Submitter(getApplicationContext()).execute();
          }
        });
  }
Esempio n. 2
0
    @Override
    protected void onPreExecute() {
      mTitle = mTitleView.getText().toString();
      mDescription = mDescriptionView.getText().toString();
      mDate = mDateView.getSelectedDate();
      mSgroup = mSgroupView.getItem();
      mSubject = mSubjectView.getItem();
      mSelectedInfos =
          CollectionUtil.findByIds(
              Bullshit.dataLoader.getAdditionalInfosList(), mAISelectView.getSelectAIIds());

      finish();
    }