public void createRandomIndividuals(int numIndividuals, KTH kth) { Map<Integer, Room> rooms = kth.getRooms(); int numRooms = kth.getRooms().size(); for (int i = 0; i < numIndividuals; i++) { // register all available timeslots ArrayList<TimeSlot> availableTimeSlots = new ArrayList<TimeSlot>(); for (int roomId : rooms.keySet()) { for (int d = 0; d < RoomTimeTable.NUM_DAYS; d++) { for (int t = 0; t < RoomTimeTable.NUM_TIMESLOTS; t++) { availableTimeSlots.add(new TimeSlot(roomId, d, t)); } } } TimeTable tt = new TimeTable(numRooms); for (int roomId : rooms.keySet()) { Room room = rooms.get(roomId); RoomTimeTable rtt = new RoomTimeTable(room); tt.putRoomTimeTable(roomId, rtt); } // index variables int rttId = 0; int day = 0; int timeSlot = 0; // assign all event to any randomly selected available timeslot Random rand = new Random(System.currentTimeMillis()); for (Event e : kth.getEvents().values()) { TimeSlot availableTimeSlot = availableTimeSlots.get(rand.nextInt(availableTimeSlots.size())); RoomTimeTable rtt = tt.getRoomTimeTables()[availableTimeSlot.roomId]; rtt.setEvent(availableTimeSlot.day, availableTimeSlot.timeSlot, e.getId()); availableTimeSlots.remove(availableTimeSlot); /* DEBUG System.out.println("=============="); System.out.println("ROOM TIME TABLE ID: " + rtt.getRoom().getName()); System.out.println("Day: " + availableTimeSlot.day + " Timeslot: " + availableTimeSlot.timeSlot + " Event ID: " + e.getId()); */ } individuals.add(tt); availableTimeSlots.clear(); } }
@Test public void testDeleteById() { Event event = genEvent(); dataRepository.save(event); dataRepository.delete(event.getId()); Assert.assertFalse(dataRepository.exists(event.getId())); }
private void populateTrainingSessions() { if (null == sessions) { sessions = new HashSet<TrainingSession>(); } Set<Event> events = getSubscribedEvents(); for (Event ev : events) { TrainingSession ts1 = new TrainingSession( ev.getId(), this, new java.util.Date(1227817411), "a workout desc", true, "something for now", "something"); TrainingSession ts2 = new TrainingSession( ev.getId(), this, new java.util.Date(1229459011), "a workout desc", true, "something for now", "something"); UserRegistry.getCurrentInstance().userEJB.addTrainingSession(ts1); UserRegistry.getCurrentInstance().userEJB.addTrainingSession(ts2); sessions.add(ts1); sessions.add(ts2); } UserRegistry.getCurrentInstance().updateUser(this); }
@Test @Transactional public void testRemoveContactFromEventMultipleGroups() throws Exception { groupService.create(group); groupService.addAggregation(event, group); Group secondGroup = new Group(); secondGroup.setGroupName("Second Group"); groupService.create(secondGroup); groupService.addAggregation(event, secondGroup); Contact newContact = new Contact(); newContact.setFirstName("Fresh Contact"); newContact.setEmail("Fresh email"); contactService.create(newContact); event = eventService.findById(event.getId()); contactService.attendEvent(newContact, event); newContact = contactService.findById(newContact.getId()); contactService.unattendEvent(newContact, event); event = eventService.findById(event.getId()); assertFalse(event.getAttendees().contains(newContact)); newContact = contactService.findById(newContact.getId()); assertFalse(newContact.getAttendedEvents().contains(event)); }
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; int type = getItemViewType(position); Event event = events.get(position); if (convertView == null) { holder = new ViewHolder(); switch (type) { case DAY: convertView = mInflater.inflate(R.layout.day_item, null); holder.day = (TextView) convertView.findViewById(R.id.day_title); break; case EVENT: convertView = mInflater.inflate(R.layout.search_list_item, null); holder.hour = (TextView) convertView.findViewById(R.id.event_hour); holder.title = (TextView) convertView.findViewById(R.id.event_title); holder.image = (ImageView) convertView.findViewById(R.id.event_favorite); holder.row = (LinearLayout) convertView.findViewById(R.id.event_row); holder.eventId = event.getId(); break; } convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } if (event != null) { if (event.getExternalId() == 0) { String dayText = BaseActivity.getDateFromTimestamp(event.getDate(), context); holder.day.setText(dayText); } else { // Hour. String hour = event.getStartHour(); if (hour.length() == 0) { hour = context.getString(R.string.event_whole_day); } holder.hour.setText(hour); // Title. String title = event.getTitle(); holder.title.setText(title); // Favorite. if (event.getFavorite() == 0) { holder.image.setImageResource(R.drawable.fav_off_small); } else { holder.image.setImageResource(R.drawable.fav_on_small); } holder.eventId = event.getId(); convertView.setOnTouchListener(eventTouch); } } return convertView; }
@Test public void testRetrieve() throws PaysioException { Map<String, Object> listParams = new HashMap<String, Object>(); listParams.put("count", 1); Event originalEvent = Event.all(listParams).getData().get(0); Event retrievedEvent = Event.retrieve(originalEvent.getId()); assertEquals(originalEvent.getId(), retrievedEvent.getId()); assertEquals(originalEvent.getCreated(), retrievedEvent.getCreated()); assertNotNull(retrievedEvent.getData()); }
/** * Updates a single Event.<br> * Implements the update Event operation of the EventSpot API by calling the ConstantContact * server side. * * @param accessToken Constant Contact OAuth2 access token. * @param event The event to update. * @return An {@link Event} containing data as returned by the server on success; <br> * An exception is thrown otherwise. * @throws ConstantContactServiceException When something went wrong in the Constant Contact flow * or an error is returned from server. */ @Override public Event updateEvent(String accessToken, Event event) throws ConstantContactServiceException { Event updatedEvent = null; try { String url = String.format( "%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.EVENT_ID, event.getId())); String json = event.toJSON(); CUrlResponse response = getRestClient().put(url, accessToken, json); if (response.hasData()) { updatedEvent = Component.fromJSON(response.getBody(), Event.class); } if (response.isError()) { ConstantContactServiceException constantContactException = new ConstantContactServiceException( ConstantContactServiceException.RESPONSE_ERR_SERVICE); response.getInfo().add(new CUrlRequestError("url", url)); constantContactException.setErrorInfo(response.getInfo()); throw constantContactException; } } catch (ConstantContactServiceException e) { throw new ConstantContactServiceException(e); } catch (Exception e) { throw new ConstantContactServiceException(e); } return updatedEvent; }
@Test public void testDeleteByIdBatch() { List<Event> events = new LinkedList<Event>(); for (int i = 0; i < 10; i++) { events.add(genEvent()); } dataRepository.save(events); List<Object[]> ids = new LinkedList<Object[]>(); for (Event e : events) { Assert.assertTrue(dataRepository.exists(e.getId())); ids.add(e.getId()); } dataRepository.delete(ids); for (Event e : events) { Assert.assertFalse(dataRepository.exists(e.getId())); ids.add(e.getId()); } }
/** * 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; }
/** * Compare two events for sorting by date in reverse chronological order * * @param firstEvent an event object for comparison * @param secondEvent an event object for comparison * @return the result of the comparison */ public int compare(Event firstEvent, Event secondEvent) { int firstDate = DateUtils.getIntegerFromDate(firstEvent.getSortFirstDate()); int secondDate = DateUtils.getIntegerFromDate(secondEvent.getSortFirstDate()); Integer first = new Integer(firstDate); Integer second = new Integer(secondDate); if (first == second) { first = Integer.parseInt(firstDate + "" + firstEvent.getId()); second = Integer.parseInt(secondDate + "" + secondEvent.getId()); } if (reverse) { return (first.compareTo(second)) * -1; } else { return first.compareTo(second); } } // end compare method
public void fireEvent(Event event) { if (event == null) throw new IllegalArgumentException("event == null"); Set<Listener> set = listeners.get(event.getId()); if (set != null) { for (Listener l : set.toArray(new Listener[set.size()])) { l.eventOccured(event); } } }
@Test public void testSaveBatch() { List<Event> events = new LinkedList<Event>(); for (int i = 0; i < 10; i++) { events.add(genEvent()); } dataRepository.save(events); for (Event e : events) { Assert.assertTrue(dataRepository.exists(e.getId())); } }
private void updateSpouseLines() { clearSpouseLine(); if (!Settings.isSpouseLinesEnabled()) return; Event selEvent = MainModel.getEvent(selEventId); Person p = selEvent.getPerson(); Person spouse = MainModel.getPerson(p.getSpouseId()); if (spouse == null || selEvent == null) return; Event firstSpouseEvent = spouse.getEarliestEvent(); if (firstSpouseEvent == null) return; if (!MainModel.isEventVisible(selEvent.getId()) || !MainModel.isEventVisible(firstSpouseEvent.getId())) return; spouseLine = drawLine(selEvent, firstSpouseEvent, SPOUSE_LINE_WIDTH, Settings.getSpouseLineColor()); }
public void setEvent(Event event) { if (event == null) { throw new DaoException( "To-one property 'event_id' has not-null constraint; cannot set to-one to null"); } synchronized (this) { this.event = event; event_id = event.getId(); event__resolvedKey = event_id; } }
@RequestMapping( value = "/events/{eventName}/additional-field/swap-position/{id1}/{id2}", method = POST) public void swapAdditionalFieldPosition( @PathVariable("eventName") String eventName, @PathVariable("id1") int id1, @PathVariable("id2") int id2, Principal principal) { Event event = eventManager.getSingleEvent(eventName, principal.getName()); eventManager.swapAdditionalFieldPosition(event.getId(), id1, id2); }
@Test @Transactional public void testAddContactToMultipleGroupsMultipleConstituents() throws Exception { groupService.create(group); groupService.addAggregation(committee, group); groupService.addAggregation(event, group); Group secondGroup = new Group(); secondGroup.setGroupName("Second Group"); groupService.create(secondGroup); groupService.addAggregation(committee, secondGroup); groupService.addAggregation(event, secondGroup); Contact contact = new Contact(); contact.setFirstName("Test Contact"); contact.setEmail("*****@*****.**"); contactService.create(contact); contactService.addContactToCommittee(contact, committee); contactService.attendEvent(contact, event); contactService.addToGroup(contact, group); contactService.addToGroup(contact, secondGroup); contact = contactService.findById(contact.getId()); group = groupService.findById(group.getId()); secondGroup = groupService.findById(secondGroup.getId()); event = eventService.findById(event.getId()); committee = committeeService.findById(committee.getId()); assertTrue(contact.getGroups().contains(group)); assertTrue(contact.getGroups().contains(secondGroup)); assertTrue(contact.getCommittees().contains(committee)); assertTrue(contact.getAttendedEvents().contains(event)); assertTrue(event.getAttendees().contains(contact)); assertTrue(event.getGroups().contains(group)); assertTrue(event.getGroups().contains(secondGroup)); assertTrue(committee.getMembers().contains(contact)); assertTrue(committee.getGroups().contains(group)); assertTrue(committee.getGroups().contains(secondGroup)); assertTrue(group.getTopLevelMembers().contains(contact)); assertTrue(group.getAggregations().contains(committee)); assertTrue(group.getAggregations().contains(event)); assertTrue(secondGroup.getTopLevelMembers().contains(contact)); assertTrue(secondGroup.getAggregations().contains(committee)); assertTrue(secondGroup.getAggregations().contains(event)); }
// region Method called after data request returns success private void completeData(List<BaasDocument> data) { Log.d(LOG_TAG, "Received list size: " + data.size()); for (BaasDocument d : data) { // Figure out what to do with returned data objects Log.d(LOG_TAG, "Iterating through received document list."); // BaasDocument d = BaasDocument.from(x); //Convert to BaasDocument if (d.getCollection().equals("group")) { Group2 g = new Group2(d); // Create group instance with BaasDocument // model.activeGroups.add(g); //Old methodology model.getActiveGroups().add(g); // Synchronized implementation 1 /*synchronized (model) { //Synchronized implementation 2 model.activeGroups.add(g); }*/ Log.d(LOG_TAG, "Added group to active group list."); } else if (d.getCollection().equals("event")) { Event e = new Event(d); // Create event instance with BaasDocument for (int i = 1; i < (model.getIdList().size() - 1); i++) { // Iterate through all event lists if (model .getIdList() .get(i) .contains(e.getId())) { // If it contains the current event ID, add event switch (i) { case 1: model.getAcceptedEvents().add(e); Log.d(LOG_TAG, "Added event to accepted."); break; case 2: model.getWaitingEvents().add(e); Log.d(LOG_TAG, "Added event to waiting."); break; case 3: model.getRejectedEvents().add(e); Log.d(LOG_TAG, "Added event to rejected."); break; default: Log.d(LOG_TAG, "Event not placed: " + e); } } } } else { Log.d(LOG_TAG, "Data object was not group or event: " + d); } } // Launch main activity if the friend pulldowns are done if (friendRT == null && eventRT == null && groupRT == null && cloudRT == null) { launchMainActivity(); } }
@Override public void onListItemClick(ListView lv, View v, int position, long id) { Event e = ((EventAdapter) getListAdapter()).getItem(position); this.getListView().getItemAtPosition(position); mEventSelected = e.getId(); if (mListMode == 1) { // Log.d(TAG, "EventListFragment: onListItemClick; saving " + e.getInvitedFriendId() + " in // fbUserName"); mSharedPrefsEditor.putString("fbUserName", e.getInvitedFriendId()); } else if (mListMode == 2) { // mSharedPrefsEditor.putString("fbUserName", e.getInvitedFriendId()); } mSharedPrefsEditor.commit(); // Log.d(TAG, "$$$$$$$Event " + e.getId() + " was clicked" ); Intent intent = new Intent(getActivity(), EventActivity.class); // TODO needs update intent.putExtra(EXTRA_EVENT_ID, e.getId() + ""); intent.putExtra(EXTRA_IS_FRIEND, String.valueOf(this.mMyEvents)); startActivity(intent); }
/** * 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())}); }
/** * Delete category. * * @param category the category * @param should_delete_all_category_events the should_delete_all_category_events */ public void deleteCategory(Category category, boolean should_delete_all_category_events) { SQLiteDatabase db = this.getWritableDatabase(); // before deleting category // check if events under this category should also be deleted if (should_delete_all_category_events) { // get all events under this category List<Event> allCategoryEvent = getAllEventsByCategory(category.getName()); // delete all events for (Event event : allCategoryEvent) { // delete event deleteEvent(event.getId()); } } // now delete the category db.delete(TABLE_CATEGORY, KEY_ID + " = ?", new String[] {String.valueOf(category.getId())}); }
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()); }
public EventListByDateAdapter(Context c, String startDate, String endDate) { eContext = c; this.startDate = startDate; this.endDate = endDate; // this.ctg = ctg; // db = new MySQLiteHelper(eContext); // Getting all Events Log.d("Get Events", "Getting All Events"); dayEvents = new ArrayList<Event>(); try { stDate = dateFormat.parse(startDate); eDate = dateFormat.parse(endDate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Getting all Events Log.d("Get Events", "Getting All Events"); allEvents = SimpleCalendarView.db.getAllEvents(); for (Event event : allEvents) { Date eventStartDate = new Date(); // Date eventEndDate = new Date(); try { eventStartDate = dateFormat.parse(event.getStartDate()); // eventEndDate = dateFormat.parse(event.getEndDate()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (((eventStartDate.compareTo(stDate) >= 0) && (eventStartDate.compareTo(eDate) <= 0))) { dayEvents.add(event); Log.d( "Event:" + event.getTitle(), "ID:" + event.getId() + "Description:" + event.getDescription()); } } }
private void updateLifeStory() { // Log.e(tag, "updating life story"); ArrayList<Event> events = MainModel.getPerson(selPersonId).getSortedEvents(); ArrayList<Event> visibleEvents = new ArrayList<Event>(); for (int i = 0; i < events.size(); i++) { Event curr_event = events.get(i); if (MainModel.isEventVisible(curr_event.getId())) { visibleEvents.add(curr_event); // Log.e(tag, "visible event: "+curr_event.toString()); } } clearLifeStory(); if (!Settings.isLifeLinesEnabled()) return; for (int j = 1; j < visibleEvents.size(); j++) { Event event1 = visibleEvents.get(j - 1); Event event2 = visibleEvents.get(j); lifeStory.add(drawLine(event1, event2, LIFE_STORY_WIDTH, Settings.getLifeStoryColor())); } }
@Test @Transactional public void testAddEventMultipleGroups() throws Exception { groupService.create(group); groupService.addAggregation(event, group); groupService.addAggregation(committee, group); Group secondGroup = new Group(); secondGroup.setGroupName("Second Group"); groupService.create(secondGroup); groupService.addAggregation(event, secondGroup); groupService.addAggregation(organization, secondGroup); event = eventService.findById(event.getId()); assertTrue(event.getGroups().contains(group)); assertTrue(event.getGroups().contains(secondGroup)); group = groupService.findById(group.getId()); assertTrue(group.getAggregations().contains(event)); secondGroup = groupService.findById(secondGroup.getId()); assertTrue(secondGroup.getAggregations().contains(event)); }
public boolean cancelPotentialWork(Event event, ImageView imageView) { final String TAG = "DownloadAndCacheImageTask"; final DownloadAndCacheImageTask bitmapWorkerTask = getBitmapWorkerTask(imageView); // Log.d(TAG, "cancelPotentialWork for event: " + event.getId()); if (bitmapWorkerTask != null) { final String bitmapData = bitmapWorkerTask.selectedEvent.getId(); // If bitmapData is not yet set or it differs from the new data if (bitmapData == null || bitmapData != event.getId()) { // Cancel previous task // Log.d(TAG, "Cancelled task for event: " + event.getName()); bitmapWorkerTask.cancel(true); } else { // The same work is already in progress // Log.d(TAG, "Found task inprogress for event: " + event.getName()); return false; } } else { // Log.d(TAG, "cancelPotentialWork for event: " + event.getId() + " bitmapWorkerTask = null // :("); } // No task associated with the ImageView, or an existing task was cancelled return true; }
@RequestMapping("/events/{eventName}/sponsor-scan/export.csv") public void downloadSponsorScanExport( @PathVariable("eventName") String eventName, HttpServletResponse response, Principal principal) throws IOException { Event event = loadEvent(eventName, principal); List<TicketFieldConfiguration> fields = ticketFieldRepository.findAdditionalFieldsForEvent(event.getId()); response.setContentType("text/csv;charset=UTF-8"); response.setHeader( "Content-Disposition", "attachment; filename=" + eventName + "-sponsor-scan.csv"); try (ServletOutputStream out = response.getOutputStream(); CSVWriter writer = new CSVWriter(new OutputStreamWriter(out))) { for (int marker : BOM_MARKERS) { out.write(marker); } List<String> header = new ArrayList<>(); header.add("Username"); header.add("Timestamp"); header.add("Full name"); header.add("Email"); header.addAll( fields.stream().map(TicketFieldConfiguration::getName).collect(Collectors.toList())); writer.writeNext(header.toArray(new String[header.size()])); userManager .findAllUsers(principal.getName()) .stream() .map(u -> Pair.of(u, userManager.getUserRole(u))) .filter(p -> p.getRight() == Role.SPONSOR) .flatMap( p -> sponsorScanRepository .loadSponsorData( event.getId(), p.getKey().getId(), SponsorScanRepository.DEFAULT_TIMESTAMP) .stream() .map( v -> Pair.of( v, ticketFieldRepository.findAllValuesForTicketId( v.getTicket().getId())))) .map( p -> { DetailedScanData data = p.getLeft(); Map<String, String> descriptions = p.getRight(); return Pair.of( data, fields .stream() .map(x -> descriptions.getOrDefault(x.getName(), "")) .collect(Collectors.toList())); }) .map( p -> { List<String> line = new ArrayList<>(); Ticket ticket = p.getLeft().getTicket(); SponsorScan sponsorScan = p.getLeft().getSponsorScan(); line.add(userManager.findUser(sponsorScan.getUserId()).getUsername()); line.add(sponsorScan.getTimestamp().toString()); line.add(ticket.getFullName()); line.add(ticket.getEmail()); line.addAll(p.getRight()); return line.toArray(new String[line.size()]); }) .forEachOrdered(writer::writeNext); writer.flush(); out.flush(); } }
/** * If the source and target events are visible, draw a line between the source and target, and * save it in the map of lines. This is so that the lines can be removed when changing the * selected event. */ private void drawFamilyStoryLine(Event source, Event target, int width) { if (source == null || target == null) return; if (MainModel.isEventVisible(source.getId()) && MainModel.isEventVisible(target.getId())) { familyLines.add(drawLine(source, target, width, Settings.getFamilyStoryColor())); } }
@Test public void testSave() { Event Event = genEvent(); dataRepository.save(Event); Assert.assertTrue(dataRepository.exists(Event.getId())); }
@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; }