private void moveCameraToLocation() { ParseGeoPoint geoPoint; String title; if (mEvent.getLocation() == null) { geoPoint = mEvent.getParseGeoPoint("UserLocation"); title = mEvent.getName(); } else { geoPoint = mEvent.getLocation().getLocation(); title = mEvent.getLocation().getName(); } LatLng location = new LatLng(geoPoint.getLatitude(), geoPoint.getLongitude()); mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, 15)); mGoogleMap.addMarker(new MarkerOptions().position(location).title(title)); }
public boolean createEvent(Event e) { if (eventList.contains(e)) return true; String query = "INSERT INTO tb_events (evn_id, evn_titile, evn_description, evn_location, evn_start_time, evn_end_time, evn_created_time, evn_created_by, evn_contact_info, evn_cat_id, evn_url, evn_count_like, evn_count_dislike, evn_status, evn_tag, evn_tag_id)"; query = query + " VALUES (NULL, '" + e.getTitle() + "', '" + e.getDescription() + "', '" + e.getLocation() + "', '" + e.getStartDayTime() + "', '" + e.getEndDayTime() + "', '" + e.getCreatedDayTime() + "', " + e.getCreatedBy() + ", '" + e.getContact() + "', " + e.getCategory() + ", '" + e.getUrl() + "', " + e.getLike() + ", " + e.getDislike() + ", " + e.getStatus() + ", '" + e.getTags() + "', NULL)"; Log.i(LOG_TAG, query); List<HashMap<String, String>> result = DBComunicationLayer.executeHttpPost(DBComunicationLayer.PHP_INSERT, query); e.setId(result.get(0).get("evn_id")); eventList.add(e); // add all Tags into Tag Table /* for (int i =0; i< e.getTagList().size();i++) { String query2 = "INSERT INTO tb_tags (tag_id, tag_name)"+ " VALUES (NULL, '"+e.getTagList().get(i)+"')"; List<HashMap<String, String>> result2 = DBComunicationLayer.executeHttpPost( DBComunicationLayer.PHP_INSERT, query2); } */ // return result.get( 0 ).get( "result" ).equals( "1" ); return true; }
public List<Event> getEvents(String filter) { if ("".equals(filter)) { return new ArrayList<Event>(events); } List<Event> filteredEvents = new ArrayList<Event>(); for (Event event : events) { if (event.getDescription().toLowerCase().contains(filter.toLowerCase()) || event.getLocation().toLowerCase().contains(filter.toLowerCase()) || event.getSummary().toLowerCase().contains(filter.toLowerCase())) { filteredEvents.add(event); } } return filteredEvents; }
@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()); }
private void populateItems() { // create the form form = new Form("form"); // create elements and add them to the form form.add(new Label("eventName", event.getName())); form.add(new Label("location", event.getLocation())); form.add(new Label("description", event.getDescription())); form.add(new Label("positions", event.getNumPositions())); form.add(new Label("positionsLeft", event.getNumPositionsRemaining())); form.add( new Button("apply") { @Override public void onSubmit() { EventDao ed = new EventDao(); ed.insertUserSignsUpForEvent(CustomSession.get().getUser(), event); if (returnTo.equals("partnerHomeView")) setResponsePage(PartnerHomeView.class); else if (returnTo.equals("partnerEventView")) setResponsePage(PartnerEventView.class); else if (returnTo.equals("volunteerHomeView")) setResponsePage(VolunteerHomeView.class); else if (returnTo.equals("volunteerSearchPage")) setResponsePage(VolunteerSearchView.class); } }); form.add( new Button("save") { @Override public void onSubmit() { if (returnTo.equals("partnerHomeView")) setResponsePage(PartnerHomeView.class); else if (returnTo.equals("partnerEventView")) setResponsePage(PartnerEventView.class); else if (returnTo.equals("volunteerHomeView")) setResponsePage(VolunteerHomeView.class); else if (returnTo.equals("volunteerSearchPage")) setResponsePage(VolunteerSearchView.class); } }); // add the form to the page add(form); }
@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; }
@Override protected Builder buildEntry(Builder builder, Resource resource) { Event event = (Event) resource; builder = builder .withValue(Events.CALENDAR_ID, id) .withValue(entryColumnRemoteName(), event.getName()) .withValue(entryColumnETag(), event.getETag()) .withValue(entryColumnUID(), event.getUid()) .withValue(Events.ALL_DAY, event.isAllDay() ? 1 : 0) .withValue(Events.DTSTART, event.getDtStartInMillis()) .withValue(Events.EVENT_TIMEZONE, event.getDtStartTzID()) .withValue(Events.HAS_ATTENDEE_DATA, event.getAttendees().isEmpty() ? 0 : 1) .withValue(Events.GUESTS_CAN_INVITE_OTHERS, 1) .withValue(Events.GUESTS_CAN_MODIFY, 1) .withValue(Events.GUESTS_CAN_SEE_GUESTS, 1); boolean recurring = false; if (event.getRrule() != null) { recurring = true; builder = builder.withValue(Events.RRULE, event.getRrule().getValue()); } if (event.getRdate() != null) { recurring = true; builder = builder.withValue(Events.RDATE, event.getRdate().getValue()); } if (event.getExrule() != null) builder = builder.withValue(Events.EXRULE, event.getExrule().getValue()); if (event.getExdate() != null) builder = builder.withValue(Events.EXDATE, event.getExdate().getValue()); // set either DTEND for single-time events or DURATION for recurring events // because that's the way Android likes it (see docs) if (recurring) { // calculate DURATION from start and end date Duration duration = new Duration(event.getDtStart().getDate(), event.getDtEnd().getDate()); builder = builder.withValue(Events.DURATION, duration.getValue()); } else { builder = builder .withValue(Events.DTEND, event.getDtEndInMillis()) .withValue(Events.EVENT_END_TIMEZONE, event.getDtEndTzID()); } if (event.getSummary() != null) builder = builder.withValue(Events.TITLE, event.getSummary()); if (event.getLocation() != null) builder = builder.withValue(Events.EVENT_LOCATION, event.getLocation()); if (event.getDescription() != null) builder = builder.withValue(Events.DESCRIPTION, event.getDescription()); if (event.getOrganizer() != null && event.getOrganizer().getCalAddress() != null) { URI organizer = event.getOrganizer().getCalAddress(); if (organizer.getScheme() != null && organizer.getScheme().equalsIgnoreCase("mailto")) builder = builder.withValue(Events.ORGANIZER, organizer.getSchemeSpecificPart()); } Status status = event.getStatus(); if (status != null) { int statusCode = Events.STATUS_TENTATIVE; if (status == Status.VEVENT_CONFIRMED) statusCode = Events.STATUS_CONFIRMED; else if (status == Status.VEVENT_CANCELLED) statusCode = Events.STATUS_CANCELED; builder = builder.withValue(Events.STATUS, statusCode); } builder = builder.withValue( Events.AVAILABILITY, event.isOpaque() ? Events.AVAILABILITY_BUSY : Events.AVAILABILITY_FREE); if (event.getForPublic() != null) builder = builder.withValue( Events.ACCESS_LEVEL, event.getForPublic() ? Events.ACCESS_PUBLIC : Events.ACCESS_PRIVATE); return builder; }
protected void onPostExecute(List<Event> eventList) { setContentView(R.layout.activity_event); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.event_marker); mapFragment.getMapAsync(EventActivity.this); dialog.hide(); final Button b = (Button) findViewById(R.id.join); for (Event event : eventList) { if (event.attendees.contains(userID)) { b.setText("Leave Event"); } if (event.creator.equals(userID)) { b.setText("Delete Event"); } } b.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { if (b.getText().equals("I'm up!")) { System.out.println("Joining"); new attendEvent() .execute("https://protected-ocean-61024.herokuapp.com/event/join/", id); dialog.setCancelable(false); dialog.setMessage("Submitting request"); dialog.setInverseBackgroundForced(false); dialog.show(); } else if (b.getText().equals("Leave Event")) { System.out.println("Leaving"); new attendEvent() .execute("https://protected-ocean-61024.herokuapp.com/event/leave/", id); dialog.setCancelable(false); dialog.setMessage("Submitting request"); dialog.setInverseBackgroundForced(false); dialog.show(); } else if (b.getText().equals("Delete Event")) { new attendEvent() .execute("https://protected-ocean-61024.herokuapp.com/event/delete/", id); dialog.setCancelable(false); dialog.setMessage("Deleting event"); dialog.setInverseBackgroundForced(false); dialog.show(); } } }); final Event e = eventList.get(0); title = (TextView) findViewById(R.id.event_info_title); date = (TextView) findViewById(R.id.event_info_date); img = (ImageView) findViewById(R.id.event_info_image); title.setText(e.getTitle()); date.setText(e.getFullDate()); String category = e.getCategory(); Bitmap largeIcon = BitmapFactory.decodeResource(getApplicationContext().getResources(), getImage(category)); largeIcon = hlp.getRoundedCornerBitmap(largeIcon, 500); img.setImageBitmap(largeIcon); String str = e.getLocation(); List<String> strList = Arrays.asList(str.split(",")); coords.add(0, Double.parseDouble(strList.get(1))); coords.add(1, Double.parseDouble(strList.get(0))); }