Пример #1
0
 @Override
 public Subscription onSubscribe(Observer<? super TResult> t1) {
   VirtualList<TIntermediate> values;
   Throwable error;
   state.lock();
   try {
     if (!state.done) {
       state.onSubscription.call();
       return state.addReplayer(t1);
     }
     values = state.values;
     error = state.error;
   } finally {
     state.unlock();
   }
   // fully replay the subject
   for (int i = values.start(); i < values.end(); i++) {
     try {
       t1.onNext(state.resultSelector.call(values.get(i)));
     } catch (Throwable t) {
       t1.onError(t);
       return Subscriptions.empty();
     }
   }
   if (error != null) {
     t1.onError(error);
   } else {
     t1.onCompleted();
   }
   return Subscriptions.empty();
 }
 protected void pointerPressed(int x, int y) {
   super.pointerPressed(x, y);
   if (x >= xCnt * imgWidth) return;
   xCursor = x / imgWidth;
   setRotator();
   if (cursor != lines - 1) return;
   if (xCursor >= xLastCnt) xCursor = xLastCnt - 1;
 }
 // }
 public void drawCursor(Graphics g, int width, int height) {
   int x = xCursor * imgWidth;
   g.setColor(ColorScheme.LIST_BGND);
   g.fillRect(0, 0, width, height);
   g.translate(x, 0);
   super.drawCursor(g, imgWidth, lineHeight);
   g.translate(-x, 0);
 }
Пример #4
0
 /** Clears the value list. */
 void clearValues() {
   lock();
   try {
     values.clear();
   } finally {
     unlock();
   }
 }
  public void userKeyPressed(int keyCode) {
    super.userKeyPressed(keyCode);

    switch (keyCode) {
      case KEY_NUM3:
        super.pageLeft();
        keyDwn();
        break;
      case KEY_NUM9:
        super.pageRight();
        break;
      case KEY_NUM4:
        super.pageLeft();
        break;
      case KEY_NUM6:
        super.pageRight();
        break;
    }
  }
Пример #6
0
    /**
     * Add a replayer to the replayers and create a Subscription for it.
     *
     * <p>Caller should hold the lock.
     *
     * @param obs
     * @return
     */
    Subscription addReplayer(Observer<? super TResult> obs) {
      Subscription s =
          new Subscription() {
            final AtomicBoolean once = new AtomicBoolean();

            @Override
            public void unsubscribe() {
              if (once.compareAndSet(false, true)) {
                remove(this);
              }
            }

            @Override
            public boolean isUnsubscribed() {
              return once.get();
            }
          };
      Replayer rp = new Replayer(obs, s);
      replayers.put(s, rp);
      rp.replayTill(values.start() + values.size());
      return s;
    }
 public void moveCursorHome() {
   super.moveCursorHome();
   xCursor = 0;
 }
 public void moveCursorEnd() {
   super.moveCursorEnd();
   xCursor = xLastCnt - 1;
 }
 public void keyDwn() {
   super.keyDwn();
   if (cursor != lines - 1) return;
   if (xCursor >= xLastCnt) xCursor = xLastCnt - 1;
 }
Пример #10
0
 /**
  * Add a notification value and limit the size of values.
  *
  * <p>Caller should hold the lock.
  *
  * @param value
  */
 void add(TIntermediate value) {
   values.add(value);
 }