Search in sources :

Example 11 with ImageResponse

use of com.facebook.internal.ImageResponse in project facebook-android-sdk by facebook.

the class UserSettingsFragment method getImageRequest.

private ImageRequest getImageRequest() {
    ImageRequest request = null;
    ImageRequest.Builder requestBuilder = new ImageRequest.Builder(getActivity(), ImageRequest.getProfilePictureUri(user.optString("id"), getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_height)));
    request = requestBuilder.setCallerTag(this).setCallback(new ImageRequest.Callback() {

        @Override
        public void onCompleted(ImageResponse response) {
            processImageResponse(user.optString("id"), response);
        }
    }).build();
    return request;
}
Also used : ImageRequest(com.facebook.internal.ImageRequest) ImageResponse(com.facebook.internal.ImageResponse)

Example 12 with ImageResponse

use of com.facebook.internal.ImageResponse in project facebook-android-sdk by facebook.

the class UserSettingsFragment method getImageRequest.

private ImageRequest getImageRequest() {
    ImageRequest request = null;
    ImageRequest.Builder requestBuilder = new ImageRequest.Builder(getActivity(), ImageRequest.getProfilePictureUri(user.optString("id"), getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_height)));
    request = requestBuilder.setCallerTag(this).setCallback(new ImageRequest.Callback() {

        @Override
        public void onCompleted(ImageResponse response) {
            processImageResponse(user.optString("id"), response);
        }
    }).build();
    return request;
}
Also used : ImageRequest(com.facebook.internal.ImageRequest) ImageResponse(com.facebook.internal.ImageResponse)

Example 13 with ImageResponse

use of com.facebook.internal.ImageResponse in project facebook-android-sdk by facebook.

the class GraphObjectAdapter method downloadProfilePicture.

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);
    }
}
Also used : ImageRequest(com.facebook.internal.ImageRequest) ImageResponse(com.facebook.internal.ImageResponse)

Example 14 with ImageResponse

use of com.facebook.internal.ImageResponse in project facebook-android-sdk by facebook.

the class GraphObjectAdapter method populateGraphObjectView.

protected void populateGraphObjectView(View view, JSONObject graphObject) {
    String id = getIdOfGraphObject(graphObject);
    view.setTag(id);
    CharSequence title = getTitleOfGraphObject(graphObject);
    TextView titleView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
    if (titleView != null) {
        titleView.setText(title, TextView.BufferType.SPANNABLE);
    }
    CharSequence subtitle = getSubTitleOfGraphObject(graphObject);
    TextView subtitleView = (TextView) view.findViewById(R.id.picker_subtitle);
    if (subtitleView != null) {
        if (subtitle != null) {
            subtitleView.setText(subtitle, TextView.BufferType.SPANNABLE);
            subtitleView.setVisibility(View.VISIBLE);
        } else {
            subtitleView.setVisibility(View.GONE);
        }
    }
    if (getShowCheckbox()) {
        CheckBox checkBox = (CheckBox) view.findViewById(R.id.com_facebook_picker_checkbox);
        updateCheckboxState(checkBox, isGraphObjectSelected(id));
    }
    if (getShowPicture()) {
        Uri pictureURI = getPictureUriOfGraphObject(graphObject);
        if (pictureURI != null) {
            ImageView profilePic = (ImageView) view.findViewById(R.id.com_facebook_picker_image);
            // See if we have already pre-fetched this; if not, download it.
            if (prefetchedPictureCache.containsKey(id)) {
                ImageResponse response = prefetchedPictureCache.get(id);
                profilePic.setImageBitmap(response.getBitmap());
                profilePic.setTag(response.getRequest().getImageUri());
            } else {
                downloadProfilePicture(id, pictureURI, profilePic);
            }
        }
    }
}
Also used : ImageResponse(com.facebook.internal.ImageResponse) Uri(android.net.Uri)

Example 15 with ImageResponse

use of com.facebook.internal.ImageResponse in project phonegap-facebook-plugin by Wizcorp.

the class UserSettingsFragment method getImageRequest.

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;
}
Also used : ImageRequest(com.facebook.internal.ImageRequest) ImageResponse(com.facebook.internal.ImageResponse) URISyntaxException(java.net.URISyntaxException)

Aggregations

ImageResponse (com.facebook.internal.ImageResponse)16 ImageRequest (com.facebook.internal.ImageRequest)11 URI (java.net.URI)4 URISyntaxException (java.net.URISyntaxException)4 Uri (android.net.Uri)1