com.facebook.internal.ImageRequest Java Examples

The following examples show how to use com.facebook.internal.ImageRequest. 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: UserSettingsFragment.java    From android-skeleton-project with MIT License 6 votes vote down vote up
private ImageRequest getImageRequest() {
    ImageRequest request = null;
    try {
        ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
                getActivity(),
                ImageRequest.getProfilePictureUrl(
                        user.getId(),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)));

        request = requestBuilder.setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(user.getId(), response);
                            }
                        })
                .build();
    } catch (URISyntaxException e) {
    }
    return request;
}
 
Example #2
Source File: UserSettingsFragment.java    From facebook-api-android-maven with Apache License 2.0 6 votes vote down vote up
private ImageRequest getImageRequest() {
    ImageRequest request = null;
    try {
        ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
                getActivity(),
                ImageRequest.getProfilePictureUrl(
                        user.getId(),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)));

        request = requestBuilder.setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(user.getId(), response);
                            }
                        })
                .build();
    } catch (URISyntaxException e) {
    }
    return request;
}
 
Example #3
Source File: UserSettingsFragment.java    From KlyphMessenger with MIT License 6 votes vote down vote up
private ImageRequest getImageRequest() {
    ImageRequest request = null;
    try {
        ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
                getActivity(),
                ImageRequest.getProfilePictureUrl(
                        user.getId(),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)));

        request = requestBuilder.setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(user.getId(), response);
                            }
                        })
                .build();
    } catch (URISyntaxException e) {
    }
    return request;
}
 
Example #4
Source File: UserSettingsFragment.java    From Abelana-Android with Apache License 2.0 6 votes vote down vote up
private ImageRequest getImageRequest() {
    ImageRequest request = null;
    try {
        ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
                getActivity(),
                ImageRequest.getProfilePictureUrl(
                        user.getId(),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)));

        request = requestBuilder.setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(user.getId(), response);
                            }
                        })
                .build();
    } catch (URISyntaxException e) {
    }
    return request;
}
 
Example #5
Source File: UserSettingsFragment.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
private ImageRequest getImageRequest() {
    ImageRequest request = null;
    try {
        ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
                getActivity(),
                ImageRequest.getProfilePictureUrl(
                        user.getId(),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)));

        request = requestBuilder.setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(user.getId(), response);
                            }
                        })
                .build();
    } catch (URISyntaxException e) {
    }
    return request;
}
 
Example #6
Source File: UserSettingsFragment.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
private ImageRequest getImageRequest() {
    ImageRequest request = null;
    try {
        ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
                getActivity(),
                ImageRequest.getProfilePictureUrl(
                        user.getId(),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)));

        request = requestBuilder.setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(user.getId(), response);
                            }
                        })
                .build();
    } catch (URISyntaxException e) {
    }
    return request;
}
 
Example #7
Source File: UserSettingsFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ImageRequest getImageRequest() {
    ImageRequest request = null;
    try {
        ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
                getActivity(),
                ImageRequest.getProfilePictureUrl(
                        user.getId(),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)));

        request = requestBuilder.setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(user.getId(), response);
                            }
                        })
                .build();
    } catch (URISyntaxException e) {
    }
    return request;
}
 
Example #8
Source File: UserSettingsFragment.java    From Klyph with MIT License 6 votes vote down vote up
private ImageRequest getImageRequest() {
    ImageRequest request = null;
    try {
        ImageRequest.Builder requestBuilder = new ImageRequest.Builder(
                getActivity(),
                ImageRequest.getProfilePictureUrl(
                        user.getId(),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                        getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height)));

        request = requestBuilder.setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(user.getId(), response);
                            }
                        })
                .build();
    } catch (URISyntaxException e) {
    }
    return request;
}
 
