コード例 #1
0
 @Subscribe
 public void onBufferChanged(BufferChangedEvent event) {
   if (event.getBuffer().getId() != mBufferId) {
     return;
   }
   updateUI();
 }
コード例 #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();
  }
コード例 #3
0
  @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();
  }
コード例 #4
0
 @Subscribe
 public void onConnectionChanged(ConnectionChangedEvent event) {
   if (event.getConnection().getId() == mConnectionId) {
     updateUI();
   }
 }