Пример #1
0
  /**
   * 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;
  }
Пример #2
0
  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;
  }
Пример #3
0
 public LinkedList<LogicalDependency<SimpleMode>> getBlocked() {
   return agendaItem.getBlocked();
 }
Пример #4
0
 public void setSalience(int salience) {
   agendaItem.setSalience(salience);
 }
Пример #5
0
 public TerminalNode getTerminalNode() {
   return agendaItem.getTerminalNode();
 }
Пример #6
0
 public boolean isActive() {
   return agendaItem.isActive();
 }
Пример #7
0
 public boolean isMatched() {
   return agendaItem.isMatched();
 }
Пример #8
0
 public PropagationContext getPropagationContext() {
   return agendaItem.getPropagationContext();
 }
Пример #9
0
 public ActivationNode getActivationNode() {
   return agendaItem.getActivationNode();
 }
Пример #10
0
 public void cancel() {
   agendaItem.cancel();
 }
Пример #11
0
 public List<String> getDeclarationIds() {
   return agendaItem.getDeclarationIds();
 }
Пример #12
0
 public Tuple getTuple() {
   return agendaItem.getTuple();
 }
Пример #13
0
 public RuleAgendaItem getRuleAgendaItem() {
   return agendaItem.getRuleAgendaItem();
 }
Пример #14
0
 public Object getDeclarationValue(String variableName) {
   return agendaItem.getDeclarationValue(variableName);
 }
Пример #15
0
 public LinkedList<SimpleMode> getBlockers() {
   return agendaItem.getBlockers();
 }
Пример #16
0
 public void setLogicalDependencies(LinkedList<LogicalDependency<T>> justified) {
   agendaItem.setLogicalDependencies(justified);
 }
Пример #17
0
 public List<FactHandle> getFactHandles() {
   return agendaItem.getFactHandles();
 }
Пример #18
0
 public void setActivationNode(ActivationNode activationNode) {
   agendaItem.setActivationNode(activationNode);
 }
Пример #19
0
 public void setPropagationContext(PropagationContext context) {
   agendaItem.setPropagationContext(context);
 }
Пример #20
0
 public GroupElement getSubRule() {
   return agendaItem.getSubRule();
 }
Пример #21
0
 public void setMatched(boolean matched) {
   agendaItem.setMatched(matched);
 }
Пример #22
0
 public void removeAllBlockersAndBlocked(InternalAgenda agenda) {
   agendaItem.removeAllBlockersAndBlocked(agenda);
 }
Пример #23
0
 public void setActive(boolean active) {
   agendaItem.setActive(active);
 }
Пример #24
0
 public boolean isCanceled() {
   return agendaItem.isCanceled();
 }
Пример #25
0
 public int getSalience() {
   return agendaItem.getSalience();
 }
Пример #26
0
 public List<Object> getObjects() {
   return agendaItem.getObjects();
 }
Пример #27
0
 public String toExternalForm() {
   return agendaItem.toExternalForm();
 }
Пример #28
0
 public boolean isRuleAgendaItem() {
   return agendaItem.isRuleAgendaItem();
 }
Пример #29
0
 public void setBlocked(LinkedList<LogicalDependency<SimpleMode>> justified) {
   agendaItem.setBlocked(justified);
 }
Пример #30
0
 public LinkedList<LogicalDependency<T>> getLogicalDependencies() {
   return agendaItem.getLogicalDependencies();
 }