Exemplo n.º 1
0
  // if no common causes or no causes i am supporting
  void noCommonOrNoMyCauses() {
    int iNoOfBusinessOrgs = mSelectedBussResult.getOrganizations().size();

    if (iNoOfBusinessOrgs == 1) {
      CauseResult cause =
          new CauseResult(
              mSelectedBussResult.getOrganizations().get(0).get("id"),
              mSelectedBussResult.getOrganizations().get(0).get("name"),
              "false");
      gotoCheckinPage(cause);

    } else if (iNoOfBusinessOrgs > 1) {
      List<CauseResult> mCommonCauses = new ArrayList<CauseResult>();
      for (int i = 0; i < iNoOfBusinessOrgs; i++) {
        CauseResult cause =
            new CauseResult(
                mSelectedBussResult.getOrganizations().get(i).get("id"),
                mSelectedBussResult.getOrganizations().get(i).get("name"),
                "false");
        mCommonCauses.add(cause);
      }
      gotoOrganizationPage(mCommonCauses);
    } else {
      ShowMessageBox("Business List", "No Organizations supported by this business");
    }
    removeDialog(0);
  }
Exemplo n.º 2
0
  public void getCommonCauses() {
    List<CauseResult> mMyCauses = null;
    mMyCauses = fetchMyCausesFromDB();
    List<CauseResult> mCommonCauses = new ArrayList<CauseResult>();
    int iMatchCount = 0;

    // check common causes
    if (mMyCauses == null) {
      noCommonOrNoMyCauses();
    } else {
      int iNoOfBusinessOrgs = mSelectedBussResult.getOrganizations().size();
      int iNoOfMyCauses = mMyCauses.size();
      for (int i = 0; i < iNoOfBusinessOrgs; i++) {
        for (int j = 0; j < iNoOfMyCauses; j++) {
          if (mSelectedBussResult
                  .getOrganizations()
                  .get(i)
                  .get("id")
                  .compareTo(mMyCauses.get(j).getId().toString())
              == 0) {
            Log.i(
                "Common cause",
                mSelectedBussResult.getOrganizations().get(i).get("name")
                    + mMyCauses.get(j).getName());
            mCommonCauses.add(mMyCauses.get(j));
            iMatchCount++;
            break;
          }
        }
      }

      if (iMatchCount == 0) {
        noCommonOrNoMyCauses();
      } else if (iMatchCount == 1) {
        if (mCommonCauses.size() > 0) gotoCheckinPage(mCommonCauses.get(0));
      } else if (iMatchCount > 1) {
        gotoOrganizationPage(mCommonCauses);
      }
    }
  }