com.facebook.LoggingBehavior Java Examples

The following examples show how to use com.facebook.LoggingBehavior. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProfilePictureView.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example #2
Source File: FacebookTimeSpentData.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: ProfilePictureView.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example #4
Source File: ProfilePictureView.java    From HypFacebook with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example #5
Source File: ProfilePictureView.java    From android-skeleton-project with MIT License 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example #6
Source File: Logger.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
public Logger(LoggingBehavior behavior, String tag) {
    Validate.notNullOrEmpty(tag, "tag");

    this.behavior = behavior;
    this.tag = LOG_TAG_BASE + tag;
    this.contents = new StringBuilder();
}
 
Example #7
Source File: ProfilePictureView.java    From android-skeleton-project with MIT License 5 votes vote down vote up
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());
    }
}
 
Example #8
Source File: Logger.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example #9
Source File: Logger.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example #10
Source File: ProfilePictureView.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
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());
    }
}
 
Example #11
Source File: ImageResponseCache.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
static void clearCache(Context context) {
    try {
        getCache(context).clearCache();
    } catch (IOException e) {
        Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "clearCache failed " + e.getMessage());
    }
}
 
Example #12
Source File: ImageResponseCache.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
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;
}
 
Example #13
Source File: Logger.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example #14
Source File: ImageResponseCache.java    From KlyphMessenger with MIT License 5 votes vote down vote up
static void clearCache(Context context) {
    try {
        getCache(context).clearCache();
    } catch (IOException e) {
        Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "clearCache failed " + e.getMessage());
    }
}
 
Example #15
Source File: Logger.java    From android-skeleton-project with MIT License 5 votes vote down vote up
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();
        }
    }
}
 
Example #16
Source File: Logger.java    From android-skeleton-project with MIT License 5 votes vote down vote up
public Logger(LoggingBehavior behavior, String tag) {
    Validate.notNullOrEmpty(tag, "tag");

    this.behavior = behavior;
    this.tag = LOG_TAG_BASE + tag;
    this.contents = new StringBuilder();
}
 
Example #17
Source File: ImageResponseCache.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #18
Source File: ProfilePictureView.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
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());
    }
}
 
Example #19
Source File: Logger.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
public Logger(LoggingBehavior behavior, String tag) {
    Validate.notNullOrEmpty(tag, "tag");

    this.behavior = behavior;
    this.tag = LOG_TAG_BASE + tag;
    this.contents = new StringBuilder();
}
 
Example #20
Source File: ImageResponseCache.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
static void clearCache(Context context) {
    try {
        getCache(context).clearCache();
    } catch (IOException e) {
        Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "clearCache failed " + e.getMessage());
    }
}
 
Example #21
Source File: ImageResponseCache.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #22
Source File: Logger.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
public Logger(LoggingBehavior behavior, String tag) {
    Validate.notNullOrEmpty(tag, "tag");

    this.behavior = behavior;
    this.tag = LOG_TAG_BASE + tag;
    this.contents = new StringBuilder();
}
 
Example #23
Source File: Logger.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
public Logger(LoggingBehavior behavior, String tag) {
    Validate.notNullOrEmpty(tag, "tag");

    this.behavior = behavior;
    this.tag = LOG_TAG_BASE + tag;
    this.contents = new StringBuilder();
}
 
Example #24
Source File: Logger.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Logger(LoggingBehavior behavior, String tag) {
    Validate.notNullOrEmpty(tag, "tag");

    this.behavior = behavior;
    this.tag = LOG_TAG_BASE + tag;
    this.contents = new StringBuilder();
}
 
Example #25
Source File: FBLoginInstance.java    From ShareLoginPayUtil with Apache License 2.0 5 votes vote down vote up
public FBLoginInstance(Activity activity, final LoginListener listener,
                       final boolean fetchUserInfo) {
    super(activity, listener, fetchUserInfo);
    if (!FacebookSdk.isInitialized()) {
        FacebookSdk.setApplicationId(ShareManager.CONFIG.getFbClientId());
        FacebookSdk.sdkInitialize(activity.getApplicationContext());
        if (BuildConfig.DEBUG) {
            FacebookSdk.setIsDebugEnabled(true);
            FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
        }
    }

    callbackManager = CallbackManager.Factory.create();
}
 
Example #26
Source File: UrlRedirectCache.java    From Klyph with MIT License 5 votes vote down vote up
static void clearCache(Context context) {
    try {
        getCache(context).clearCache();
    } catch (IOException e) {
        Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "clearCache failed " + e.getMessage());
    }
}
 
Example #27
Source File: ImageResponseCache.java    From Klyph with MIT License 5 votes vote down vote up
static void clearCache(Context context) {
    try {
        getCache(context).clearCache();
    } catch (IOException e) {
        Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "clearCache failed " + e.getMessage());
    }
}
 
Example #28
Source File: ImageResponseCache.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
static InputStream getCachedImageStream(URL 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;
}
 
Example #29
Source File: Logger.java    From Klyph with MIT License 5 votes vote down vote up
public Logger(LoggingBehavior behavior, String tag) {
    Validate.notNullOrEmpty(tag, "tag");

    this.behavior = behavior;
    this.tag = LOG_TAG_BASE + tag;
    this.contents = new StringBuilder();
}
 
Example #30
Source File: Logger.java    From Klyph with MIT License 5 votes vote down vote up
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();
        }
    }
}