private Event cursorToEvent(Cursor cursor) {
    Event event = new EventImpl();
    event.setID(cursor.getLong(0));

    long ts = cursor.getLong(1);
    Timestamp timestamp = new Timestamp(ts);
    event.setTimestamp(timestamp);

    event.setTitle(cursor.getString(2));
    event.setUser(cursor.getString(3));

    ts = cursor.getLong(4);
    timestamp = new Timestamp(ts);
    event.setStartTime(timestamp);

    ts = cursor.getLong(5);
    timestamp = new Timestamp(ts);
    event.setEndTime(timestamp);

    event.setDescription(cursor.getString(6));

    event.setProfilePicURI(cursor.getString(7));

    return event;
  }
  /**
   * Gets the all events.
   *
   * @return the all events
   */
  public List<Event> getAllEvents() {
    List<Event> events = new ArrayList<Event>();
    String selectQuery = "SELECT  * FROM " + TABLE_EVENT;

    Log.e(LOG, selectQuery);

    SQLiteDatabase db = this.getReadableDatabase();
    Cursor c = db.rawQuery(selectQuery, null);

    // looping through all rows and adding to list
    if (c.moveToFirst()) {
      do {
        Event ev = new Event();
        ev.setId(c.getInt((c.getColumnIndex(KEY_ID))));
        ev.setTitle((c.getString(c.getColumnIndex(KEY_EVENT_TITLE))));
        ev.setStartDate((c.getString(c.getColumnIndex(KEY_EVENT_STARTDATE))));
        ev.setEndDate((c.getString(c.getColumnIndex(KEY_EVENT_ENDDATE))));
        ev.setStartTime((c.getString(c.getColumnIndex(KEY_EVENT_STARTTIME))));
        ev.setEndTime((c.getString(c.getColumnIndex(KEY_EVENT_ENDTIME))));
        ev.setDescription((c.getString(c.getColumnIndex(KEY_EVENT_DESCRIPTION))));
        ev.setRepeat((c.getString(c.getColumnIndex(KEY_EVENT_REPEAT))));

        // adding to event list
        events.add(ev);
      } while (c.moveToNext());
    }
    return events;
  }
