/**
   * Creates the event.
   *
   * @param event the event
   * @param category_ids the category_ids
   * @return the long
   */
  public long createEvent(Event event, long[] category_ids) {

    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_EVENT_TITLE, event.getTitle());
    values.put(KEY_EVENT_STARTDATE, event.getStartDate());
    values.put(KEY_EVENT_ENDDATE, event.getEndDate());
    values.put(KEY_EVENT_STARTTIME, event.getStartTime());
    values.put(KEY_EVENT_ENDTIME, event.getEndTime());
    values.put(KEY_EVENT_DESCRIPTION, event.getDescription());
    values.put(KEY_EVENT_REPEAT, event.getRepeat());

    // insert row
    long event_id = db.insert(TABLE_EVENT, null, values);

    // assigning categories to events
    for (long category_id : category_ids) {
      createEventCategory(event_id, category_id);
    }
    // for logging
    //	Log.e("createEvent", event.toString());
    //   db.close();

    return event_id;
  }
  /**
   * Check conflictin update events.
   *
   * @param newEvent the new event
   * @return true, if successful
   * @throws ParseException the parse exception
   */
  @SuppressLint("LongLogTag")
  public boolean checkConflictinUpdateEvents(Event newEvent) throws ParseException {
    SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm");
    String sTime = newEvent.getStartTime();
    String sDate = newEvent.getStartDate();
    String eTime = newEvent.getEndTime();
    String eDate = newEvent.getEndDate();

    Date parsedStartTime = timeFormat.parse(sTime);
    Timestamp newStartTime = new Timestamp(parsedStartTime.getTime());
    Date parsedEndTime = timeFormat.parse(eTime);
    Timestamp newEndTime = new Timestamp(parsedEndTime.getTime());

    if (sDate.equalsIgnoreCase(eDate)) {
      if (newStartTime.after(newEndTime)) {
        Log.e("Illogiacl Update", "StartTime is greater then EndTime");
        return false;
      }
    }

    List<Event> allEvents = getEvent(sDate, eDate);
    for (Event prevEvent : allEvents) {
      Log.d(
          "Event: " + prevEvent.getTitle(),
          "" + prevEvent.getId() + "  " + prevEvent.getDescription());

      Date parsedPreviousStartTime = timeFormat.parse(prevEvent.getStartTime());
      Timestamp previousStartTime = new Timestamp(parsedPreviousStartTime.getTime());
      Date parsedPreviousEndTime = timeFormat.parse(prevEvent.getEndTime());
      Timestamp previousEndTime = new Timestamp(parsedPreviousEndTime.getTime());

      if (newStartTime.after(previousStartTime) && newStartTime.before(previousEndTime)
          || newEndTime.after(previousStartTime) && newEndTime.before(previousEndTime)
          || previousStartTime.after(newStartTime) && previousStartTime.before(newEndTime)
          || previousEndTime.after(newStartTime) && previousEndTime.before(newEndTime)) {
        if (newEvent.getId() != prevEvent.getId()) {
          Log.e("Conflict with existent event", "Can't update this event");
          return false;
        }
      }
    }
    return true;
  }
示例#3
0
  public void updateEventWithId(int id, Event e) {
    ContentValues cv = new ContentValues();
    cv.put(colName, e.getName());
    cv.put(colStartTime, e.getStartTime());
    cv.put(colEndTime, e.getEndTime());
    cv.put(colLatitude, e.getLatitude());
    cv.put(colLongitude, e.getLongitude());
    cv.put(transport, e.getTransport());
    cv.put(colInfo, e.getInfo());
    cv.put(colPassed, e.getPassed());

    db.update(eventTable, cv, colId + "=" + Integer.toString(id), null);
  }
示例#4
0
  public long AddEvent(Event e) {
    ContentValues cv = new ContentValues();

    cv.put(colName, e.getName());
    cv.put(colStartTime, e.getStartTime());
    cv.put(colEndTime, e.getEndTime());
    cv.put(colLatitude, e.getLatitude());
    cv.put(colLongitude, e.getLongitude());
    cv.put(transport, e.getTransport());
    cv.put(colInfo, e.getInfo());
    cv.put(colPassed, e.getPassed());

    return db.insert(eventTable, colName, cv);
  }
  /**
   * Update event.
   *
   * @param event the event
   * @return the int
   */
  public int updateEvent(Event event) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_EVENT_TITLE, event.getTitle());
    values.put(KEY_EVENT_STARTDATE, event.getStartDate());
    values.put(KEY_EVENT_ENDDATE, event.getEndDate());
    values.put(KEY_EVENT_STARTTIME, event.getStartTime());
    values.put(KEY_EVENT_ENDTIME, event.getEndTime());
    values.put(KEY_EVENT_DESCRIPTION, event.getDescription());
    values.put(KEY_EVENT_REPEAT, event.getRepeat());

    // updating row
    return db.update(
        TABLE_EVENT, values, KEY_ID + " = ?", new String[] {String.valueOf(event.getId())});
  }
