Ejemplo n.º 1
0
  @Subscribe
  public void onServiceStateChanged(ServiceStateChangedEvent event) {
    TapchatService service = event.getService();

    if (service.getConnectionState() == TapchatService.STATE_LOADED) {
      if (mConnection == null && mBuffer == null) {
        mConnection = service.getConnection(mConnectionId);
        if (mConnection == null) {
          throw new IllegalStateException(
              "Connection not found. "
                  + mConnectionId
                  + " connections: "
                  + service.getConnections());
        }

        mBuffer = mConnection.getBuffer(mBufferId);
        if (mBuffer == null) {
          throw new IllegalStateException(
              "Buffer not found. " + mBufferId + " buffers: " + mConnection.getBuffers());
        }
      }
    } else {
      mConnection = null;
      mBuffer = null;
    }

    mConnectionState = service.getConnectionState();
    updateUI();
  }
  @Subscribe
  @Override
  public void onServiceStateChanged(ServiceStateChangedEvent event) {
    super.onServiceStateChanged(event);

    TapchatService service = event.getService();

    if (service.getConnectionState() == TapchatService.STATE_LOADED) {
      mChannel = (ChannelBuffer) mBuffer;
    } else {
      mChannel = null;
    }

    updateUI();
  }