Exemplo n.º 1
0
  private void initializeLikeButton(Context context) {
    likeButton =
        new LikeButton(
            context, likeActionController != null && likeActionController.isObjectLiked());
    likeButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            toggleLike();
          }
        });

    LinearLayout.LayoutParams buttonLayout =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    likeButton.setLayoutParams(buttonLayout);
  }
Exemplo 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();
  }