コード例 #3
0
 /*
  * get top 3 (today and tomorrow) events that most people are attending
  */
 public ArrayList<Event> getDayHotEvent() {
   ArrayList<Event> list = new ArrayList<Event>();
   String query = " SELECT a.att_evn_id, e.* , COUNT(att_evn_id) AS count ";
   query += " FROM tb_events e JOIN tb_attending a ON e.evn_id = a.att_evn_id ";
   query += " WHERE evn_start_time BETWEEN now() AND DATE_ADD(NOW(), INTERVAL 1 DAY) ";
   query += " GROUP BY a.att_evn_id ";
   query += " ORDER BY COUNT(att_evn_id) DESC LIMIT 3";
   List<HashMap<String, String>> result =
       DBComunicationLayer.executeHttpPost(DBComunicationLayer.PHP_SELECT, query);
   Log.i(LOG_TAG, query);
   for (int i = 1; i < result.size(); i++) {
     Event e = new Event();
     for (Map.Entry<String, String> item : result.get(i).entrySet()) {
       if (item.getKey().equalsIgnoreCase("evn_id")) {
         e.setId(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_titile")) {
         e.setTitle(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_description")) {
         e.setDescription(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_location")) {
         e.setLocation(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_start_time")) {
         e.setStartDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_end_time")) {
         e.setEndDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_created_time")) {
         e.setCreatedDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_contact_info")) {
         e.setContact(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_cat_id")) {
         e.setCategory(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_url")) {
         e.setUrl(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_count_like")) {
         e.setLike(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_count_dislike")) {
         e.setDislike(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_status")) {
         e.setStatus(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_tag")) {
         e.setTags(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_tag_id")) {
         e.setTagId(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("count")) {
         e.setCount(Integer.parseInt(item.getValue().trim()));
       }
     }
     list.add(e);
   } // eventList now holds all events
   return list;
 }
コード例 #4
0
 /*
  * get top 3 (today and tomorrow) events that most people are attending
  */
 public ArrayList<Event> getEventById(String id) {
   ArrayList<Event> list = new ArrayList<Event>();
   String query = " SELECT * FROM tb_events ";
   query += " WHERE env_id = '" + id + "'";
   List<HashMap<String, String>> result =
       DBComunicationLayer.executeHttpPost(DBComunicationLayer.PHP_SELECT, query);
   Log.i(LOG_TAG, query);
   for (int i = 1; i < result.size(); i++) {
     Event e = new Event();
     for (Map.Entry<String, String> item : result.get(i).entrySet()) {
       if (item.getKey().equalsIgnoreCase("evn_id")) {
         e.setId(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_titile")) {
         e.setTitle(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_description")) {
         e.setDescription(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_location")) {
         e.setLocation(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_start_time")) {
         e.setStartDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_end_time")) {
         e.setEndDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_created_time")) {
         e.setCreatedDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_contact_info")) {
         e.setContact(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_cat_id")) {
         e.setCategory(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_url")) {
         e.setUrl(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_count_like")) {
         e.setLike(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_count_dislike")) {
         e.setDislike(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_status")) {
         e.setStatus(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_tag")) {
         e.setTags(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_tag_id")) {
         e.setTagId(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("count")) {
         e.setCount(Integer.parseInt(item.getValue().trim()));
       }
     }
     list.add(e);
   } // eventList now holds all events
   return list;
 }
コード例 #5
0
  public boolean getAllEvents() {
    resetEventList();
    String query = "SELECT * FROM tb_events";
    List<HashMap<String, String>> result =
        DBComunicationLayer.executeHttpPost(DBComunicationLayer.PHP_SELECT, query);
    for (int i = 1; i < result.size(); i++) {
      Event e = new Event();
      for (Map.Entry<String, String> item : result.get(i).entrySet()) {

        if (item.getKey().equalsIgnoreCase("evn_id")) {
          e.setId(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_titile")) {
          e.setTitle(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_description")) {
          e.setDescription(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_location")) {
          e.setLocation(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_start_time")) {
          e.setStartDayTime(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_end_time")) {
          e.setEndDayTime(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_created_time")) {
          e.setCreatedDayTime(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_contact_info")) {
          e.setContact(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_cat_id")) {
          e.setCategory(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_url")) {
          e.setUrl(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_count_like")) {
          e.setLike(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_count_dislike")) {
          e.setDislike(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_status")) {
          e.setStatus(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_tag")) {
          e.setTags(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_tag_id")) {
          e.setTagId(item.getValue().trim());
        }
      }
      if (!eventList.contains(e)) eventList.add(e);
    }
    //	return Integer.parseInt( result.get( 0 ).get( "result" ) ) == 1;
    return true;
  }
  /**
   * Gets the event.
   *
   * @param title the title
   * @return the event
   */
  public Event getEvent(String title) {
    SQLiteDatabase db = this.getReadableDatabase();
    String selectQuery =
        "SELECT  * FROM " + TABLE_EVENT + " WHERE " + KEY_EVENT_TITLE + " = '" + title + "'";

    Log.e(LOG, selectQuery);
    Cursor c = db.rawQuery(selectQuery, null);
    if (c != null) c.moveToFirst();

    Event ev = new Event();
    ev.setId(c.getInt(c.getColumnIndex(KEY_ID)));
    ev.setTitle((c.getString(c.getColumnIndex(KEY_EVENT_TITLE))));
    ev.setStartDate((c.getString(c.getColumnIndex(KEY_EVENT_STARTDATE))));
    ev.setEndDate((c.getString(c.getColumnIndex(KEY_EVENT_ENDDATE))));
    ev.setStartTime((c.getString(c.getColumnIndex(KEY_EVENT_STARTTIME))));
    ev.setEndTime((c.getString(c.getColumnIndex(KEY_EVENT_ENDTIME))));
    ev.setDescription((c.getString(c.getColumnIndex(KEY_EVENT_DESCRIPTION))));
    ev.setRepeat((c.getString(c.getColumnIndex(KEY_EVENT_REPEAT))));

    return ev;
  }