Ejemplo n.º 1
0
 @Subscribe
 public void onBufferChanged(BufferChangedEvent event) {
   if (event.getBuffer().getId() != mBufferId) {
     return;
   }
   updateUI();
 }
Ejemplo n.º 2
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();
  }
  @Override
  protected void updateUI() {
    super.updateUI();
    if (getView() == null) {
      // View not yet created.
      return;
    }

    boolean isConnected =
        (mConnection != null && mConnection.getState() == Connection.STATE_CONNECTED);
    boolean isJoined = (mChannel != null && mChannel.isJoined());

    View notInChannelView = getView().findViewById(R.id.not_in_channel);
    notInChannelView.setVisibility((!isConnected) || isJoined ? View.GONE : View.VISIBLE);

    getActivity().invalidateOptionsMenu();
  }
Ejemplo n.º 4
0
 @Subscribe
 public void onConnectionChanged(ConnectionChangedEvent event) {
   if (event.getConnection().getId() == mConnectionId) {
     updateUI();
   }
 }