Search in sources :

Example 1 with ProfilePictureView

use of com.facebook.login.widget.ProfilePictureView in project facebook-android-sdk by facebook.

the class SelectionFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.selection, container, false);
    profilePictureView = (ProfilePictureView) view.findViewById(R.id.selection_profile_pic);
    profilePictureView.setCropped(true);
    announceButton = (TextView) view.findViewById(R.id.announce_text);
    shareButton = (ShareButton) view.findViewById(R.id.share_button);
    messageButton = (SendButton) view.findViewById(R.id.message_button);
    listView = (ListView) view.findViewById(R.id.selection_list);
    photoThumbnail = (ImageView) view.findViewById(R.id.selected_image);
    announceProgressDialog = new ProgressDialog(getActivity());
    announceProgressDialog.setMessage(getString(R.string.progress_dialog_text));
    if (MessageDialog.canShow(ShareOpenGraphContent.class)) {
        messageButton.setVisibility(View.VISIBLE);
    }
    announceButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            handleAnnounce();
        }
    });
    messageButton.registerCallback(callbackManager, shareCallback);
    messageButton.setFragment(this);
    shareButton.registerCallback(callbackManager, shareCallback);
    shareButton.setFragment(this);
    profilePictureView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (AccessToken.getCurrentAccessToken() != null) {
                activity.showSettingsFragment();
            } else {
                activity.showSplashFragment();
            }
        }
    });
    init(savedInstanceState);
    updateWithToken(AccessToken.getCurrentAccessToken());
    return view;
}
Also used : ProgressDialog(android.app.ProgressDialog) View(android.view.View) ProfilePictureView(com.facebook.login.widget.ProfilePictureView)

Example 2 with ProfilePictureView

use of com.facebook.login.widget.ProfilePictureView in project facebook-android-sdk by facebook.

the class FacebookLoginActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_facebook_login);
    callbackManager = CallbackManager.Factory.create();
    fbLoginButton = (LoginButton) findViewById(R.id._fb_login);
    profilePictureView = (ProfilePictureView) findViewById(R.id.user_pic);
    profilePictureView.setCropped(true);
    userNameView = (TextView) findViewById(R.id.user_name);
    final Button deAuthButton = (Button) findViewById(R.id.deauth);
    deAuthButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (!isLoggedIn()) {
                Toast.makeText(FacebookLoginActivity.this, R.string.app_not_logged_in, Toast.LENGTH_LONG).show();
                return;
            }
            GraphRequest.Callback callback = new GraphRequest.Callback() {

                @Override
                public void onCompleted(GraphResponse response) {
                    try {
                        if (response.getError() != null) {
                            Toast.makeText(FacebookLoginActivity.this, getResources().getString(R.string.failed_to_deauth, response.toString()), Toast.LENGTH_LONG).show();
                        } else if (response.getJSONObject().getBoolean(SUCCESS)) {
                            LoginManager.getInstance().logOut();
                        // updateUI();?
                        }
                    } catch (JSONException ex) {
                    /* no op */
                    }
                }
            };
            GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(), GRAPH_PATH, new Bundle(), HttpMethod.DELETE, callback);
            request.executeAsync();
        }
    });
    final Button permsButton = (Button) findViewById(R.id.perms);
    permsButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(final View v) {
            Intent selectPermsIntent = new Intent(FacebookLoginActivity.this, PermissionSelectActivity.class);
            startActivityForResult(selectPermsIntent, PICK_PERMS_REQUEST);
        }
    });
    // Callback registration
    fbLoginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {

        @Override
        public void onSuccess(final LoginResult loginResult) {
            // App code
            Toast.makeText(FacebookLoginActivity.this, R.string.success, Toast.LENGTH_LONG).show();
            updateUI();
        }

        @Override
        public void onCancel() {
            // App code
            Toast.makeText(FacebookLoginActivity.this, R.string.cancel, Toast.LENGTH_LONG).show();
        }

        @Override
        public void onError(final FacebookException exception) {
            // App code
            Toast.makeText(FacebookLoginActivity.this, R.string.error, Toast.LENGTH_LONG).show();
        }
    });
    new ProfileTracker() {

        @Override
        protected void onCurrentProfileChanged(final Profile oldProfile, final Profile currentProfile) {
            updateUI();
        }
    };
}
Also used : GraphRequest(com.facebook.GraphRequest) Bundle(android.os.Bundle) LoginResult(com.facebook.login.LoginResult) JSONException(org.json.JSONException) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) ProfilePictureView(com.facebook.login.widget.ProfilePictureView) Profile(com.facebook.Profile) FacebookCallback(com.facebook.FacebookCallback) ProfileTracker(com.facebook.ProfileTracker) Button(android.widget.Button) LoginButton(com.facebook.login.widget.LoginButton) GraphResponse(com.facebook.GraphResponse) FacebookException(com.facebook.FacebookException)

