コード例 #1
0
  /**
   * Process the received protocol buffer
   *
   * @param clementineMessage The Message received from Clementine
   */
  private void processProtocolBuffer(ClementineMessage clementineMessage) {
    // Close the connection if we have an old proto verion
    if (clementineMessage.isErrorMessage()) {
      closeConnection(clementineMessage);
    } else if (clementineMessage.getTypeGroup() == MessageGroup.GUI_RELOAD) {
      sendUiMessage(clementineMessage);

      // Now update the notification and the remote control client
      if (App.mClementine.getCurrentSong() != mLastSong) {
        mLastSong = App.mClementine.getCurrentSong();
        updateNotification();
        updateRemoteControlClient();
        mPebble.sendMusicUpdateToPebble();
      }
      if (App.mClementine.getState() != mLastState) {
        mLastState = App.mClementine.getState();
        updateRemoteControlClient();
      }
    } else if (clementineMessage.getMessageType() == MsgType.DISCONNECT) {
      closeConnection(clementineMessage);
    } else {
      sendUiMessage(clementineMessage);
    }
  }