Example #9
Source File: GraphObjectAdapter.java    From Klyph with MIT License 5 votes vote down vote up
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
Example #10
Source File: GraphObjectAdapter.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
Example #11
Source File: GraphObjectAdapter.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
Example #12
Source File: GraphObjectAdapter.java    From KlyphMessenger with MIT License 5 votes vote down vote up
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
Example #13
Source File: GraphObjectAdapter.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
Example #14
Source File: GraphObjectAdapter.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
Example #15
Source File: GraphObjectAdapter.java    From android-skeleton-project with MIT License 5 votes vote down vote up
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
Example #16
Source File: GraphObjectAdapter.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
Example #17
Source File: UserSettingsFragment.java    From FacebookImageShareIntent with MIT License 4 votes vote down vote up
private void updateUI() {
    if (!isAdded()) {
        return;
    }
    if (isSessionOpen()) {
        connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
        connectedStateLabel.setShadowLayer(1f, 0f, -1f,
                getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
        
        if (user != null) {
            ImageRequest request = getImageRequest();
            if (request != null) {
                URI requestUrl = request.getImageUri();
                // Do we already have the right picture? If so, leave it alone.
                if (!requestUrl.equals(connectedStateLabel.getTag())) {
                    if (user.getId().equals(userProfilePicID)) {
                        connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
                        connectedStateLabel.setTag(requestUrl);
                    } else {
                        ImageDownloader.downloadAsync(request);
                    }
                }
            }
            connectedStateLabel.setText(user.getName());
        } else {
            connectedStateLabel.setText(getResources().getString(
                    R.string.com_facebook_usersettingsfragment_logged_in));
            Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
            noProfilePic.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
        }
    } else {
        int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
        connectedStateLabel.setTextColor(textColor);
        connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
        connectedStateLabel.setText(getResources().getString(
                R.string.com_facebook_usersettingsfragment_not_logged_in));
        connectedStateLabel.setCompoundDrawables(null, null, null, null);
        connectedStateLabel.setTag(null);
    }
}
 
Example #18
Source File: UserSettingsFragment.java    From android-skeleton-project with MIT License 4 votes vote down vote up
private void updateUI() {
    if (!isAdded()) {
        return;
    }
    if (isSessionOpen()) {
        connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
        connectedStateLabel.setShadowLayer(1f, 0f, -1f,
                getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
        
        if (user != null) {
            ImageRequest request = getImageRequest();
            if (request != null) {
                URI requestUrl = request.getImageUri();
                // Do we already have the right picture? If so, leave it alone.
                if (!requestUrl.equals(connectedStateLabel.getTag())) {
                    if (user.getId().equals(userProfilePicID)) {
                        connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
                        connectedStateLabel.setTag(requestUrl);
                    } else {
                        ImageDownloader.downloadAsync(request);
                    }
                }
            }
            connectedStateLabel.setText(user.getName());
        } else {
            connectedStateLabel.setText(getResources().getString(
                    R.string.com_facebook_usersettingsfragment_logged_in));
            Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
            noProfilePic.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
        }
    } else {
        int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
        connectedStateLabel.setTextColor(textColor);
        connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
        connectedStateLabel.setText(getResources().getString(
                R.string.com_facebook_usersettingsfragment_not_logged_in));
        connectedStateLabel.setCompoundDrawables(null, null, null, null);
        connectedStateLabel.setTag(null);
    }
}
 
Example #19
Source File: UserSettingsFragment.java    From Abelana-Android with Apache License 2.0 4 votes vote down vote up
private void updateUI() {
    if (!isAdded()) {
        return;
    }
    if (isSessionOpen()) {
        connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
        connectedStateLabel.setShadowLayer(1f, 0f, -1f,
                getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
        
        if (user != null) {
            ImageRequest request = getImageRequest();
            if (request != null) {
                URI requestUrl = request.getImageUri();
                // Do we already have the right picture? If so, leave it alone.
                if (!requestUrl.equals(connectedStateLabel.getTag())) {
                    if (user.getId().equals(userProfilePicID)) {
                        connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
                        connectedStateLabel.setTag(requestUrl);
                    } else {
                        ImageDownloader.downloadAsync(request);
                    }
                }
            }
            connectedStateLabel.setText(user.getName());
        } else {
            connectedStateLabel.setText(getResources().getString(
                    R.string.com_facebook_usersettingsfragment_logged_in));
            Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
            noProfilePic.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
        }
    } else {
        int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
        connectedStateLabel.setTextColor(textColor);
        connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
        connectedStateLabel.setText(getResources().getString(
                R.string.com_facebook_usersettingsfragment_not_logged_in));
        connectedStateLabel.setCompoundDrawables(null, null, null, null);
        connectedStateLabel.setTag(null);
    }
}
 
Example #20
Source File: UserSettingsFragment.java    From Klyph with MIT License 4 votes vote down vote up
private void updateUI() {
    if (!isAdded()) {
        return;
    }
    if (isSessionOpen()) {
        connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
        connectedStateLabel.setShadowLayer(1f, 0f, -1f,
                getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
        
        if (user != null) {
            ImageRequest request = getImageRequest();
            if (request != null) {
                URI requestUrl = request.getImageUri();
                // Do we already have the right picture? If so, leave it alone.
                if (!requestUrl.equals(connectedStateLabel.getTag())) {
                    if (user.getId().equals(userProfilePicID)) {
                        connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
                        connectedStateLabel.setTag(requestUrl);
                    } else {
                        ImageDownloader.downloadAsync(request);
                    }
                }
            }
            connectedStateLabel.setText(user.getName());
        } else {
            connectedStateLabel.setText(getResources().getString(
                    R.string.com_facebook_usersettingsfragment_logged_in));
            Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
            noProfilePic.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
        }
    } else {
        int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
        connectedStateLabel.setTextColor(textColor);
        connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
        connectedStateLabel.setText(getResources().getString(
                R.string.com_facebook_usersettingsfragment_not_logged_in));
        connectedStateLabel.setCompoundDrawables(null, null, null, null);
        connectedStateLabel.setTag(null);
    }
}
 
Example #21
Source File: UserSettingsFragment.java    From KlyphMessenger with MIT License 4 votes vote down vote up
private void updateUI() {
    if (!isAdded()) {
        return;
    }
    if (isSessionOpen()) {
        connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
        connectedStateLabel.setShadowLayer(1f, 0f, -1f,
                getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
        
        if (user != null) {
            ImageRequest request = getImageRequest();
            if (request != null) {
                URI requestUrl = request.getImageUri();
                // Do we already have the right picture? If so, leave it alone.
                if (!requestUrl.equals(connectedStateLabel.getTag())) {
                    if (user.getId().equals(userProfilePicID)) {
                        connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
                        connectedStateLabel.setTag(requestUrl);
                    } else {
                        ImageDownloader.downloadAsync(request);
                    }
                }
            }
            connectedStateLabel.setText(user.getName());
        } else {
            connectedStateLabel.setText(getResources().getString(
                    R.string.com_facebook_usersettingsfragment_logged_in));
            Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
            noProfilePic.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
        }
    } else {
        int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
        connectedStateLabel.setTextColor(textColor);
        connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
        connectedStateLabel.setText(getResources().getString(
                R.string.com_facebook_usersettingsfragment_not_logged_in));
        connectedStateLabel.setCompoundDrawables(null, null, null, null);
        connectedStateLabel.setTag(null);
    }
}
 
Example #22
Source File: UserSettingsFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void updateUI() {
    if (!isAdded()) {
        return;
    }
    if (isSessionOpen()) {
        connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
        connectedStateLabel.setShadowLayer(1f, 0f, -1f,
                getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
        
        if (user != null) {
            ImageRequest request = getImageRequest();
            if (request != null) {
                URI requestUrl = request.getImageUri();
                // Do we already have the right picture? If so, leave it alone.
                if (!requestUrl.equals(connectedStateLabel.getTag())) {
                    if (user.getId().equals(userProfilePicID)) {
                        connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
                        connectedStateLabel.setTag(requestUrl);
                    } else {
                        ImageDownloader.downloadAsync(request);
                    }
                }
            }
            connectedStateLabel.setText(user.getName());
        } else {
            connectedStateLabel.setText(getResources().getString(
                    R.string.com_facebook_usersettingsfragment_logged_in));
            Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
            noProfilePic.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
        }
    } else {
        int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
        connectedStateLabel.setTextColor(textColor);
        connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
        connectedStateLabel.setText(getResources().getString(
                R.string.com_facebook_usersettingsfragment_not_logged_in));
        connectedStateLabel.setCompoundDrawables(null, null, null, null);
        connectedStateLabel.setTag(null);
    }
}
 
Example #23
Source File: UserSettingsFragment.java    From barterli_android with Apache License 2.0 4 votes vote down vote up
private void updateUI() {
    if (!isAdded()) {
        return;
    }
    if (isSessionOpen()) {
        connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
        connectedStateLabel.setShadowLayer(1f, 0f, -1f,
                getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
        
        if (user != null) {
            ImageRequest request = getImageRequest();
            if (request != null) {
                URI requestUrl = request.getImageUri();
                // Do we already have the right picture? If so, leave it alone.
                if (!requestUrl.equals(connectedStateLabel.getTag())) {
                    if (user.getId().equals(userProfilePicID)) {
                        connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
                        connectedStateLabel.setTag(requestUrl);
                    } else {
                        ImageDownloader.downloadAsync(request);
                    }
                }
            }
            connectedStateLabel.setText(user.getName());
        } else {
            connectedStateLabel.setText(getResources().getString(
                    R.string.com_facebook_usersettingsfragment_logged_in));
            Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
            noProfilePic.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
        }
    } else {
        int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
        connectedStateLabel.setTextColor(textColor);
        connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
        connectedStateLabel.setText(getResources().getString(
                R.string.com_facebook_usersettingsfragment_not_logged_in));
        connectedStateLabel.setCompoundDrawables(null, null, null, null);
        connectedStateLabel.setTag(null);
    }
}
 
Example #24
Source File: UserSettingsFragment.java    From facebook-api-android-maven with Apache License 2.0 4 votes vote down vote up
private void updateUI() {
    if (!isAdded()) {
        return;
    }
    if (isSessionOpen()) {
        connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
        connectedStateLabel.setShadowLayer(1f, 0f, -1f,
                getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
        
        if (user != null) {
            ImageRequest request = getImageRequest();
            if (request != null) {
                URI requestUrl = request.getImageUri();
                // Do we already have the right picture? If so, leave it alone.
                if (!requestUrl.equals(connectedStateLabel.getTag())) {
                    if (user.getId().equals(userProfilePicID)) {
                        connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
                        connectedStateLabel.setTag(requestUrl);
                    } else {
                        ImageDownloader.downloadAsync(request);
                    }
                }
            }
            connectedStateLabel.setText(user.getName());
        } else {
            connectedStateLabel.setText(getResources().getString(
                    R.string.com_facebook_usersettingsfragment_logged_in));
            Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
            noProfilePic.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
        }
    } else {
        int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
        connectedStateLabel.setTextColor(textColor);
        connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
        connectedStateLabel.setText(getResources().getString(
                R.string.com_facebook_usersettingsfragment_not_logged_in));
        connectedStateLabel.setCompoundDrawables(null, null, null, null);
        connectedStateLabel.setTag(null);
    }
}
 
Example #25
Source File: Profile.java    From kognitivo with Apache License 2.0 2 votes vote down vote up
/**
 * Getter for the Uri of the profile picture.
 *
 * @param width  The desired width for the profile picture.
 * @param height The desired height for the profile picture.
 * @return The Uri of the profile picture.
 */
public Uri getProfilePictureUri(
        int width,
        int height) {
    return ImageRequest.getProfilePictureUri(this.id, width, height);
}