本文整理汇总了Java中com.facebook.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于com.facebook包,在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserFriendList
import com.facebook.Response; //导入依赖的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: requestUserData
import com.facebook.Response; //导入依赖的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();
}
示例3: fetchUserInfo
import com.facebook.Response; //导入依赖的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;
}
}
示例4: followNextLink
import com.facebook.Response; //导入依赖的package包/类
public void followNextLink() {
if (nextRequest != null) {
appendResults = true;
currentRequest = nextRequest;
currentRequest.setCallback(new Request.Callback() {
@Override
public void onCompleted(Response response) {
requestCompleted(response);
}
});
loading = true;
CacheableRequestBatch batch = putRequestIntoBatch(currentRequest, skipRoundtripIfCached);
Request.executeBatchAsync(batch);
}
}
示例5: requestCompleted
import com.facebook.Response; //导入依赖的package包/类
private void requestCompleted(Response response) {
Request request = response.getRequest();
if (request != currentRequest) {
return;
}
loading = false;
currentRequest = null;
FacebookRequestError requestError = response.getError();
FacebookException exception = (requestError == null) ? null : requestError.getException();
if (response.getGraphObject() == null && exception == null) {
exception = new FacebookException("GraphObjectPagingLoader received neither a result nor an error.");
}
if (exception != null) {
nextRequest = null;
if (onErrorListener != null) {
onErrorListener.onError(exception, this);
}
} else {
addResults(response);
}
}
示例6: postStatus
import com.facebook.Response; //导入依赖的package包/类
public void postStatus(View view){
EditText editText = (EditText) findViewById(R.id.editText);
final String statusText = editText.getText().toString();
Session session = Session.getActiveSession();
if (session != null) {
if (session.isOpened() && hasPublishPermission()) {
Request request = Request
.newStatusUpdateRequest(Session.getActiveSession(), statusText, null, null, new Request.Callback() {
@Override
public void onCompleted(Response response) {
showPublishResult(statusText, response.getGraphObject(), response.getError());
}
});
request.executeAsync();
return;
}
else {
Toast.makeText(this, getString(R.string.err_notConnected), Toast.LENGTH_SHORT).show();
}
}
else {
Toast.makeText(this, getString(R.string.err_notConnected), Toast.LENGTH_SHORT).show();
}
}
示例7: onSessionStateChange
import com.facebook.Response; //导入依赖的package包/类
/**
* Changes the UI when an interaction with the Session object occurs with the user.
* @param session The current active Session.
* @param sessionState The current state of the active Session.
* @param e An Exception if there is one.
*/
private void onSessionStateChange(Session session, SessionState sessionState, Exception e) {
if (sessionState == SessionState.OPENED) {
Log.d(TAG, "Successful login!");
new Request(session, "/me", null, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
JSONObject obj = response.getGraphObject().getInnerJSONObject();
Log.d(TAG, "Got back " + obj + " from Facebook API.");
UserSession.getInstance().setFacebookData(obj);
getUserData();
}
}).executeAsync();
} else if (e != null) { // handle exception
}
}
示例8: call
import com.facebook.Response; //导入依赖的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();
}
}
示例9: populateContact
import com.facebook.Response; //导入依赖的package包/类
public void populateContact() {
final Session session = Session.getActiveSession();
new Request(session, "/me/friends", null, HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
// Process the returned response
GraphObject graphObject = response.getGraphObject();
if (graphObject != null) {
// Check if there is extra data
if (graphObject.getProperty("data") != null) {
JSONArray arrayObject = (JSONArray) graphObject
.getProperty("data");
int count = arrayObject.length();
if(count == 0)
hasAppFriends = false;
// Ensure the user has at least one friend
//session.close();
}
}
}
}).executeAsync();
}
示例10: onSessionStateChange
import com.facebook.Response; //导入依赖的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.");
}
}
示例11: onSessionStateChangeP
import com.facebook.Response; //导入依赖的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);
}
示例12: onSessionStateChange
import com.facebook.Response; //导入依赖的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());
}
}
示例13: populateLoggedInUser
import com.facebook.Response; //导入依赖的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()) {
}
}
示例14: onLoginFacebookCallback
import com.facebook.Response; //导入依赖的package包/类
private void onLoginFacebookCallback(final Session paramSession)
{
if (paramSession.isOpened())
Request.newMeRequest(paramSession, new Request.GraphUserCallback()
{
public void onCompleted(GraphUser paramAnonymousGraphUser, Response paramAnonymousResponse)
{
if (paramAnonymousGraphUser != null)
{
FacebookFriendsFragment.access$202(FacebookFriendsFragment.this, paramSession.getAccessToken());
Object[] arrayOfObject = new Object[1];
arrayOfObject[0] = FacebookFriendsFragment.this.fbAccessToken;
ךּ.ˊ("REQUEST_FB_LINKING", arrayOfObject);
}
}
}).executeAsync();
}
示例15: requestCompleted
import com.facebook.Response; //导入依赖的package包/类
private void requestCompleted(Response paramResponse)
{
if (paramResponse.getRequest() != this.currentRequest)
return;
this.loading = false;
this.currentRequest = null;
FacebookRequestError localFacebookRequestError = paramResponse.getError();
FacebookException localFacebookException;
if (localFacebookRequestError == null)
localFacebookException = null;
else
localFacebookException = localFacebookRequestError.getException();
if ((paramResponse.getGraphObject() == null) && (localFacebookException == null))
localFacebookException = new FacebookException("GraphObjectPagingLoader received neither a result nor an error.");
if (localFacebookException != null)
{
this.nextRequest = null;
if (this.onErrorListener != null)
this.onErrorListener.onError(localFacebookException, this);
}
else
{
addResults(paramResponse);
}
}