示例#6
0
  public void updateEvent(Event e) {
    ContentValues cv = new ContentValues();
    cv.put(colName, e.getName());
    cv.put(colStartTime, e.getStartTime());
    cv.put(colEndTime, e.getEndTime());
    cv.put(colLatitude, e.getLatitude());
    cv.put(colLongitude, e.getLongitude());
    cv.put(transport, e.getTransport());
    cv.put(colInfo, e.getInfo());

    if (e.getPassed()) {
      cv.put(colPassed, 1);
    } else {
      cv.put(colPassed, 0);
    }

    db.update(eventTable, cv, colId + "=" + Integer.toString(e.getId()), null);
  }
 @MediumTest
 public void testGetEvent_withLocationAndDescription() {
   mockServer
       .expect(requestTo("https://graph.facebook.com/193482154020832"))
       .andExpect(method(GET))
       .andExpect(header("Authorization", "OAuth someAccessToken"))
       .andRespond(withResponse(jsonResource("testdata/full-event"), responseHeaders));
   Event event = facebook.eventOperations().getEvent("193482154020832");
   assertEquals("193482154020832", event.getId());
   assertEquals("100001387295207", event.getOwner().getId());
   assertEquals("Art Names", event.getOwner().getName());
   assertEquals("Breakdancing Class", event.getName());
   assertEquals(Event.Privacy.SECRET, event.getPrivacy());
   assertEquals(toDate("2011-03-30T14:30:00+0000"), event.getStartTime());
   assertEquals(toDate("2011-03-30T17:30:00+0000"), event.getEndTime());
   assertEquals(toDate("2011-03-30T14:38:40+0000"), event.getUpdatedTime());
   assertEquals("Bring your best parachute pants!", event.getDescription());
   assertEquals("2400 Dunlavy Dr, Denton, TX", event.getLocation());
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      Event selectedEvent = getItem(position);

      // if we weren't given a view, inflate one
      if (null == convertView) {
        convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_event, null);
      }

      // TODO:set the event details here for all sub-views eventNameTextView
      ImageView imageButton = (ImageView) convertView.findViewById(R.id.eventImageView);
      // imageButton.setVisibility(View.GONE);
      Bitmap bitmap = imageCache.get(selectedEvent.getId());
      if (bitmap != null) {
        imageButton.setImageBitmap(bitmap);
        imageButton.setVisibility(View.VISIBLE);
      } else {
        // displayEventImage(selectedEvent, imageButton);

        //				TODO loadBitmap(selectedEvent, imageButton);
        if (true) { // selectedEvent.getCoverImage() != null) {
          //					new DownloadAndCacheImageTask(imageButton, mContext, true).execute(selectedEvent);

          Glide.with(mContext)
              .load(selectedEvent.getCoverImage())
              .fitCenter()
              .placeholder(R.drawable.ic_launcher)
              .crossFade()
              .into(imageButton);
        }
      }
      // TODO 10/1/14
      //            if(selectedEvent.getImageUri() != null || selectedEvent.getLocalFileUri() !=
      // null) {
      //            	displayEventImage(selectedEvent, imageButton);
      //            }
      //            else {
      //            	Log.d(TAG, "EventListFragment: getView() - hiding the ImageView until bitmap is
      // created");
      //            	imageButton.setMaxHeight(0);
      //            	imageButton.setVisibility(View.GONE);
      //            }
      TextView eventNameView = (TextView) convertView.findViewById(R.id.nameTextView);
      eventNameView.setText(selectedEvent.getName());
      TextView eventDayView = (TextView) convertView.findViewById(R.id.eventDay);
      eventDayView.setText(selectedEvent.getDay());
      TextView eventMonthView = (TextView) convertView.findViewById(R.id.eventMonth);
      eventMonthView.setText(selectedEvent.getMonth());
      TextView eventLocationView = (TextView) convertView.findViewById(R.id.eventLocation);
      if (selectedEvent.getLocation() != null) {
        eventLocationView.setText(selectedEvent.getLocation());
      }

      TextView eventStartTime = (TextView) convertView.findViewById(R.id.eventStartTime);

      if (selectedEvent.getStartTime() != null) {
        eventStartTime.setText(selectedEvent.getStartTime().getTime().toString());
      } else {
        eventStartTime.setText(selectedEvent.getTime());
      }
      //            ImageButton rsvpButton = (ImageButton)
      // convertView.findViewById(R.id.rsvp_status);
      //            rsvpButton.setOnClickListener(new View.OnClickListener() {
      //    			@Override
      //    			public void onClick(View v) {
      //    				Log.d(TAG, "rsvpButton clicked by View: " + v.getId());
      //    				//showPopup(v);
      //    			}
      //
      //    		});

      mPreferences = mContext.getSharedPreferences("cyathen_references", mContext.MODE_PRIVATE);
      mIsFriend = (mSharedPrefs.getBoolean("isFriendEvent", false));

      TextView eventInviterView = (TextView) convertView.findViewById(R.id.eventHost);

      /*mHostProfilePictureView = (ProfilePictureView) convertView
      		.findViewById(R.id.hostProfilePicture);
      mHostProfilePictureView.setPresetSize(ProfilePictureView.SMALL);*/

      String rsvpText = "";
      String name = "";
      Friend friend = FriendInventory.get(mContext).getFriend(selectedEvent.getInvitedFriendId());
      if (mIsFriend && friend != null) {
        name = friend.getName();
        rsvpText = " is ";
        // Log.d(TAG, "EventListFragment isFriendEvent: " + mIsFriend + ", name: " + name);
      } else {
        name = "You";
        rsvpText = " are ";
        // Log.d(TAG, "EventListFragment isFriendEvent: " + mIsFriend);
      }
      String rsvpStatus = selectedEvent.getRSVP();
      if (rsvpStatus != null) {
        if (rsvpStatus.equalsIgnoreCase("not_replied")) {
          rsvpStatus = "invited by " + selectedEvent.getHost();
        } else {
          if (rsvpStatus.equalsIgnoreCase("unsure")) rsvpStatus = "maybe going";
          else if (rsvpStatus.equalsIgnoreCase("attending")) rsvpStatus = "going!";
          else if (rsvpStatus.equalsIgnoreCase("declined")) rsvpStatus = "not going";
        }
        // Log.d(TAG, "rsvpStatus: " + rsvpStatus);
      } else {
        rsvpStatus = "Invited by " + selectedEvent.getHost();
      }
      // If Mode = 0; then it's an event I'm invited to
      // Set eventInviterView to: my rsvp and mHostProfilePictureView to: FB image of inviter/host
      // If Mode = 1; then it's an event a FRIEND is invited to
      // Set eventInviterView to: friend name " is invited" and mHostProfilePictureView to: FB image
      // of friend
      // If Mode = 2; then this is a list of all events ONE friend is invited to
      // Set eventInviterView to: friend's rsvp and mHostProfilePictureView to: FB image of
      // inviter/host
      if (mListMode == 0) {
        eventInviterView.setText(name + rsvpText + rsvpStatus);
        // mHostProfilePictureView.setProfileId(selectedEvent.getHostId());
        // Log.d(TAG, selectedEvent.getName() + " is MY event ");
      } else if (mListMode == 1) {
        if (selectedEvent.getInvitedFriendId() != null) {
          // Log.d(TAG, selectedEvent.getName() + " is from friend: "
          // +selectedEvent.getInvitedFriendId() + ", name:" +
          // FriendInventory.get(mContext).getFriend(selectedEvent.getInvitedFriendId()).getName());

          if (friend != null) {
            eventInviterView.setText(friend.getName() + " is invited");
          } else {
            eventInviterView.setText(
                "Your friend " + selectedEvent.getInvitedFriendId() + " is invited");
          }
          // mHostProfilePictureView.setProfileId(selectedEvent.getInvitedFriendId());
        }
      } else if (mListMode == 2) {
        eventInviterView.setText(rsvpText + rsvpStatus);
        // mHostProfilePictureView.setProfileId(selectedEvent.getHostId());
      }
      return convertView;
    }