use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project NewPipe by TeamNewPipe.
the class VideoItemDetailFragment method initThumbnailViews.
private void initThumbnailViews(final StreamInfo info) {
ImageView videoThumbnailView = (ImageView) activity.findViewById(R.id.detail_thumbnail_view);
ImageView uploaderThumb = (ImageView) activity.findViewById(R.id.detail_uploader_thumbnail_view);
if (info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
imageLoader.displayImage(info.thumbnail_url, videoThumbnailView, displayImageOptions, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
ErrorActivity.reportError(getActivity(), failReason.getCause(), null, rootView, ErrorActivity.ErrorInfo.make(ErrorActivity.LOAD_IMAGE, NewPipe.getNameOfService(info.service_id), imageUri, R.string.could_not_load_thumbnails));
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
streamThumbnail = loadedImage;
if (streamThumbnail != null) {
// TODO: Change the thumbnail implementation
// When the thumbnail is not loaded yet, it not passes to the service in time
// so, I can notify the service through a broadcast, but the problem is
// when I click in another video, another thumbnail will be load, and will
// notify again, so I send the videoUrl and compare with the service's url
ActivityCommunicator.getCommunicator().backgroundPlayerThumbnail = streamThumbnail;
Intent intent = new Intent(PopupVideoPlayer.InternalListener.ACTION_UPDATE_THUMB);
intent.putExtra(PopupVideoPlayer.VIDEO_URL, info.webpage_url);
getContext().sendBroadcast(intent);
}
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else {
videoThumbnailView.setImageResource(R.drawable.dummy_thumbnail_dark);
}
if (info.uploader_thumbnail_url != null && !info.uploader_thumbnail_url.isEmpty()) {
imageLoader.displayImage(info.uploader_thumbnail_url, uploaderThumb, displayImageOptions, new ImageErrorLoadingListener(activity, rootView, info.service_id));
}
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Slide by ccrama.
the class SubredditPosts method loadPhotos.
public void loadPhotos(List<Submission> submissions) {
for (Submission submission : submissions) {
String url;
ContentType.Type type = ContentType.getContentType(submission);
if (submission.getThumbnails() != null) {
if (type == ContentType.Type.IMAGE || type == ContentType.Type.SELF || (submission.getThumbnailType() == Submission.ThumbnailType.URL)) {
if (type == ContentType.Type.IMAGE) {
if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails() != null && submission.getThumbnails().getVariations() != null && submission.getThumbnails().getVariations().length > 0) {
int length = submission.getThumbnails().getVariations().length;
if (SettingValues.lqLow && length >= 3) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
} else if (SettingValues.lqMid && length >= 4) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
} else if (length >= 5) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
} else {
if (submission.getDataNode().has("preview") && submission.getDataNode().get("preview").get("images").get(0).get("source").has("height")) {
// Load the preview image which has probably already been cached in memory instead of the direct link
url = submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText();
} else {
url = submission.getUrl();
}
}
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else if (submission.getThumbnails() != null) {
if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails().getVariations().length != 0) {
int length = submission.getThumbnails().getVariations().length;
if (SettingValues.lqLow && length >= 3) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
} else if (SettingValues.lqMid && length >= 4) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
} else if (length >= 5) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else if (submission.getThumbnail() != null && (submission.getThumbnailType() == Submission.ThumbnailType.URL || submission.getThumbnailType() == Submission.ThumbnailType.NSFW)) {
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(submission.getUrl(), new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
}
}
}
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Slide by ccrama.
the class MultiredditPosts method loadPhotos.
public void loadPhotos(List<Submission> submissions) {
for (Submission submission : submissions) {
String url;
ContentType.Type type = ContentType.getContentType(submission);
if (submission.getThumbnails() != null) {
if (type == ContentType.Type.IMAGE || type == ContentType.Type.SELF || (submission.getThumbnailType() == Submission.ThumbnailType.URL)) {
if (type == ContentType.Type.IMAGE) {
if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails() != null && submission.getThumbnails().getVariations() != null && submission.getThumbnails().getVariations().length > 0) {
int length = submission.getThumbnails().getVariations().length;
if (SettingValues.lqLow && length >= 3) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
} else if (SettingValues.lqMid && length >= 4) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
} else if (length >= 5) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
} else {
if (submission.getDataNode().has("preview") && submission.getDataNode().get("preview").get("images").get(0).get("source").has("height")) {
// Load the preview image which has probably already been cached in memory instead of the direct link
url = submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText();
} else {
url = submission.getUrl();
}
}
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else if (submission.getThumbnails() != null) {
if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails().getVariations().length != 0) {
int length = submission.getThumbnails().getVariations().length;
if (SettingValues.lqLow && length >= 3) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
} else if (SettingValues.lqMid && length >= 4) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
} else if (length >= 5) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else if (submission.getThumbnail() != null && (submission.getThumbnailType() == Submission.ThumbnailType.URL || submission.getThumbnailType() == Submission.ThumbnailType.NSFW)) {
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(submission.getUrl(), new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
}
}
}
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Slide by ccrama.
the class SubredditPostsRealm method loadPhotos.
public void loadPhotos(List<Submission> submissions) {
for (Submission submission : submissions) {
String url;
ContentType.Type type = ContentType.getContentType(submission);
if (submission.getThumbnails() != null) {
if (type == ContentType.Type.IMAGE || type == ContentType.Type.SELF || (submission.getThumbnailType() == Submission.ThumbnailType.URL)) {
if (type == ContentType.Type.IMAGE) {
if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails() != null && submission.getThumbnails().getVariations() != null && submission.getThumbnails().getVariations().length > 0) {
int length = submission.getThumbnails().getVariations().length;
if (SettingValues.lqLow && length >= 3) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
} else if (SettingValues.lqMid && length >= 4) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
} else if (length >= 5) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
} else {
if (submission.getDataNode().has("preview") && submission.getDataNode().get("preview").get("images").get(0).get("source").has("height")) {
// Load the preview image which has probably already been cached in memory instead of the direct link
url = submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText();
} else {
url = submission.getUrl();
}
}
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else if (submission.getThumbnails() != null) {
if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails().getVariations().length != 0) {
int length = submission.getThumbnails().getVariations().length;
if (SettingValues.lqLow && length >= 3) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
} else if (SettingValues.lqMid && length >= 4) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
} else if (length >= 5) {
url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
} else {
url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
}
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else if (submission.getThumbnail() != null && (submission.getThumbnailType() == Submission.ThumbnailType.URL || submission.getThumbnailType() == Submission.ThumbnailType.NSFW)) {
((Reddit) c.getApplicationContext()).getImageLoader().loadImage(submission.getUrl(), new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
}
}
}
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project NewPipe by TeamNewPipe.
the class VideoDetailFragment method initThumbnailViews.
private void initThumbnailViews(@NonNull StreamInfo info) {
thumbnailImageView.setImageResource(R.drawable.dummy_thumbnail_dark);
if (!TextUtils.isEmpty(info.getThumbnailUrl())) {
final String infoServiceName = NewPipe.getNameOfService(info.getServiceId());
final ImageLoadingListener onFailListener = new SimpleImageLoadingListener() {
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
showSnackBarError(failReason.getCause(), UserAction.LOAD_IMAGE, infoServiceName, imageUri, R.string.could_not_load_thumbnails);
}
};
imageLoader.displayImage(info.getThumbnailUrl(), thumbnailImageView, ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS, onFailListener);
}
if (!TextUtils.isEmpty(info.getUploaderAvatarUrl())) {
imageLoader.displayImage(info.getUploaderAvatarUrl(), uploaderThumb, ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
}
}
Aggregations