/** * Return the event info for a given position in the adapter * * @param positionInListView * @param returnEventStartDay If true, return actual event startday. Otherwise return agenda * date-header date as the startDay. The two will differ for multi-day events after the first * day. * @return */ public AgendaItem getAgendaItemByPosition( final int positionInListView, boolean returnEventStartDay) { if (DEBUGLOG) Log.e(TAG, "getEventByPosition " + positionInListView); if (positionInListView < 0) { return null; } final int positionInAdapter = positionInListView - OFF_BY_ONE_BUG; DayAdapterInfo info = getAdapterInfoByPosition(positionInAdapter); if (info == null) { return null; } int cursorPosition = info.dayAdapter.getCursorPosition(positionInAdapter - info.offset); if (cursorPosition == Integer.MIN_VALUE) { return null; } boolean isDayHeader = false; if (cursorPosition < 0) { cursorPosition = -cursorPosition; isDayHeader = true; } if (cursorPosition < info.cursor.getCount()) { AgendaItem item = buildAgendaItemFromCursor(info.cursor, cursorPosition, isDayHeader); if (!returnEventStartDay && !isDayHeader) { item.startDay = info.dayAdapter.findJulianDayFromPosition(positionInAdapter - info.offset); } return item; } return null; }
private AgendaItem buildAgendaItemFromCursor( final Cursor cursor, int cursorPosition, boolean isDayHeader) { if (cursorPosition == -1) { cursor.moveToFirst(); } else { cursor.moveToPosition(cursorPosition); } AgendaItem agendaItem = new AgendaItem(); agendaItem.begin = cursor.getLong(AgendaWindowAdapter.INDEX_BEGIN); agendaItem.end = cursor.getLong(AgendaWindowAdapter.INDEX_END); agendaItem.startDay = cursor.getInt(AgendaWindowAdapter.INDEX_START_DAY); agendaItem.allDay = cursor.getInt(AgendaWindowAdapter.INDEX_ALL_DAY) != 0; if (agendaItem.allDay) { // UTC to Local time conversion Time time = new Time(mTimeZone); time.setJulianDay(Time.getJulianDay(agendaItem.begin, 0)); agendaItem.begin = time.toMillis(false /* use isDst */); } else if (isDayHeader) { // Trim to midnight. Time time = new Time(mTimeZone); time.set(agendaItem.begin); time.hour = 0; time.minute = 0; time.second = 0; agendaItem.begin = time.toMillis(false /* use isDst */); } // If this is not a day header, then it's an event. if (!isDayHeader) { agendaItem.id = cursor.getLong(AgendaWindowAdapter.INDEX_EVENT_ID); if (agendaItem.allDay) { Time time = new Time(mTimeZone); time.setJulianDay(Time.getJulianDay(agendaItem.end, 0)); agendaItem.end = time.toMillis(false /* use isDst */); } } return agendaItem; }
public LinkedList<LogicalDependency<SimpleMode>> getBlocked() { return agendaItem.getBlocked(); }
public void setSalience(int salience) { agendaItem.setSalience(salience); }
public TerminalNode getTerminalNode() { return agendaItem.getTerminalNode(); }
public boolean isActive() { return agendaItem.isActive(); }
public boolean isMatched() { return agendaItem.isMatched(); }
public PropagationContext getPropagationContext() { return agendaItem.getPropagationContext(); }
public ActivationNode getActivationNode() { return agendaItem.getActivationNode(); }
public void cancel() { agendaItem.cancel(); }
public List<String> getDeclarationIds() { return agendaItem.getDeclarationIds(); }
public Tuple getTuple() { return agendaItem.getTuple(); }
public RuleAgendaItem getRuleAgendaItem() { return agendaItem.getRuleAgendaItem(); }
public Object getDeclarationValue(String variableName) { return agendaItem.getDeclarationValue(variableName); }
public LinkedList<SimpleMode> getBlockers() { return agendaItem.getBlockers(); }
public void setLogicalDependencies(LinkedList<LogicalDependency<T>> justified) { agendaItem.setLogicalDependencies(justified); }
public List<FactHandle> getFactHandles() { return agendaItem.getFactHandles(); }
public void setActivationNode(ActivationNode activationNode) { agendaItem.setActivationNode(activationNode); }
public void setPropagationContext(PropagationContext context) { agendaItem.setPropagationContext(context); }
public GroupElement getSubRule() { return agendaItem.getSubRule(); }
public void setMatched(boolean matched) { agendaItem.setMatched(matched); }
public void removeAllBlockersAndBlocked(InternalAgenda agenda) { agendaItem.removeAllBlockersAndBlocked(agenda); }
public void setActive(boolean active) { agendaItem.setActive(active); }
public boolean isCanceled() { return agendaItem.isCanceled(); }
public int getSalience() { return agendaItem.getSalience(); }
public List<Object> getObjects() { return agendaItem.getObjects(); }
public String toExternalForm() { return agendaItem.toExternalForm(); }
public boolean isRuleAgendaItem() { return agendaItem.isRuleAgendaItem(); }
public void setBlocked(LinkedList<LogicalDependency<SimpleMode>> justified) { agendaItem.setBlocked(justified); }
public LinkedList<LogicalDependency<T>> getLogicalDependencies() { return agendaItem.getLogicalDependencies(); }