Beispiel #1
0
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    int count = lv.getChildCount();
    for (int i = 0; i < count; i++) {
      LinearLayout linearLayout = (LinearLayout) lv.getChildAt(i);
      LinearLayout linearLayoutChild = (LinearLayout) linearLayout.getChildAt(0);
      EditText editText = (EditText) linearLayoutChild.getChildAt(1);
      if (editText.isShown()) {
        String value = editText.getText().toString();
        EnterCompanyListAdapter.ViewHolder viewHolder = (ViewHolder) linearLayout.getTag();
        viewHolder.fieldAndAnswer.set(1, value);
      }
    }

    @SuppressWarnings("unused")
    int count2 = epla.getCount();
    for (int i = 0; i < epla.getCount(); i++) {
      @SuppressWarnings("unchecked")
      ArrayList<String> fieldAndAnswer = (ArrayList<String>) epla.getItem(i);
      String fieldName = fieldAndAnswer.get(0);
      String value = fieldAndAnswer.get(1);
      company.set(fieldName, value);
    }

    outState.putSerializable("company", company);
    outState.putSerializable("person", person);
    outState.putBoolean("personLinked", personLinked);
  }
Beispiel #2
0
  public void commitCompany(View arg0) {

    // print out all of the properties of this Company
    Log.v("TeamLeader", "results \n" + company.toString());

    // go through and make sure we got all of the showing fields entered
    for (int i = 0; i < lv.getChildCount(); i++) {
      LinearLayout tempLL = (LinearLayout) lv.getChildAt(i);
      LinearLayout innerLL = (LinearLayout) tempLL.getChildAt(0);
      EditText tempEditText = (EditText) innerLL.getChildAt(1);
      EnterCompanyListAdapter.ViewHolder viewHolder = (ViewHolder) tempLL.getTag();
      ((ArrayList<String>) (viewHolder.fieldAndAnswer)).remove(1);
      viewHolder.fieldAndAnswer.add(tempEditText.getText().toString());
    }

    for (int i = 0; i < epla.getCount(); i++) {

      //			LinearLayout tempLL = (LinearLayout)lv.getChildAt(i);
      //			LinearLayout innerLL = (LinearLayout)tempLL.getChildAt(0);
      //			EditText tempEditText = (EditText)innerLL.getChildAt(1);

      @SuppressWarnings("unchecked")
      ArrayList<String> fieldAndAnswer = (ArrayList<String>) epla.getItem(i);
      String fieldName = fieldAndAnswer.get(0);
      String answer = fieldAndAnswer.get(1);
      company.set(fieldName, answer);
    }

    progressDialog = new ProgressDialog(this);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage("Communicating with server");
    progressDialog.setCancelable(true);

    // send the instruction to add the Company with the TeamLeader API

    RESTfulAPI restAPI = new RESTfulAPI(this, null, progressDialog);
    try {
      personLinked = false;
      restAPI.addCompany(company);
      if (!personLinked && person != null) finish();
    } catch (IncompleteCompanyException e) {
      Toast.makeText(this, "Incomplete Company: required - name ", Toast.LENGTH_LONG).show();
    }
  }