/**
   * 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();
 }
Beispiel #10
0
 public void cancel() {
   agendaItem.cancel();
 }
Beispiel #11
0
 public List<String> getDeclarationIds() {
   return agendaItem.getDeclarationIds();
 }
Beispiel #12
0
 public Tuple getTuple() {
   return agendaItem.getTuple();
 }
Beispiel #13
0
 public RuleAgendaItem getRuleAgendaItem() {
   return agendaItem.getRuleAgendaItem();
 }
Beispiel #14
0
 public Object getDeclarationValue(String variableName) {
   return agendaItem.getDeclarationValue(variableName);
 }
Beispiel #15
0
 public LinkedList<SimpleMode> getBlockers() {
   return agendaItem.getBlockers();
 }
Beispiel #16
0
 public void setLogicalDependencies(LinkedList<LogicalDependency<T>> justified) {
   agendaItem.setLogicalDependencies(justified);
 }
Beispiel #17
0
 public List<FactHandle> getFactHandles() {
   return agendaItem.getFactHandles();
 }
Beispiel #18
0
 public void setActivationNode(ActivationNode activationNode) {
   agendaItem.setActivationNode(activationNode);
 }
Beispiel #19
0
 public void setPropagationContext(PropagationContext context) {
   agendaItem.setPropagationContext(context);
 }
Beispiel #20
0
 public GroupElement getSubRule() {
   return agendaItem.getSubRule();
 }
Beispiel #21
0
 public void setMatched(boolean matched) {
   agendaItem.setMatched(matched);
 }
Beispiel #22
0
 public void removeAllBlockersAndBlocked(InternalAgenda agenda) {
   agendaItem.removeAllBlockersAndBlocked(agenda);
 }
Beispiel #23
0
 public void setActive(boolean active) {
   agendaItem.setActive(active);
 }
Beispiel #24
0
 public boolean isCanceled() {
   return agendaItem.isCanceled();
 }
Beispiel #25
0
 public int getSalience() {
   return agendaItem.getSalience();
 }
Beispiel #26
0
 public List<Object> getObjects() {
   return agendaItem.getObjects();
 }
Beispiel #27
0
 public String toExternalForm() {
   return agendaItem.toExternalForm();
 }
Beispiel #28
0
 public boolean isRuleAgendaItem() {
   return agendaItem.isRuleAgendaItem();
 }
Beispiel #29
0
 public void setBlocked(LinkedList<LogicalDependency<SimpleMode>> justified) {
   agendaItem.setBlocked(justified);
 }
Beispiel #30
0
 public LinkedList<LogicalDependency<T>> getLogicalDependencies() {
   return agendaItem.getLogicalDependencies();
 }