@Override public void displayRaw(@NonNull ImageView img, @NonNull String absPath, int width, int height, final IBoxingCallback callback) { String path = "file://" + absPath; RequestCreator creator = Picasso.with(img.getContext()) .load(path); if (width > 0 && height > 0) { creator.transform(new BitmapTransform(width, height)); } creator.into(img, new Callback() { @Override public void onSuccess() { if (callback != null) { callback.onSuccess(); } } @Override public void onError() { if (callback != null) { callback.onFail(null); } } }); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ImageView imageView = (ImageView) view.findViewById(R.id.picasso_fragment_b_image); Picasso.with(getContext()) .load(PicassoFragmentA.GIRAFFE_PIC_URL) .fit() .noFade() .centerCrop() .into(imageView, new Callback() { @Override public void onSuccess() { startPostponedEnterTransition(); } @Override public void onError() { startPostponedEnterTransition(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animal_detail); supportPostponeEnterTransition(); Bundle extras = getIntent().getExtras(); AnimalItem animalItem = extras.getParcelable(RecyclerViewActivity.EXTRA_ANIMAL_ITEM); ImageView imageView = (ImageView) findViewById(R.id.animal_detail_image_view); TextView textView = (TextView) findViewById(R.id.animal_detail_text); textView.setText(animalItem.detail); String imageUrl = animalItem.imageUrl; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { String imageTransitionName = extras.getString(RecyclerViewActivity.EXTRA_ANIMAL_IMAGE_TRANSITION_NAME); imageView.setTransitionName(imageTransitionName); } Picasso.with(this) .load(imageUrl) .noFade() .into(imageView, new Callback() { @Override public void onSuccess() { supportStartPostponedEnterTransition(); } @Override public void onError() { supportStartPostponedEnterTransition(); } }); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); AnimalItem animalItem = getArguments().getParcelable(EXTRA_ANIMAL_ITEM); String transitionName = getArguments().getString(EXTRA_TRANSITION_NAME); TextView detailTextView = (TextView) view.findViewById(R.id.animal_detail_text); detailTextView.setText(animalItem.detail); ImageView imageView = (ImageView) view.findViewById(R.id.animal_detail_image_view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { imageView.setTransitionName(transitionName); } Picasso.with(getContext()) .load(animalItem.imageUrl) .noFade() .into(imageView, new Callback() { @Override public void onSuccess() { startPostponedEnterTransition(); } @Override public void onError() { startPostponedEnterTransition(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.picasso_activity_b); ImageView imageView = (ImageView) findViewById(R.id.picasso_activity_b_image); supportPostponeEnterTransition(); Picasso.with(this) .load(PicassoActivityA.TIGER_PIC_URL) .fit() .noFade() .centerCrop() .into(imageView, new Callback() { @Override public void onSuccess() { supportStartPostponedEnterTransition(); } @Override public void onError() { supportStartPostponedEnterTransition(); } }); }
@Override public void loadImage(String path, ImageView imageView) { if (path == null || path.equalsIgnoreCase("") || imageView == null) { //TODO:ERROR LOADING IMAGE }else{ Picasso.with(context).load(path).into(imageView, new Callback() { @Override public void onSuccess() { listener.onImageLoaded(); } @Override public void onError() { listener.onImageError(); } }); } }
@Override public void startLoading() { picasso.load(PokeQuestApp.BASE_URL + mChoices.get(mCorrectNo).getImageUrl()) .placeholder(me.datvu.pokequest.R.drawable.pokeball_padding) .error(me.datvu.pokequest.R.drawable.pokeball) .into(mImPoke, new Callback() { @Override public void onSuccess() { if (mListener != null) { if (!mIsFinish) mListener.onQuizReady(); } } @Override public void onError() { if (mListener != null) { mListener.onQuizLoadingError(new Exception("Error when loading poke " + "image at id=" + mChoices.get(mCorrectNo).getId())); } } }); }
private Completable loadImageInto(ImageView im, Pokemon pk) { return Completable.create(e -> picasso.load(PokeQuestApp.BASE_URL + pk.getImageUrl()) .placeholder(R.drawable.pokeball_padding) .error(R.drawable.pokeball) .into(im, new Callback() { @Override public void onSuccess() { e.onComplete(); } @Override public void onError() { e.onError(new Throwable("Error when loading poke image at id=" + pk.getId())); } })); }
void setPhotoUrl(String image, ViewHolder vh){ ImageView event_image = vh.cardview.findViewById(R.id.commentorProfileImageView); final ProgressBar progressBar = vh.cardview.findViewById(R.id.progressBar2); Picasso.with(event_image.getContext()) .load(image) .into(event_image, new Callback() { @Override public void onSuccess() { progressBar.setVisibility(View.GONE); } @Override public void onError() { Toast.makeText(getApplicationContext(), "Network error: failed to load image", Toast.LENGTH_SHORT).show(); } }); }
void setPhotoUrl(String image){ ImageView event_image = mView.findViewById(R.id.photoImageView); final ProgressBar progressBar = mView.findViewById(R.id.imageProgressBar); Picasso.with(event_image.getContext()) .load(image) .into(event_image, new Callback() { @Override public void onSuccess() { progressBar.setVisibility(View.GONE); } @Override public void onError() { } }); }
void setPhotoUrl(String image, ViewHolder vh){ ImageView event_image = vh.cardview.findViewById(R.id.photoImageView); final ProgressBar progressBar = vh.cardview.findViewById(R.id.imageProgressBar); Picasso.with(event_image.getContext()) .load(image) .into(event_image, new Callback() { @Override public void onSuccess() { progressBar.setVisibility(View.GONE); } @Override public void onError() { } }); }
@Override public void setProfilePhotoURL(String profilePhotoUrl) { Picasso.with(getActivity()) .load(Uri.parse(profilePhotoUrl)) .noFade() .into(thumbnail, new Callback() { @Override public void onSuccess() { presenter.onThumbnailLoaded(); } @Override public void onError() { setDefaultProfilePhoto(); } }); //CircleImageView requires noFade() to be set }
@Override public void setDefaultProfilePhoto() { Picasso.with(getActivity()) .load(R.drawable.default_profile_pic) .noFade() .into(thumbnail, new Callback() { @Override public void onSuccess() { presenter.onThumbnailLoaded(); } @Override public void onError() { Toast.makeText( getActivity(), getString(R.string.error_loading_image), Toast.LENGTH_SHORT).show(); } }); }
@Override public void setBitmap() { Picasso.with(getActivity()) .load(photoURL) .fit() .into(photo, new Callback() { @Override public void onSuccess() { presenter.onImageLoaded(); } @Override public void onError() { presenter.onImageLoadFailure(); } }); }
public void setPictureUrl(final String imageUrl) { progressBar.setVisibility(View.VISIBLE); Picasso.with(image.getContext()) .load(imageUrl) .into(image, new Callback() { @Override public void onSuccess() { progressBar.setVisibility(View.GONE); } @Override public void onError() { progressBar.setVisibility(View.GONE); image.setImageResource(android.R.drawable.ic_menu_gallery); } }); }
/** * Loads an image into a target view. * @param context context * @param image image * @param centerCrop boolean * @param errorResourceId image of error * @param target imageView * @param callback callback */ public static void loadImage(final Context context, final String image, final boolean centerCrop, final int errorResourceId, final ImageView target, final Callback callback) { Picasso pic = Picasso.with(context); RequestCreator request; int errorRId = errorResourceId; if (image != null ) request = pic.load(image).fit(); else { request = pic.load(errorResourceId).fit(); errorRId = 0; } if (centerCrop) request = request.centerCrop(); if (errorRId != 0) request = request.error(errorResourceId); if (callback != null) request.into(target, callback); else request.into(target); }
/** * Fills the TV Show Details in screen. * @param container TVShowData */ private void populateDetails(final TVShowData container) { if (container == null) { return; } final Palette.PaletteAsyncListener paletteAsyncListener = ActivityUtils.definePaletteAsyncListener(this, title, textRating, rating, starRating); Callback callback = ActivityUtils.defineCallback(paletteAsyncListener, backgroundPoster, tvShowPoster); PopulateDetailsTitle(container); PopulateDetailsPoster(container, callback); PopulateDetailsGenresCountries(container); PopulateDetailsProdCompanies(container); PopulateDetailsStatus(container); PopulateDetailsDates(container); defineClickFavoriteButtons(container); ActivityUtils.firebaseAnalyticsLogEventViewItem( mFirebaseAnalytics, "" + tvShowId, tvShowTitle[0], TV_SHOWS); }
/** * Populates poster in screen. * @param container TVShowData * @param callback callback */ private void PopulateDetailsPoster(final TVShowData container, Callback callback) { ActivityUtils.loadImage(this, TMDB_IMAGE_URL + SIZE_W342 + container.getPosterPath(), true, R.drawable.disk_reel, tvShowPoster, null); String backgroundPosterPath = container.getBackgroundPath(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, true, R.drawable.no_background_poster, backgroundPoster, callback); } else { ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, false, R.drawable.no_background_poster, backgroundPoster, callback); } // Save background movie image poster to use in PersonProfile page. ActivityUtils.saveStringToPreferences(this, KNOWN_FOR_BACKGROUND_POSTER, container.getBackgroundPath()); }
/** * Populates poster in screen. * @param profilePosterPath image path * @param backgroundPosterPath image path * @param callback callback */ private void PopulateBackgroundPoster(final String profilePosterPath, final String backgroundPosterPath, Callback callback) { ActivityUtils.loadImage(this, TMDB_IMAGE_URL + SIZE_W342 + profilePosterPath, true, R.drawable.disk_reel, personalProfImage, null); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, true, R.drawable.no_background_poster, backgroundPoster, callback); } else { ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, false, R.drawable.no_background_poster, backgroundPoster, callback); } }
/** * Fills the Movie Details in screen. * @param container MovieData */ private void populateDetails(final MovieData container) { if (container == null) { return; } final Palette.PaletteAsyncListener paletteAsyncListener = ActivityUtils.definePaletteAsyncListener(this, title, textRating, rating, starRating); Callback callback = ActivityUtils.defineCallback(paletteAsyncListener, backgroundPoster, moviePoster); PopulateDetailsTitle(container); PopulateDetailsPoster(container, callback); PopulateDetailsDateDurationRating(container); PopulateDetailsLanguage(container); PopulateDetailsGenres(container); PopulateDetailsCountries(container); PopulateDetailsProdCompanies(container); PopulateDetailsStatus(container); PopulateDetailsPlot(container); defineClickFavoriteButtons(container); ActivityUtils.firebaseAnalyticsLogEventViewItem( mFirebaseAnalytics, "" + movieID, container.getTitle(), MOVIES); }
/** * Populates poster in screen. * @param container MovieData * @param callback callback */ private void PopulateDetailsPoster(final MovieData container, Callback callback) { ActivityUtils.loadImage(this, TMDB_IMAGE_URL + SIZE_W342 + container.getPosterPath(), true, R.drawable.disk_reel, moviePoster, null); String backgroundPosterPath = container.getBackgroundPath(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, true, R.drawable.no_background_poster, backgroundPoster, callback); } else { ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, false, R.drawable.no_background_poster, backgroundPoster, callback); } // Save background movie image poster to use in PersonProfile page. ActivityUtils.saveStringToPreferences(this, KNOWN_FOR_BACKGROUND_POSTER, container.getBackgroundPath()); }
private void initView() { Picasso.with(this).load(R.drawable.star).resize(900, 1600).centerCrop().into(imgBackgroundStar, new Callback() { @Override public void onSuccess() { AnimationDrawable frameAnimation = (AnimationDrawable) imgBackgroundFire.getDrawable(); frameAnimation.start(); showButtonStartChat(); } @Override public void onError() { } }); Picasso.with(this).load(R.drawable.icon_light_moon).resize(100, 100).centerCrop().into(imgBackgroundMoon); Picasso.with(this).load(R.drawable.background_main_back).resize(500, 322).centerCrop().into(imgBackgroundTree); Picasso.with(this).load(R.drawable.icon_meteor).into(imgMeteor0); Picasso.with(this).load(R.drawable.icon_meteor).into(imgMeteor1); Picasso.with(this).load(R.drawable.icon_meteor).into(imgMeteor2); Picasso.with(this).load(R.drawable.icon_meteor).into(imgMeteor3); }
private void saveResultAndLoadPreview(final SearchResultContainer container, final String text) { // If i don't have items then just save it into the config, it will be ignored on the screen if (container != null && !container.getImages().isEmpty()) { container.setCreatedAt(System.currentTimeMillis()); // Load first image as bitmap and save search results Picasso.with(mContext) .load(container.getFirstThumbnailLink()) .resize(50, 50) .centerCrop() .fetch(new Callback() { @Override public void onSuccess() { saveSearchResultAndRemoveFromLoadingDetections(container, text); } @Override public void onError() { saveSearchResultAndRemoveFromLoadingDetections(container, text); } }); } else { saveSearchResultAndRemoveFromLoadingDetections(new SearchResultContainer(), text); } }
private void loadThumbnailPhoto() { ivPhoto.setScaleX(0); ivPhoto.setScaleY(0); Picasso.with(this) .load(photoUri) .centerCrop() .resize(photoSize, photoSize) .into(ivPhoto, new Callback() { @Override public void onSuccess() { ivPhoto.animate() .scaleX(1.f).scaleY(1.f) .setInterpolator(new OvershootInterpolator()) .setDuration(400) .setStartDelay(200) .start(); } @Override public void onError() { } }); }
private void loadImageFromNetwork(String url, ImageView photoView) { Picasso.with(getContext()) .load(url) .noPlaceholder() .into(photoView, new Callback() { @Override public void onSuccess() { finishLoadingSuccessfully(); } @Override public void onError() { rootView.findViewById(R.id.view_media_progress).setVisibility(View.GONE); } }); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Callback callback = new Callback() { @Override public void onSuccess() { final Bitmap bitmap = ((BitmapDrawable) mask.getDrawable()).getBitmap(); detectMaskHeight(bitmap); detectMaskWidth(bitmap); } @Override public void onError() { } }; // Picasso.with(getContext()) // .load(R.drawable.mask) // .centerCrop() // .fit() // .into(mask, callback); }
public void setimg(final Context ctx, final String postimag) { final ImageView postimage = (ImageView)view.findViewById(R.id.postimage); Picasso.with(ctx).load(postimag).networkPolicy(NetworkPolicy.OFFLINE).into(postimage, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(ctx).load(postimag).into(postimage); } }); }
private void bindPhoto(final PhotoViewHolder holder, int position) { Picasso.with(context) .load(photos.get(position)) .resize(cellSize, cellSize) .centerCrop() .into(holder.ivPhoto, new Callback() { @Override public void onSuccess() { animatePhoto(holder); } @Override public void onError() { } }); if (lastAnimatedItem < position) lastAnimatedItem = position; }
private void loadThumbnailPhoto() { ivPhoto.setScaleX(0); ivPhoto.setScaleY(0); Picasso.with(this) .load(photoUri) .centerCrop() .resize(photoSize, photoSize) .into(ivPhoto, new Callback() { @Override public void onSuccess() { ivPhoto.animate() .scaleX(1.f).scaleY(1.f) .setInterpolator(new OvershootInterpolator()) .setDuration(400) .setStartDelay(200) .start(); } @Override public void onError() { Toast.makeText(getApplicationContext(), "error", Toast.LENGTH_LONG).show(); } }); }
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) public void loadArtworkView(final EMPlaylistManager.PlaylistItem currentItem) { picasso.load(currentItem.getArtworkUrl()).transform(new BlurTransformer(currentItem.getArtworkUrl())).into(artworkView, new Callback() { @Override public void onSuccess() { RotateAnimation ra = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); ra.setRepeatMode(Animation.INFINITE); ra.setRepeatCount(Animation.INFINITE); ra.setDuration(12000l); ra.setInterpolator(new LinearInterpolator()); artworkView.startAnimation(ra); } @Override public void onError() { } }); }