Example 3 with ProfilePictureView

use of com.facebook.login.widget.ProfilePictureView in project facebook-android-sdk by facebook.

the class ProfileFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_profile, parent, false);
    userNameView = (TextView) v.findViewById(R.id.profileUserName);
    profilePictureView = (ProfilePictureView) v.findViewById(R.id.profilePic);
    if (pendingUpdateForUser != null) {
        setProfile(pendingUpdateForUser);
        pendingUpdateForUser = null;
    }
    return v;
}
Also used : TextView(android.widget.TextView) ProfilePictureView(com.facebook.login.widget.ProfilePictureView)

Example 4 with ProfilePictureView

use of com.facebook.login.widget.ProfilePictureView in project facebook-android-sdk by facebook.

the class HelloFacebookSampleActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {

        @Override
        public void onSuccess(LoginResult loginResult) {
            handlePendingAction();
            updateUI();
        }

        @Override
        public void onCancel() {
            if (pendingAction != PendingAction.NONE) {
                showAlert();
                pendingAction = PendingAction.NONE;
            }
            updateUI();
        }

        @Override
        public void onError(FacebookException exception) {
            if (pendingAction != PendingAction.NONE && exception instanceof FacebookAuthorizationException) {
                showAlert();
                pendingAction = PendingAction.NONE;
            }
            updateUI();
        }

        private void showAlert() {
            new AlertDialog.Builder(HelloFacebookSampleActivity.this).setTitle(R.string.cancelled).setMessage(R.string.permission_not_granted).setPositiveButton(R.string.ok, null).show();
        }
    });
    shareDialog = new ShareDialog(this);
    shareDialog.registerCallback(callbackManager, shareCallback);
    if (savedInstanceState != null) {
        String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY);
        pendingAction = PendingAction.valueOf(name);
    }
    setContentView(R.layout.main);
    profileTracker = new ProfileTracker() {

        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            updateUI();
            // It's possible that we were waiting for Profile to be populated in order to
            // post a status update.
            handlePendingAction();
        }
    };
    profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture);
    greeting = (TextView) findViewById(R.id.greeting);
    postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton);
    postStatusUpdateButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            onClickPostStatusUpdate();
        }
    });
    postPhotoButton = (Button) findViewById(R.id.postPhotoButton);
    postPhotoButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            onClickPostPhoto();
        }
    });
    // Can we present the share dialog for regular links?
    canPresentShareDialog = ShareDialog.canShow(ShareLinkContent.class);
    // Can we present the share dialog for photos?
    canPresentShareDialogWithPhotos = ShareDialog.canShow(SharePhotoContent.class);
}
Also used : AlertDialog(android.app.AlertDialog) ShareLinkContent(com.facebook.share.model.ShareLinkContent) SharePhotoContent(com.facebook.share.model.SharePhotoContent) ShareDialog(com.facebook.share.widget.ShareDialog) LoginResult(com.facebook.login.LoginResult) View(android.view.View) ProfilePictureView(com.facebook.login.widget.ProfilePictureView) TextView(android.widget.TextView) Profile(com.facebook.Profile) FacebookException(com.facebook.FacebookException)

Aggregations

ProfilePictureView (com.facebook.login.widget.ProfilePictureView)4 View (android.view.View)3 TextView (android.widget.TextView)3 FacebookException (com.facebook.FacebookException)2 Profile (com.facebook.Profile)2 LoginResult (com.facebook.login.LoginResult)2 AlertDialog (android.app.AlertDialog)1 ProgressDialog (android.app.ProgressDialog)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Button (android.widget.Button)1 FacebookCallback (com.facebook.FacebookCallback)1 GraphRequest (com.facebook.GraphRequest)1 GraphResponse (com.facebook.GraphResponse)1 ProfileTracker (com.facebook.ProfileTracker)1 LoginButton (com.facebook.login.widget.LoginButton)1 ShareLinkContent (com.facebook.share.model.ShareLinkContent)1 SharePhotoContent (com.facebook.share.model.SharePhotoContent)1 ShareDialog (com.facebook.share.widget.ShareDialog)1 JSONException (org.json.JSONException)1