use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.
the class EpisodeDetailsFragment method loadImage.
private void loadImage(String imagePath, boolean hideDetails) {
// immediately hide container if there is no image
if (TextUtils.isEmpty(imagePath)) {
mImageContainer.setVisibility(View.GONE);
return;
}
if (hideDetails) {
// show image placeholder
mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
mEpisodeImage.setImageResource(R.drawable.ic_image_missing);
} else {
// try loading image
mImageContainer.setVisibility(View.VISIBLE);
ServiceUtils.loadWithPicasso(getActivity(), TvdbImageTools.fullSizeUrl(imagePath)).error(R.drawable.ic_image_missing).into(mEpisodeImage, new Callback() {
@Override
public void onSuccess() {
mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
@Override
public void onError() {
mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
});
}
}
use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.
the class FullscreenImageActivity method loadLargeImage.
private void loadLargeImage(boolean hasPreviewImage) {
String imagePath = getIntent().getStringExtra(EXTRA_IMAGE);
if (TextUtils.isEmpty(imagePath)) {
// set to null so picasso shows error drawable
imagePath = null;
}
RequestCreator requestCreator = ServiceUtils.loadWithPicasso(this, imagePath);
if (hasPreviewImage) {
// keep showing preview image if loading full image fails
requestCreator.noPlaceholder().into(photoView);
} else {
// no preview image? show error image instead if loading full image fails
requestCreator.error(R.drawable.ic_image_missing).into(photoView, new Callback() {
@Override
public void onSuccess() {
photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
}
@Override
public void onError() {
photoView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
});
}
}
use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.
the class FullscreenImageActivity method setupViews.
private void setupViews() {
photoView = (PhotoView) findViewById(R.id.fullscreen_content);
// try to immediately show cached preview image
String previewImagePath = getIntent().getStringExtra(EXTRA_PREVIEW_IMAGE);
if (!TextUtils.isEmpty(previewImagePath)) {
ServiceUtils.loadWithPicasso(this, previewImagePath).networkPolicy(NetworkPolicy.OFFLINE).into(photoView, new Callback() {
@Override
public void onSuccess() {
loadLargeImage(true);
}
@Override
public void onError() {
loadLargeImage(false);
}
});
} else {
loadLargeImage(false);
}
// Set up an instance of SystemUiHider to control the system UI for
// this activity.
systemUiHider = SystemUiHider.getInstance(this, photoView, SystemUiHider.FLAG_FULLSCREEN);
systemUiHider.setup();
photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
@Override
public void onViewTap(View view, float x, float y) {
systemUiHider.toggle();
}
});
}
use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.
the class OverviewFragment method loadEpisodeImage.
private void loadEpisodeImage(String imagePath) {
if (TextUtils.isEmpty(imagePath)) {
imageEpisode.setImageDrawable(null);
return;
}
if (DisplaySettings.preventSpoilers(getContext())) {
// show image placeholder
imageEpisode.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageEpisode.setImageResource(R.drawable.ic_image_missing);
} else {
// try loading image
ServiceUtils.loadWithPicasso(getActivity(), TvdbImageTools.fullSizeUrl(imagePath)).error(R.drawable.ic_image_missing).into(imageEpisode, new Callback() {
@Override
public void onSuccess() {
imageEpisode.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
@Override
public void onError() {
imageEpisode.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
});
}
}
use of com.squareup.picasso.Callback in project Hummingbird-for-Android by xiprox.
the class FavoriteAnimeAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rootView = inflater.inflate(R.layout.item_favorite_grid, null);
FavoriteAnime fav = mItems.get(position);
final ImageView mCover = (ImageView) rootView.findViewById(R.id.item_favorite_cover);
final TextView mTitle = (TextView) rootView.findViewById(R.id.item_favorite_title);
ViewFlipper mFlipper = (ViewFlipper) rootView.findViewById(R.id.item_favorite_flipper);
Picasso.with(context).load(fav.getCoverImage()).into(mCover, new Callback() {
@Override
public void onSuccess() {
int darkMutedColor;
Bitmap bitmap = ((BitmapDrawable) mCover.getDrawable()).getBitmap();
darkMutedColor = Palette.generate(bitmap).getDarkMutedSwatch().getRgb();
mTitle.setBackgroundDrawable(new ColorDrawable(darkMutedColor));
}
@Override
public void onError() {
}
});
mTitle.setText(fav.getTitle());
if (mFlipper.getDisplayedChild() == 0)
mFlipper.showNext();
return rootView;
}
Aggregations