本文整理匯總了Java中com.facebook.LoggingBehavior類的典型用法代碼示例。如果您正苦於以下問題:Java LoggingBehavior類的具體用法?Java LoggingBehavior怎麽用?Java LoggingBehavior使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LoggingBehavior類屬於com.facebook包,在下文中一共展示了LoggingBehavior類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processResponse
import com.facebook.LoggingBehavior; //導入依賴的package包/類
private void processResponse(ImageResponse response) {
// First check if the response is for the right request. We may have:
// 1. Sent a new request, thus super-ceding this one.
// 2. Detached this view, in which case the response should be discarded.
if (response.getRequest() == lastRequest) {
lastRequest = null;
Bitmap responseImage = response.getBitmap();
Exception error = response.getError();
if (error != null) {
OnErrorListener listener = onErrorListener;
if (listener != null) {
listener.onError(new FacebookException(
"Error in downloading profile picture for profileId: " +
getProfileId(), error));
} else {
Logger.log(LoggingBehavior.REQUESTS, Log.ERROR, TAG, error.toString());
}
} else if (responseImage != null) {
setImageBitmap(responseImage);
if (response.isCachedRedirect()) {
sendImageRequest(false);
}
}
}
}
示例2: onSuspend
import com.facebook.LoggingBehavior; //導入依賴的package包/類
void onSuspend(AppEventsLogger logger, long eventTime) {
if (!isAppActive) {
Logger.log(LoggingBehavior.APP_EVENTS, TAG, "Suspend for inactive app");
return;
}
long now = eventTime;
long delta = (now - lastResumeTime);
if (delta < 0) {
Logger.log(LoggingBehavior.APP_EVENTS, TAG, "Clock skew detected");
delta = 0;
}
millisecondsSpentInSession += delta;
lastSuspendTime = now;
isAppActive = false;
}
示例3: processResponse
import com.facebook.LoggingBehavior; //導入依賴的package包/類
private void processResponse(ImageResponse response) {
// First check if the response is for the right request. We may have:
// 1. Sent a new request, thus super-ceding this one.
// 2. Detached this view, in which case the response should be discarded.
if (response.getRequest() == lastRequest) {
lastRequest = null;
Bitmap responseImage = response.getBitmap();
Exception error = response.getError();
if (error != null) {
OnErrorListener listener = onErrorListener;
if (listener != null) {
listener.onError(new FacebookException(
"Error in downloading profile picture for profileId: " + getProfileId(), error));
} else {
Logger.log(LoggingBehavior.REQUESTS, Log.ERROR, TAG, error.toString());
}
} else if (responseImage != null) {
setImageBitmap(responseImage);
if (response.isCachedRedirect()) {
sendImageRequest(false);
}
}
}
}
示例4: getJSONObjectForGraphAPICall
import com.facebook.LoggingBehavior; //導入依賴的package包/類
public static JSONObject getJSONObjectForGraphAPICall(
GraphAPIActivityType activityType,
AttributionIdentifiers attributionIdentifiers,
String anonymousAppDeviceGUID,
boolean limitEventUsage,
Context context) throws JSONException {
JSONObject publishParams = new JSONObject();
publishParams.put("event", API_ACTIVITY_TYPE_TO_STRING.get(activityType));
Utility.setAppEventAttributionParameters(publishParams, attributionIdentifiers,
anonymousAppDeviceGUID, limitEventUsage);
// The code to get all the Extended info is safe but just in case we can wrap the
// whole call in its own try/catch block since some of the things it does might
// cause unexpected exceptions on rooted/funky devices:
try {
Utility.setAppEventExtendedDeviceInfoParameters(
publishParams,
context);
} catch (Exception e) {
// Swallow but log
Logger.log(LoggingBehavior.APP_EVENTS, "AppEvents",
"Fetching extended device info parameters failed: '%s'",
e.toString());
}
publishParams.put("application_package_name", context.getPackageName());
return publishParams;
}
示例5: log
import com.facebook.LoggingBehavior; //導入依賴的package包/類
public static void log(
LoggingBehavior behavior,
int priority,
String tag,
String format,
Object... args) {
if (FacebookSdk.isLoggingBehaviorEnabled(behavior)) {
String string = String.format(format, args);
log(behavior, priority, tag, string);
}
}
示例6: Logger
import com.facebook.LoggingBehavior; //導入依賴的package包/類
public Logger(LoggingBehavior behavior, String tag) {
Validate.notNullOrEmpty(tag, "tag");
this.behavior = behavior;
this.tag = LOG_TAG_BASE + tag;
this.contents = new StringBuilder();
}
示例7: getCachedImageStream
import com.facebook.LoggingBehavior; //導入依賴的package包/類
static InputStream getCachedImageStream(Uri uri, Context context) {
InputStream imageStream = null;
if (uri != null) {
if (isCDNURL(uri)) {
try {
FileLruCache cache = getCache(context);
imageStream = cache.get(uri.toString());
} catch (IOException e) {
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, e.toString());
}
}
}
return imageStream;
}
示例8: clearCache
import com.facebook.LoggingBehavior; //導入依賴的package包/類
static void clearCache(Context context) {
try {
getCache(context).clearCache();
} catch (IOException e) {
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "clearCache failed " + e.getMessage());
}
}
示例9: clearCache
import com.facebook.LoggingBehavior; //導入依賴的package包/類
static void clearCache() {
try {
getCache().clearCache();
} catch (IOException e) {
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "clearCache failed " + e.getMessage());
}
}
示例10: log
import com.facebook.LoggingBehavior; //導入依賴的package包/類
public static void log(LoggingBehavior behavior, int priority, String tag, String string) {
if (Settings.isLoggingBehaviorEnabled(behavior)) {
string = replaceStrings(string);
if (tag.startsWith(LOG_TAG_BASE) == false) {
tag = LOG_TAG_BASE + tag;
}
Log.println(priority, tag, string);
// Developer errors warrant special treatment by printing out a stack trace, to make both more noticeable,
// and let the source of the problem be more easily pinpointed.
if (behavior == LoggingBehavior.DEVELOPER_ERRORS) {
(new Exception()).printStackTrace();
}
}
}
示例11: getCachedImageStream
import com.facebook.LoggingBehavior; //導入依賴的package包/類
static InputStream getCachedImageStream(URI url, Context context) {
InputStream imageStream = null;
if (url != null) {
if (isCDNURL(url)) {
try {
FileLruCache cache = getCache(context);
imageStream = cache.get(url.toString());
} catch (IOException e) {
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, e.toString());
}
}
}
return imageStream;
}
示例12: sendImageRequest
import com.facebook.LoggingBehavior; //導入依賴的package包/類
private void sendImageRequest(boolean allowCachedResponse) {
try {
ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
getContext(),
ImageRequest.getProfilePictureUrl(profileId, queryWidth, queryHeight));
ImageRequest request = requestBuilder.setAllowCachedRedirects(allowCachedResponse)
.setCallerTag(this)
.setCallback(
new ImageRequest.Callback() {
@Override
public void onCompleted(ImageResponse response) {
processResponse(response);
}
})
.build();
// Make sure to cancel the old request before sending the new one to prevent
// accidental cancellation of the new request. This could happen if the URL and
// caller tag stayed the same.
if (lastRequest != null) {
ImageDownloader.cancelRequest(lastRequest);
}
lastRequest = request;
ImageDownloader.downloadAsync(request);
} catch (URISyntaxException e) {
Logger.log(LoggingBehavior.REQUESTS, Log.ERROR, TAG, e.toString());
}
}
示例13: onCreate
import com.facebook.LoggingBehavior; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
FacebookSdk.addLoggingBehavior(LoggingBehavior.REQUESTS);
}
示例14: log
import com.facebook.LoggingBehavior; //導入依賴的package包/類
public static void log(LoggingBehavior behavior, int priority, String tag, String string) {
if (FacebookSdk.isLoggingBehaviorEnabled(behavior)) {
string = replaceStrings(string);
if (tag.startsWith(LOG_TAG_BASE) == false) {
tag = LOG_TAG_BASE + tag;
}
Log.println(priority, tag, string);
// Developer errors warrant special treatment by printing out a stack trace, to make
// both more noticeable, and let the source of the problem be more easily pinpointed.
if (behavior == LoggingBehavior.DEVELOPER_ERRORS) {
(new Exception()).printStackTrace();
}
}
}
示例15: saveAppSessionInformation
import com.facebook.LoggingBehavior; //導入依賴的package包/類
static void saveAppSessionInformation(Context context) {
ObjectOutputStream oos = null;
synchronized (staticLock) {
if (hasChanges) {
try {
oos = new ObjectOutputStream(
new BufferedOutputStream(
context.openFileOutput(
PERSISTED_SESSION_INFO_FILENAME,
Context.MODE_PRIVATE)
)
);
oos.writeObject(appSessionInfoMap);
hasChanges = false;
Logger.log(
LoggingBehavior.APP_EVENTS,
"AppEvents",
"App session info saved");
} catch (Exception e) {
Log.d(TAG, "Got unexpected exception: " + e.toString());
} finally {
Utility.closeQuietly(oos);
}
}
}
}