Java Code Examples for com.facebook.model.GraphUser

The following are top voted examples for showing how to use com.facebook.model.GraphUser. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: chat-sdk-android-push-firebase   File: BFacebookManager.java   View source code 7 votes vote down vote up
public static  Promise<List<GraphUser>, BError, Void>  getUserFriendList(){

        final Deferred<List<GraphUser>, BError, Void> deferred = new DeferredObject<>();

        
        if (!Session.getActiveSession().getState().isOpened())
        {
            return deferred.reject(new BError(BError.Code.SESSION_CLOSED));
        }
        Request req = Request.newMyFriendsRequest(Session.getActiveSession(), new Request.GraphUserListCallback() {
            @Override
            public void onCompleted(List<GraphUser> users, Response response) {
                deferred.resolve(users);
            }
        });

        req.executeAsync();
        
        return deferred.promise();
    }
 
Example 2
Project: AndroidBackendlessChat   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 3
Project: AndroidBackendlessChat   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 4
Project: AndroidBackendlessChat   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 5
Project: AndroidBackendlessChat   File: BFacebookManager.java   View source code 6 votes vote down vote up
public static  Promise<List<GraphUser>, BError, Void>  getUserFriendList(){

        final Deferred<List<GraphUser>, BError, Void> deferred = new DeferredObject<>();

        
        if (!Session.getActiveSession().getState().isOpened())
        {
            return deferred.reject(new BError(BError.Code.SESSION_CLOSED));
        }
        Request req = Request.newMyFriendsRequest(Session.getActiveSession(), new Request.GraphUserListCallback() {
            @Override
            public void onCompleted(List<GraphUser> users, Response response) {
                deferred.resolve(users);
            }
        });

        req.executeAsync();
        
        return deferred.promise();
    }
 
Example 6
Project: chat-sdk-android-push-firebase   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 7
Project: chat-sdk-android-push-firebase   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 8
Project: chat-sdk-android-push-firebase   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 9
Project: aptoide-client   File: FragmentSocialTimeline.java   View source code 6 votes vote down vote up
private void startLogin(GraphUser user, Session session) {
    try {
        loginMode = true;
        Fragment fragment = new FragmentSignIn();
        Bundle args = new Bundle();
        args.putInt(FragmentSignIn.LOGIN_MODE_ARG, LoginActivity.Mode.FACEBOOK.ordinal());
        args.putString(FragmentSignIn.LOGIN_PASSWORD_OR_TOKEN_ARG, session.getAccessToken());
        args.putString(FragmentSignIn.LOGIN_USERNAME_ARG, (String) user.getProperty("email"));
        fragment.setArguments(args);
        getChildFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, "tag").setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();

        Analytics.SocialTimeline.login();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 10
Project: pedefacil   File: FbLoginDelegate.java   View source code 6 votes vote down vote up
public void requestUserData( Session session ) {
    // Request user data and show the results
    Request.newMeRequest(session, new Request.GraphUserCallback() {

        @Override
        public void onCompleted(GraphUser user, Response response) {
            if (user != null) {
               User currentUser = new User();
                currentUser.setUserId(user.getId());
                currentUser.setUserName(user.getUsername());
                currentUser.setFirstName(user.getFirstName());
                currentUser.setLastName(user.getLastName());
                currentUser.setDisplayName(user.getName());
                currentUser.setMail((String) user.getProperty("email"));
                currentUser.setProviderDisplayName("Facebook");
                currentUser.setProvider(PROVIDER_NAME);
               FbLoginDelegate.this.mUserHelper.setCurrentUser(currentUser);
                if ( mUserSessionCallback != null) {
                    mUserSessionCallback.onLogin();
                }
            }
        }
    }).executeAsync();
}
 
Example 11
Project: yelo-android   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 12
Project: yelo-android   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 13
Project: yelo-android   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 14
Project: BrillaMXAndroid   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 15
Project: BrillaMXAndroid   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 16
Project: BrillaMXAndroid   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 17
Project: aquaplay   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 18
Project: aquaplay   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 19
Project: aquaplay   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 20
Project: TP-Formation-Android   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 21
Project: TP-Formation-Android   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 22
Project: TP-Formation-Android   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 23
Project: AutoTimeHelper   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 24
Project: AutoTimeHelper   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 25
Project: AutoTimeHelper   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 26
Project: snake-game-aws   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 27
Project: snake-game-aws   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 28
Project: snake-game-aws   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 29
Project: snake-game-aws   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public void call(Session session, SessionState state, Exception exception) {
	if (session.isOpened()) {
		setFacebookSession(session);
		// make request to the /me API
		Request.newMeRequest(session, new Request.GraphUserCallback() {

			// callback after Graph API response with user object
			@Override
			public void onCompleted(GraphUser user, Response response) {
				if (user != null) {
					Toast.makeText(LoginActivity.this,
							"Hello " + user.getName(), Toast.LENGTH_LONG)
							.show();
				}
			}
		}).executeAsync();
	}
}
 
Example 30
Project: CallService-Facebook-sample   File: UserHome.java   View source code 6 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data) {
	switch (requestCode) {
	case PICK_FRIENDS_ACTIVITY:
           /*
		Session session = Session.getActiveSession();
		if(session != null) {
			session.close();
		}
		*/
		
		Collection<GraphUser> selection = FriendPickerData.getSelectedUsers();
		if (selection != null && selection.size() > 0) {
			finish();
		}
	}
}
 
