Beispiel #1
0
 private boolean moveToNext() {
   try {
     Notification<? extends T> nextNotification = observer.takeNext();
     if (nextNotification.isOnNext()) {
       isNextConsumed = false;
       next = nextNotification.getValue();
       return true;
     }
     // If an observable is completed or fails,
     // hasNext() always return false.
     hasNext = false;
     if (nextNotification.isOnCompleted()) {
       return false;
     }
     if (nextNotification.isOnError()) {
       error = nextNotification.getThrowable();
       throw Exceptions.propagate(error);
     }
     throw new IllegalStateException("Should not reach here");
   } catch (InterruptedException e) {
     Thread.currentThread().interrupt();
     error = e;
     throw Exceptions.propagate(error);
   }
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      // FIXME
      if (null == convertView) {
        convertView =
            LayoutInflater.from(parent.getContext())
                .inflate(R.layout.view_debug_subscriptions_stats, parent, false);
      }

      TextView countTextView = (TextView) convertView.findViewById(R.id.count);
      TextView infoTextView = (TextView) convertView.findViewById(R.id.info);
      RxDebugger.Stats stats = getItem(position);

      countTextView.setText("" + stats.onNextCount);
      if (null != stats.mostRecentNotification) {
        Notification n = stats.mostRecentNotification;
        switch (n.getKind()) {
          case OnNext:
            @Nullable Object value = n.getValue();
            infoTextView.setText(
                String.format(
                    "NEXT %s", null != value ? value.getClass().getSimpleName() : "null"));
            break;
          case OnCompleted:
            infoTextView.setText("COMPLETED");
            break;
          case OnError:
            infoTextView.setText("ERROR");
            break;
        }
      } else {
        infoTextView.setText("");
      }

      return convertView;
    }
  @Override
  protected void match() {
    if (!jo1.queue().isEmpty()
        && !jo2.queue().isEmpty()
        && !jo3.queue().isEmpty()
        && !jo4.queue().isEmpty()
        && !jo5.queue().isEmpty()
        && !jo6.queue().isEmpty()
        && !jo7.queue().isEmpty()) {
      Notification<T1> n1 = jo1.queue().peek();
      Notification<T2> n2 = jo2.queue().peek();
      Notification<T3> n3 = jo3.queue().peek();
      Notification<T4> n4 = jo4.queue().peek();
      Notification<T5> n5 = jo5.queue().peek();
      Notification<T6> n6 = jo6.queue().peek();
      Notification<T7> n7 = jo7.queue().peek();

      if (n1.isOnCompleted()
          || n2.isOnCompleted()
          || n3.isOnCompleted()
          || n4.isOnCompleted()
          || n5.isOnCompleted()
          || n6.isOnCompleted()
          || n7.isOnCompleted()) {
        onCompleted.call();
      } else {
        dequeue();
        onNext.call(
            n1.getValue(),
            n2.getValue(),
            n3.getValue(),
            n4.getValue(),
            n5.getValue(),
            n6.getValue(),
            n7.getValue());
      }
    }
  }