Search in sources :

Example 11 with WPNetworkImageView

use of org.wordpress.android.widgets.WPNetworkImageView in project WordPress-Android by wordpress-mobile.

the class ReaderLikingUsersView method showLikingAvatars.

/*
     * note that the passed list of avatar urls has already been Photon-ized,
     * so there's no need to do that here
     */
private void showLikingAvatars(final ArrayList<String> avatarUrls) {
    if (avatarUrls == null || avatarUrls.size() == 0) {
        removeAllViews();
        return;
    }
    // remove excess existing views
    int numExistingViews = getChildCount();
    if (numExistingViews > avatarUrls.size()) {
        int numToRemove = numExistingViews - avatarUrls.size();
        removeViews(numExistingViews - numToRemove, numToRemove);
    }
    int index = 0;
    LayoutInflater inflater = LayoutInflater.from(getContext());
    for (String url : avatarUrls) {
        WPNetworkImageView imgAvatar;
        // reuse existing view when possible, otherwise inflate a new one
        if (index < numExistingViews) {
            imgAvatar = (WPNetworkImageView) getChildAt(index);
        } else {
            imgAvatar = (WPNetworkImageView) inflater.inflate(R.layout.reader_like_avatar, this, false);
            addView(imgAvatar);
        }
        imgAvatar.setImageUrl(url, WPNetworkImageView.ImageType.AVATAR);
        index++;
    }
}
Also used : WPNetworkImageView(org.wordpress.android.widgets.WPNetworkImageView) LayoutInflater(android.view.LayoutInflater)

Example 12 with WPNetworkImageView

use of org.wordpress.android.widgets.WPNetworkImageView in project WordPress-Android by wordpress-mobile.

the class ReaderThumbnailStrip method loadThumbnails.

public void loadThumbnails(long blogId, long postId, boolean isPrivate) {
    // get rid of any views already added
    mView.removeAllViews();
    // get this post's content and scan it for images suitable in a gallery
    final String content = ReaderPostTable.getPostText(blogId, postId);
    final ReaderImageList imageList = new ReaderImageScanner(content, isPrivate).getImageList(IMAGE_COUNT, ReaderConstants.MIN_GALLERY_IMAGE_WIDTH);
    if (imageList.size() < IMAGE_COUNT) {
        mView.setVisibility(View.GONE);
        return;
    }
    final EnumSet<PhotoViewerOption> photoViewerOptions = EnumSet.of(PhotoViewerOption.IS_GALLERY_IMAGE);
    if (isPrivate) {
        photoViewerOptions.add(PhotoViewerOption.IS_PRIVATE_IMAGE);
    }
    // add a separate imageView for each image up to the max
    int numAdded = 0;
    LayoutInflater inflater = LayoutInflater.from(getContext());
    for (final String imageUrl : imageList) {
        View view = inflater.inflate(R.layout.reader_thumbnail_strip_image, mView, false);
        WPNetworkImageView imageView = (WPNetworkImageView) view.findViewById(R.id.thumbnail_strip_image);
        mView.addView(view);
        String photonUrl = PhotonUtils.getPhotonImageUrl(imageUrl, mThumbnailWidth, mThumbnailHeight);
        imageView.setImageUrl(photonUrl, WPNetworkImageView.ImageType.PHOTO);
        // tapping a thumbnail opens the photo viewer
        imageView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                ReaderActivityLauncher.showReaderPhotoViewer(view.getContext(), imageUrl, content, view, photoViewerOptions, 0, 0);
            }
        });
        numAdded++;
        if (numAdded >= IMAGE_COUNT) {
            break;
        }
    }
    if (mView.getVisibility() != View.VISIBLE) {
        AniUtils.fadeIn(mView, AniUtils.Duration.SHORT);
    }
}
Also used : PhotoViewerOption(org.wordpress.android.ui.reader.ReaderActivityLauncher.PhotoViewerOption) WPNetworkImageView(org.wordpress.android.widgets.WPNetworkImageView) LayoutInflater(android.view.LayoutInflater) ReaderImageScanner(org.wordpress.android.ui.reader.utils.ReaderImageScanner) WPNetworkImageView(org.wordpress.android.widgets.WPNetworkImageView) View(android.view.View) ReaderImageList(org.wordpress.android.ui.reader.models.ReaderImageList)

Aggregations

WPNetworkImageView (org.wordpress.android.widgets.WPNetworkImageView)12 View (android.view.View)8 TextView (android.widget.TextView)7 LayoutInflater (android.view.LayoutInflater)3 ImageView (android.widget.ImageView)3 ViewGroup (android.view.ViewGroup)2 ScrollView (android.widget.ScrollView)2 ViewTreeObserver (android.view.ViewTreeObserver)1 ToolTipView (com.github.xizzhu.simpletooltip.ToolTipView)1 File (java.io.File)1 IOException (java.io.IOException)1 CommentModel (org.wordpress.android.fluxc.model.CommentModel)1 SiteModel (org.wordpress.android.fluxc.model.SiteModel)1 RemoteCommentPayload (org.wordpress.android.fluxc.store.CommentStore.RemoteCommentPayload)1 PhotoViewerOption (org.wordpress.android.ui.reader.ReaderActivityLauncher.PhotoViewerOption)1 ReaderImageList (org.wordpress.android.ui.reader.models.ReaderImageList)1 ReaderImageScanner (org.wordpress.android.ui.reader.utils.ReaderImageScanner)1 WPTextView (org.wordpress.android.widgets.WPTextView)1