Example 31
Project: CallService-Facebook-sample   File: PickFriendsActivity.java   View source code 6 votes vote down vote up
@Override
protected void onStart() {
	super.onStart();

	try {
		List<GraphUser> selectedUsers = FriendPickerData.getSelectedUsers();
		if (selectedUsers != null) {
			FriendPickerData.setSelectedUsers(null);
			// friendPickerFragment.setSelection(selectedUsers);
		}

		// Load data, unless a query has already taken place.
		friendPickerFragment.loadData(false);
	} catch (Exception ex) {
		onError(ex);
	}
}
 
Example 32
Project: CallService-Facebook-sample   File: MainActivity.java   View source code 6 votes vote down vote up
private void getSelectedFriendData() {
    //check if user's friends available with this app, If not than share / invite and return
    if(!UserHome.hasAppFriends){
        shareOrInvite();
        return;
    }

    Collection<GraphUser> selection = FriendPickerData.getSelectedUsers();
    if (selection != null && selection.size() > 0) {
        GraphUser friend = selection.iterator().next();

        String friendId = friend.getId();
        String friendName = friend.getName();

        Intent intent = new Intent(this, OutgoingCallActivity.class);
        intent.putExtra(EXTRA_REMOTE_USER_ID, friendId);
        intent.putExtra(EXTRA_REMOTE_USER_NAME, friendName);
        startActivityForResult(intent, OUTGOING_CALL_ACTIVITY);
    } else {
        finish();
    }
}
 
Example 33
Project: BrainStudio   File: PruebasFacebook.java   View source code 6 votes vote down vote up
private void onFriendPickerDone(FriendPickerFragment fragment) {
    FragmentManager fm = getSupportFragmentManager();
    fm.popBackStack();

    String results = "";

    List<GraphUser> selection = fragment.getSelection();
    tags = selection;
    if (selection != null && selection.size() > 0) {
        ArrayList<String> names = new ArrayList<String>();
        for (GraphUser user : selection) {
            names.add(user.getName());
        }
        results = TextUtils.join(", ", names);
    } else {
        results = getString(R.string.no_friends_selected);
    }

    showAlert(getString(R.string.you_picked), results);
}
 
