本文整理匯總了Java中com.facebook.model.GraphUser類的典型用法代碼示例。如果您正苦於以下問題:Java GraphUser類的具體用法?Java GraphUser怎麽用?Java GraphUser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GraphUser類屬於com.facebook.model包,在下文中一共展示了GraphUser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getUserFriendList
import com.facebook.model.GraphUser; //導入依賴的package包/類
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();
}
示例2: fetchUserInfo
import com.facebook.model.GraphUser; //導入依賴的package包/類
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;
}
}
示例3: createAdapter
import com.facebook.model.GraphUser; //導入依賴的package包/類
@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;
}
示例4: onLoadFinished
import com.facebook.model.GraphUser; //導入依賴的package包/類
@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);
}
}
}
示例5: startLogin
import com.facebook.model.GraphUser; //導入依賴的package包/類
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();
}
}
示例6: requestUserData
import com.facebook.model.GraphUser; //導入依賴的package包/類
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();
}
示例7: call
import com.facebook.model.GraphUser; //導入依賴的package包/類
@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();
}
}
示例8: onActivityResult
import com.facebook.model.GraphUser; //導入依賴的package包/類
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();
}
}
}
示例9: onStart
import com.facebook.model.GraphUser; //導入依賴的package包/類
@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);
}
}
示例10: getSelectedFriendData
import com.facebook.model.GraphUser; //導入依賴的package包/類
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();
}
}
示例11: onFriendPickerDone
import com.facebook.model.GraphUser; //導入依賴的package包/類
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);
}
示例12: onSessionStateChange
import com.facebook.model.GraphUser; //導入依賴的package包/類
@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.");
}
}
示例13: onSessionStateChangeP
import com.facebook.model.GraphUser; //導入依賴的package包/類
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);
}
示例14: onSessionStateChange
import com.facebook.model.GraphUser; //導入依賴的package包/類
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());
}
}
示例15: populateLoggedInUser
import com.facebook.model.GraphUser; //導入依賴的package包/類
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()) {
}
}