Java 类com.facebook.LegacyHelper 实例源码
项目:yelo-android
文件:Facebook.java
@Override
@SuppressWarnings("deprecation")
public void handleMessage(Message msg) {
Facebook facebook = facebookWeakReference.get();
TokenRefreshServiceConnection connection = connectionWeakReference.get();
if (facebook == null || connection == null) {
return;
}
String token = msg.getData().getString(TOKEN);
// Legacy functions in Facebook class (and ServiceListener implementors) expect expires_in in
// milliseconds from epoch
long expiresAtMsecFromEpoch = msg.getData().getLong(EXPIRES) * 1000L;
if (token != null) {
facebook.setAccessToken(token);
facebook.setAccessExpires(expiresAtMsecFromEpoch);
Session refreshSession = facebook.session;
if (refreshSession != null) {
// Session.internalRefreshToken expects the original bundle with expires_in in seconds from
// epoch.
LegacyHelper.extendTokenCompleted(refreshSession, msg.getData());
}
if (connection.serviceListener != null) {
// To avoid confusion we should return the expiration time in
// the same format as the getAccessExpires() function - that
// is in milliseconds.
Bundle resultBundle = (Bundle) msg.getData().clone();
resultBundle.putLong(EXPIRES, expiresAtMsecFromEpoch);
connection.serviceListener.onComplete(resultBundle);
}
} else if (connection.serviceListener != null) { // extract errors only if
// client wants them
String error = msg.getData().getString("error");
if (msg.getData().containsKey("error_code")) {
int errorCode = msg.getData().getInt("error_code");
connection.serviceListener.onFacebookError(new FacebookError(error, null, errorCode));
} else {
connection.serviceListener.onError(new Error(error != null ? error : "Unknown service error"));
}
}
// The refreshToken function should be called rarely,
// so there is no point in keeping the binding open.
connection.applicationsContext.unbindService(connection);
}
项目:QuizUpWinner
文件:Facebook.java
public void handleMessage(Message paramMessage)
{
Facebook localFacebook = (Facebook)this.facebookWeakReference.get();
Facebook.TokenRefreshServiceConnection localTokenRefreshServiceConnection = (Facebook.TokenRefreshServiceConnection)this.connectionWeakReference.get();
if ((localFacebook == null) || (localTokenRefreshServiceConnection == null))
return;
String str1 = paramMessage.getData().getString("access_token");
long l = 1000L * paramMessage.getData().getLong("expires_in");
if (str1 != null)
{
localFacebook.setAccessToken(str1);
localFacebook.setAccessExpires(l);
Session localSession = localFacebook.session;
if (localSession != null)
LegacyHelper.extendTokenCompleted(localSession, paramMessage.getData());
if (localTokenRefreshServiceConnection.serviceListener != null)
{
Bundle localBundle = (Bundle)paramMessage.getData().clone();
localBundle.putLong("expires_in", l);
localTokenRefreshServiceConnection.serviceListener.onComplete(localBundle);
}
}
else if (localTokenRefreshServiceConnection.serviceListener != null)
{
String str2 = paramMessage.getData().getString("error");
if (paramMessage.getData().containsKey("error_code"))
{
int i = paramMessage.getData().getInt("error_code");
localTokenRefreshServiceConnection.serviceListener.onFacebookError(new FacebookError(str2, null, i));
}
else
{
Facebook.ServiceListener localServiceListener = localTokenRefreshServiceConnection.serviceListener;
String str3;
if (str2 != null)
str3 = str2;
else
str3 = "Unknown service error";
localServiceListener.onError(new Error(str3));
}
}
localTokenRefreshServiceConnection.applicationsContext.unbindService(localTokenRefreshServiceConnection);
}
项目:p2psafety
文件:Facebook.java
@Override
@SuppressWarnings("deprecation")
public void handleMessage(Message msg) {
Facebook facebook = facebookWeakReference.get();
TokenRefreshServiceConnection connection = connectionWeakReference.get();
if (facebook == null || connection == null) {
return;
}
String token = msg.getData().getString(TOKEN);
// Legacy functions in Facebook class (and ServiceListener implementors) expect expires_in in
// milliseconds from epoch
long expiresAtMsecFromEpoch = msg.getData().getLong(EXPIRES) * 1000L;
if (token != null) {
facebook.setAccessToken(token);
facebook.setAccessExpires(expiresAtMsecFromEpoch);
Session refreshSession = facebook.session;
if (refreshSession != null) {
// Session.internalRefreshToken expects the original bundle with expires_in in seconds from
// epoch.
LegacyHelper.extendTokenCompleted(refreshSession, msg.getData());
}
if (connection.serviceListener != null) {
// To avoid confusion we should return the expiration time in
// the same format as the getAccessExpires() function - that
// is in milliseconds.
Bundle resultBundle = (Bundle) msg.getData().clone();
resultBundle.putLong(EXPIRES, expiresAtMsecFromEpoch);
connection.serviceListener.onComplete(resultBundle);
}
} else if (connection.serviceListener != null) { // extract errors only if
// client wants them
String error = msg.getData().getString("error");
if (msg.getData().containsKey("error_code")) {
int errorCode = msg.getData().getInt("error_code");
connection.serviceListener.onFacebookError(new FacebookError(error, null, errorCode));
} else {
connection.serviceListener.onError(new Error(error != null ? error : "Unknown service error"));
}
}
if (connection != null) {
// The refreshToken function should be called rarely,
// so there is no point in keeping the binding open.
connection.applicationsContext.unbindService(connection);
}
}