Example 34
Project: BrainStudio   File: UserSettingsFragment.java   View source code 6 votes vote down vote up
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
Example 35
Project: BrainStudio   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
PickerFragmentAdapter<GraphUser> createAdapter() {
    PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>(
            this.getActivity()) {

        @Override
        protected int getGraphObjectRowLayoutId(GraphUser graphObject) {
            return R.layout.com_facebook_picker_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return R.drawable.com_facebook_profile_default_icon;
        }

    };
    adapter.setShowCheckbox(true);
    adapter.setShowPicture(getShowPictures());
    adapter.setSortFields(Arrays.asList(new String[]{NAME}));
    adapter.setGroupByField(NAME);

    return adapter;
}
 
Example 36
Project: BrainStudio   File: FriendPickerFragment.java   View source code 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphUser> loader,
        SimpleGraphObjectCursor<GraphUser> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    if (data.areMoreObjectsAvailable()) {
        // We got results, but more are available.
        followNextLink();
    } else {
        // We finished loading results.
        hideActivityCircle();

        // If this was from the cache, schedule a delayed refresh query (unless we got no results
        // at all, in which case refresh immediately.
        if (data.isFromCache()) {
            loader.refreshOriginalRequest(data.getCount() == 0 ? CACHED_RESULT_REFRESH_DELAY : 0);
        }
    }
}
 
Example 37
Project: GeoNote   File: MapViewFragment.java   View source code 6 votes vote down vote up
@Override
protected void onSessionStateChange(Session session, SessionState state, Exception exception){
    final TextView txtUserDetails = (TextView) mCurrentView.findViewById(R.id.mapViewLoggedInUser);
    if (session != null && session.isOpened()) {
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    txtUserDetails.setText("Logged in as " + user.getName());
                    System.out.println("onSessionStateChange: LoadNotes: session is open. username:"+user.getName());
                }
            }
        });
        Request.executeBatchAsync(request);
    } else if (session.isClosed()) {
        txtUserDetails.setText("");
        System.out.println("onSessionStateChange: LoadNotes: session was closed.");
    }
}
 
Example 38
Project: GeoNote   File: BaseFacebookHandlerFragment.java   View source code 6 votes vote down vote up
private void onSessionStateChangeP(Session session, SessionState state, Exception exception)
{
    if (session != null && session.isOpened()) {
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    LoggedInUser = user;
                }
            }
        });
        Request.executeBatchAsync(request);
    } else if (session.isClosed()) {
        LoggedInUser = null;
    }

    onSessionStateChange(session, state, exception);
}
 
Example 39
Project: GeoNote   File: SplashScreenFragment.java   View source code 6 votes vote down vote up
protected void onSessionStateChange(Session session, SessionState state, Exception exception){
    if (session != null && session.isOpened()) {
        logAndShowOnScreen("\nLogged in. Getting user details.");
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    System.out.println("onSessionStateChange: LoadNotes: session is open. username:"+user.getName());

                    loadNotes(getActivity(), user.getId());
                }
            }
        });
        Request.executeBatchAsync(request);
    } else {
        logAndShowOnScreen("\nUser not already logged in.");
        System.out.println("onSessionStateChange: LoadNotes: session was closed.");
        loadNotes(getActivity(), getLoggedInUsername());
    }
}
 
Example 40
Project: GeoNote   File: LoginActivityFB.java   View source code 6 votes vote down vote up
private void populateLoggedInUser() {

            final TextView txtUserDetails = (TextView) this.getActivity().findViewById(R.id.userDetails);

            final Session session = Session.getActiveSession();
            if (session != null && session.isOpened()) {
                // If the session is open, make an API call to get user data
                // and define a new callback to handle the response
                Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        // If the response is successful
                        if (session == Session.getActiveSession()) {
                            if (user != null) {
                                String user_ID = user.getId();//user id
                                String profileName = user.getName();//user's profile name
                                txtUserDetails.setText(user.getName());
                            }
                        }
                    }
                });
                Request.executeBatchAsync(request);
            } else if (session == null || session.isClosed()) {

            }
        }