Search in sources :

Example 1 with ImageResponse

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

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)

Example 2 with ImageResponse

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

the class GraphObjectAdapter method populateGraphObjectView.

protected void populateGraphObjectView(View view, T 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(java.net.URI)

Example 3 with ImageResponse

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

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 4 with ImageResponse

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

the class GraphObjectAdapter method populateGraphObjectView.

protected void populateGraphObjectView(View view, T 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(java.net.URI)

Example 5 with ImageResponse

use of com.facebook.internal.ImageResponse in project Klyph by jonathangerbaud.

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