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++;
}
}
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);
}
}
Aggregations