@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); eventList = EventFactory.generateDiverseEventList(); iterator = new EventIterator(eventList); progressBar = (ProgressBar) findViewById(R.id.progressBar); progressBar.setMax(iterator.getSize() - 1); myText = (TextView) findViewById(R.id.m_description); myTitle = (TextView) findViewById(R.id.title); displayEvent(iterator.current()); }
/** * Get the next event in the sequence. This will never be an EventIterator. * * @return the next event, or null when the sequence is exhausted * @throws org.orbeon.saxon.trans.XPathException if a dynamic evaluation error occurs */ public PullEvent next() throws XPathException { if (eventStack.isEmpty()) { return null; } EventIterator iter = (EventIterator) eventStack.peek(); PullEvent next = iter.next(); if (next == null) { eventStack.pop(); return next(); } else if (next instanceof EventIterator) { eventStack.push(next); return next(); } else { return next; } }
/** * Factory method to create an iterator that flattens the sequence of PullEvents received from a * base iterator, that is, it returns an EventIterator that will never return any nested * iterators. * * @param base the base iterator. Any nested EventIterator returned by the base iterator will be * flattened, recursively. */ public static EventIterator flatten(EventIterator base) { if (base.isFlatSequence()) { return base; } return new EventStackIterator(base); }
public void updateProgressBar() { if (progressBar.getMax() > (iterator.getSize() - 1)) { progressBar.setMax(iterator.getSize() - 1); } progressBar.setProgress(iterator.getIndexNum()); }
public void displayEvent(Event event) { String titleString = event.getEventName(); String displayString = event.toString(); myText.setText(displayString.toString() + iterator.getIndexNum()); myTitle.setText(titleString.toString()); }
public void updateDisplay() { updateProgressBar(); displayEvent(iterator.current()); }
public void nextOnClick(View v) { iterator.advance(); updateDisplay(); }
public void likeOnClick(View v) { likedEventList.add(iterator.remove()); updateDisplay(); }
public void hateOnClick(View v) { iterator.delete(); updateDisplay(); }