Ejemplo n.º 1
0
    @Override
    public void onComplete(LikeActionController likeActionController, FacebookException error) {
      if (isCancelled) {
        return;
      }

      if (likeActionController != null) {
        if (!likeActionController.shouldEnableView()) {
          error = new FacebookException("Cannot use LikeView. The device may not be supported.");
        }

        // Always associate with the controller, so it can get updates if the view gets
        // enabled again.
        associateWithLikeActionController(likeActionController);
        updateLikeStateAndLayout();
      }

      if (error != null) {
        if (onErrorListener != null) {
          onErrorListener.onError(error);
        }
      }

      LikeView.this.creationCallback = null;
    }
Ejemplo n.º 2
0
  private void updateLikeStateAndLayout() {
    boolean enabled = !explicitlyDisabled;

    if (likeActionController == null) {
      likeButton.setSelected(false);
      socialSentenceView.setText(null);
      likeBoxCountView.setText(null);
    } else {
      likeButton.setSelected(likeActionController.isObjectLiked());
      socialSentenceView.setText(likeActionController.getSocialSentence());
      likeBoxCountView.setText(likeActionController.getLikeCountString());

      enabled &= likeActionController.shouldEnableView();
    }

    super.setEnabled(enabled);
    likeButton.setEnabled(enabled);

    updateLayout();
  }