示例#1
0
  /*
   * Get the JSON array containing the details of all the triggers
   * which have activated a given survey at the moment.
   */
  public static JSONArray getActiveTriggerInfo(Context context, String campaignUrn, String survey) {
    JSONObject jInfo = new JSONObject();
    JSONArray jTrigs = new JSONArray();

    TriggerDB db = new TriggerDB(context);
    db.open();

    Cursor c = db.getAllTriggers(campaignUrn);
    if (c.moveToFirst()) {
      do {
        if (getActiveSurveys(context, c).contains(survey)) {
          addTriggerInfoToArray(context, c, jTrigs);
        }

      } while (c.moveToNext());
    }
    c.close();
    db.close();

    try {
      jInfo.put(KEY_ACTIVE_TRIGGERS, jTrigs);
    } catch (JSONException e) {
      return null;
    }

    return jTrigs;
  }
示例#2
0
  /*
   * Get the list of all surveys active at the moment. This
   * function creates a set of all active surveys from all
   * active triggers.
   *
   * This function is used by the Notifier to prepare the
   * notification item.
   */
  public static Set<String> getAllActiveSurveys(Context context, String campaignUrn) {
    HashSet<String> actSurveys = new HashSet<String>();

    TriggerDB db = new TriggerDB(context);
    db.open();

    Cursor c = db.getAllTriggers(campaignUrn);
    if (c.moveToFirst()) {
      do {

        actSurveys.addAll(getActiveSurveys(context, c));

      } while (c.moveToNext());
    }
    c.close();
    db.close();

    return actSurveys;
  }