Exemple #1
0
  @Override
  protected void configureButton(
      final Context context,
      final AttributeSet attrs,
      final int defStyleAttr,
      final int defStyleRes) {
    super.configureButton(context, attrs, defStyleAttr, defStyleRes);
    setInternalOnClickListener(new LoginClickListener());

    parseLoginButtonAttributes(context, attrs, defStyleAttr, defStyleRes);

    if (isInEditMode()) {
      // cannot use a drawable in edit mode, so setting the background color instead
      // of a background resource.
      setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
      // hardcoding in edit mode as getResources().getString() doesn't seem to work in
      // IntelliJ
      loginText = "Log in with Facebook";
    } else {
      accessTokenTracker =
          new AccessTokenTracker() {
            @Override
            protected void onCurrentAccessTokenChanged(
                AccessToken oldAccessToken, AccessToken currentAccessToken) {
              setButtonText();
            }
          };
    }

    setButtonText();
  }
Exemple #2
0
 @Override
 protected void onAttachedToWindow() {
   super.onAttachedToWindow();
   if (accessTokenTracker != null && !accessTokenTracker.isTracking()) {
     accessTokenTracker.startTracking();
     setButtonText();
   }
 }
Exemple #3
0
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   super.onLayout(changed, left, top, right, bottom);
   setButtonText();
 }