com.squareup.picasso.Callback Java Examples

The following examples show how to use com.squareup.picasso.Callback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: kcanotify_h5-master   Author: qly5213   File: BoxingPicassoLoader.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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);
            }
        }
    });
}
 
Example #2
Source Project: firebase-android-sdk   Author: firebase   File: FirebaseInAppMessagingDisplayTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void streamListener_whenImageLoadSucceeds_startsImpressionTimer() {
  resumeActivity(activity);
  listener.displayMessage(IMAGE_MESSAGE_MODEL, callbacks);
  verify(fakeRequestCreator).into(any(ImageView.class), callbackArgCaptor.capture());

  callbackArgCaptor.getValue().onSuccess();
  verify(impressionTimer)
      .start(
          any(RenewableTimer.Callback.class),
          ArgumentMatchers.eq(
              com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay
                  .IMPRESSION_THRESHOLD_MILLIS),
          ArgumentMatchers.eq(
              com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay
                  .INTERVAL_MILLIS));
}
 
Example #3
Source Project: ImageLoader   Author: hss01248   File: PicassoLoader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 * http://blog.csdn.net/u014592587/article/details/47070075
 *
 * https://github.com/square/picasso/issues/1025
 * @param url
 * @return
 */
@Override
public File getFileFromDiskCache(final String url) {

    Picasso.with(ImageLoader.context)
            .load(url)
            .fetch(new Callback() {
                @Override
                public void onSuccess() {

                }

                @Override
                public void onError() {

                }
            });
    return null;
}
 
Example #4
Source Project: ListBuddies   Author: jpardogo   File: DetailActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    overridePendingTransition(0, 0);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.detail_activity);
    ButterKnife.inject(this);
    mBackground = mImageView;
    String imageUrl = getIntent().getExtras().getString(EXTRA_URL);
    Picasso.with(this).load(imageUrl).into((ImageView) findViewById(R.id.image), new Callback() {
        @Override
        public void onSuccess() {
            moveBackground();
        }

        @Override
        public void onError() {
        }
    });
}
 
Example #5
Source Project: MNImageBrowser   Author: maning0303   File: PicassoImageEngine.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void loadImage(Context context, String url, ImageView imageView, final View progressView) {
    Picasso.get()
            .load(url)
            .placeholder(R.drawable.default_placeholder)
            .error(R.mipmap.ic_launcher)
            .into(imageView, new Callback() {
                @Override
                public void onSuccess() {
                    progressView.setVisibility(View.GONE);
                }

                @Override
                public void onError(Exception e) {
                    progressView.setVisibility(View.GONE);
                }
            });
}
 
Example #6
Source Project: px-android   Author: mercadopago   File: BankDealsAdapter.java    License: MIT License 6 votes vote down vote up
private void loadBankLogo(final BankDeal bankDeal) {
    bankImageView.setVisibility(View.GONE);

    if (bankDeal.hasPictureUrl()) {
        ViewUtils.loadOrCallError(bankDeal.getPicture().getUrl(), bankImageView, new Callback.EmptyCallback() {
            @Override
            public void onSuccess() {
                bankImageView.setVisibility(View.VISIBLE);
                logoName.setVisibility(View.GONE);
            }

            @Override
            public void onError() {
                logoName.setVisibility(View.VISIBLE);
                bankImageView.setVisibility(View.GONE);
            }
        });
    }
}
 
Example #7
Source Project: Jager   Author: JaspervanRiet   File: ProductListAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void loadImage (final ProductViewHolder holder) {
	String imgUrl = mProducts.get (holder.getLayoutPosition ())
			.getScreenshotUrl ().getSmallImgUrl ();
	holder.progressWheel.setVisibility (View.VISIBLE);
	holder.progressWheel.spin ();
	Picasso.with (mContext).load (imgUrl)
			.fit ()
			.centerCrop ()
			.into (holder.screenshot, new Callback () {
				@Override
				public void onSuccess () {
					holder.progressWheel.setVisibility (View.GONE);
					holder.progressWheel.stopSpinning ();
				}

				@Override
				public void onError () {
					// TODO: Error view
				}
			});
}
 
Example #8
Source Project: TuentiTV   Author: pedrovgs   File: ShowImageActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  setContentView(R.layout.show_image_activity);
  super.onCreate(savedInstanceState);
  String imageUrl = getImageUrlFromExtras();
  Picasso.with(this).load(imageUrl).into(iv_media_element, new Callback() {
    @Override public void onSuccess() {
      animateImageView();
      updateImageViewBackground();
      hideLoading();
    }

    @Override public void onError() {
      finish();
    }
  });
}
 
Example #9
Source Project: FaceT   Author: clementf2b   File: MakeupProductFragment.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public void setImage(final Context ctx, final String image) {
    final ImageView makeup_apply_product_image = (ImageView) mView.findViewById(R.id.makeup_apply_product_image);
    Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(makeup_apply_product_image, new Callback() {
        @Override
        public void onSuccess() {
            Log.d(TAG, "image loading success !");
        }

        @Override
        public void onError() {
            Log.d(TAG, "image loading error !");
            Picasso.with(ctx)
                    .load(image)
                    .resize(100, 100)
                    .centerCrop()
                    .into(makeup_apply_product_image);
        }
    });
}
 
Example #10
Source Project: FaceT   Author: clementf2b   File: ColorizeFaceActivity.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public void setImage(final Context ctx, final String image) {
    final ImageView makeup_product_image = (ImageView) mView.findViewById(R.id.makeup_product_image);
    Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(makeup_product_image, new Callback() {
        @Override
        public void onSuccess() {
            Log.d(TAG, "image loading success !");
        }

        @Override
        public void onError() {
            Log.d(TAG, "image loading error !");
            Picasso.with(ctx)
                    .load(image)
                    .resize(100, 100)
                    .centerCrop()
                    .into(makeup_product_image);
        }
    });
}
 
Example #11
Source Project: FaceT   Author: clementf2b   File: ProductRecommentationActivity.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public void setImage(final Context ctx, final String image) {
    final ImageView post_image = (ImageView) mView.findViewById(R.id.product_image);
    Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(post_image, new Callback() {
        @Override
        public void onSuccess() {
            Log.d(TAG, "image loading success !");
        }

        @Override
        public void onError() {
            Log.d(TAG, "image loading error !");
            Picasso.with(ctx)
                    .load(image)
                    .resize(100, 100)
                    .centerCrop()
                    .into(post_image);
        }
    });
}
 
Example #12
Source Project: FaceT   Author: clementf2b   File: ProfileActivity.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public void setImage(final Context ctx, final String image) {
    final ImageView product_image = (ImageView) mView.findViewById(R.id.product_image);
    Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(product_image, new Callback() {
        @Override
        public void onSuccess() {
            Log.d(TAG, "image loading success !");
        }

        @Override
        public void onError() {
            Log.d(TAG, "image loading error !");
            Picasso.with(ctx)
                    .load(image)
                    .resize(90, 90)
                    .centerCrop()
                    .into(product_image);
        }
    });
}
 
Example #13
Source Project: FaceT   Author: clementf2b   File: MainActivity.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public void setImage(final Context ctx, final String image) {
    final ImageView post_image = (ImageView) mView.findViewById(R.id.product_image);
    Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(post_image, new Callback() {
        @Override
        public void onSuccess() {
            Log.d(TAG, "image loading success !");
        }

        @Override
        public void onError() {
            Log.d(TAG, "image loading error !");
            Picasso.with(ctx)
                    .load(image)
                    .resize(100, 100)
                    .centerCrop()
                    .into(post_image);
        }
    });
}
 
Example #14
Source Project: FaceT   Author: clementf2b   File: ProductDetailActivity.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public void setUserImage(final Context ctx, final String userImage) {
    if (userImage != null && userImage.length() > 0) {
        Log.d(TAG + "userImage", userImage);
        Picasso.with(ctx).load(userImage).networkPolicy(NetworkPolicy.OFFLINE).into(user_image, new Callback() {
            @Override
            public void onSuccess() {
                Log.d(TAG, "image loading success !");
            }

            @Override
            public void onError() {
                Log.d(TAG, "image loading error !");
                Picasso.with(ctx)
                        .load(userImage)
                        .resize(50, 50)
                        .centerCrop()
                        .into(user_image);
            }
        });

    }
}
 
Example #15
Source Project: InstaMaterial   Author: frogermcs   File: PublishActivity.java    License: Apache License 2.0 6 votes vote down vote up
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() {
                }
            });
}
 
Example #16
Source Project: UGank   Author: Bakumon   File: BigimgActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void loadMeizuImg(String url) {
    Picasso.with(this)
            .load(url)
            .into(imgBig, new Callback() {
                @Override
                public void onSuccess() {
                    // 这里可能会有内存泄露
                    hideLoading();
                }

                @Override
                public void onError() {

                }
            });
}
 
Example #17
Source Project: InstaMaterial   Author: frogermcs   File: UserProfileAdapter.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #18
Source Project: Movie-Check   Author: tassioauad   File: PersonListAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    Person person = personList.get(position);

    holder.itemView.setTag(person);
    holder.textViewName.setText(person.getName());
    String posterUrl = holder.itemView.getContext().getString(R.string.imagetmdb_baseurl) + person.getProfilePath();
    holder.progressBar.setVisibility(View.VISIBLE);
    Picasso.with(holder.itemView.getContext()).load(posterUrl).placeholder(R.drawable.noimage).into(holder.imageViewPoster, new Callback() {
        @Override
        public void onSuccess() {
            holder.progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onError() {
            holder.progressBar.setVisibility(View.GONE);
            Picasso.with(holder.itemView.getContext()).load(R.drawable.noimage).into(holder.imageViewPoster);
        }
    });
}
 
Example #19
Source Project: Movie-Check   Author: tassioauad   File: NowPlayingMovieListAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    Movie movie = movieList.get(position);

    holder.itemView.setTag(movie);
    String posterUrl = holder.itemView.getContext().getString(R.string.imagetmdb_baseurl) + movie.getBackdropUrl();
    Picasso.with(holder.itemView.getContext()).load(posterUrl).placeholder(R.drawable.noimage).into(holder.imageViewBackdrop);
    holder.progressBar.setVisibility(View.VISIBLE);
    Picasso.with(holder.itemView.getContext()).load(posterUrl).placeholder(R.drawable.noimage).into(holder.imageViewBackdrop, new Callback() {
        @Override
        public void onSuccess() {
            holder.progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onError() {
            holder.progressBar.setVisibility(View.GONE);
        }
    });
    holder.textViewName.setText(movie.getTitle());
}
 
Example #20
Source Project: Movie-Check   Author: tassioauad   File: CrewListAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    Crew crew = crewList.get(position);

    holder.itemView.setTag(crew);
    holder.textViewName.setText(crew.getName());
    holder.textViewJob.setText(crew.getJob());
    holder.progressBar.setVisibility(View.VISIBLE);
    String posterUrl = holder.itemView.getContext().getString(R.string.imagetmdb_baseurl) + crew.getProfilePath();
    Picasso.with(holder.itemView.getContext()).load(posterUrl).placeholder(R.drawable.noimage).into(holder.imageViewProfile, new Callback() {
        @Override
        public void onSuccess() {
            holder.progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onError() {
            holder.progressBar.setVisibility(View.GONE);
            Picasso.with(holder.itemView.getContext()).load(R.drawable.noimage).into(holder.imageViewProfile);
        }
    });
}
 
Example #21
Source Project: Movie-Check   Author: tassioauad   File: TopRatedMovieListAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    Movie movie = movieList.get(position);
    String posterUrl = holder.itemView.getContext().getString(R.string.imagetmdb_baseurl) + movie.getPosterUrl();

    holder.itemView.setTag(movie);
    holder.progressBar.setVisibility(View.VISIBLE);
    Picasso.with(holder.itemView.getContext()).load(posterUrl).placeholder(R.drawable.noimage).into(holder.imageViewPoster, new Callback() {
        @Override
        public void onSuccess() {
            holder.progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onError() {
            holder.progressBar.setVisibility(View.GONE);
        }
    });
    holder.textViewRate.setText(String.valueOf(movie.getVoteAverage()));
}
 
Example #22
Source Project: LoopViewPagerLayout   Author: why168   File: OnPicassoImageViewLoader.java    License: MIT License 6 votes vote down vote up
@Override
public void onLoadImageView(ImageView imageView, Object object) {
    Picasso
            .with(imageView.getContext())
            .load((String) object)
            .error(R.mipmap.a)
            .into(imageView, new Callback() {
                @Override
                public void onSuccess() {
                    L.e("Picasso ---> onSuccess");
                }

                @Override
                public void onError() {
                    L.e("Picasso ---> onError");
                }
            });
}
 
Example #23
Source Project: Dashboard   Author: Supremez   File: DetailActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mImageView = (ImageView) findViewById(R.id.image);
    progressBar = (ProgressBar) findViewById(R.id.loading);
    mAttacher = new PhotoViewAttacher(mImageView);


    ViewCompat.setTransitionName(mImageView, EXTRA_IMAGE);
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(mImageView, new Callback.EmptyCallback() {
        @Override public void onSuccess() {
            progressBar.setVisibility(View.GONE);
        }
        @Override
        public void onError() {
            progressBar.setVisibility(View.GONE);
        }


    });
}
 
Example #24
Source Project: LoyalNativeSlider   Author: jjhesk   File: LoyalUtil.java    License: MIT License 6 votes vote down vote up
public static void picassoImplementation(String u, final ImageView target, Context context, final Runnable callback) {
    Picasso.with(context)
            .load(u)
            .memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE)
            .into(target, new Callback() {
                @Override
                public void onSuccess() {
                    callback.run();
                }

                @Override
                public void onError() {

                }
            });
}
 
Example #25
Source Project: NHentai-android   Author: NoireFHC   File: BookDetailsActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostExecute(File result) {
	Picasso.with(getApplicationContext())
			.load(result)
			.into(mImageView, new Callback() {
				@Override
				public void onSuccess() {
					MaterialImageLoading.animate(mImageView).setDuration(1500).start();
				}

				@Override
				public void onError() {

				}
			});
}
 
Example #26
Source Project: ImageGallery   Author: lawloretienne   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void loadFullScreenImage(final ImageView iv, String imageUrl, int width, final LinearLayout bgLinearLayout) {
    if (!TextUtils.isEmpty(imageUrl)) {
        Picasso.with(iv.getContext())
                .load(imageUrl)
                .resize(width, 0)
                .into(iv, new Callback() {
                    @Override
                    public void onSuccess() {
                        Bitmap bitmap = ((BitmapDrawable) iv.getDrawable()).getBitmap();
                        Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
                            public void onGenerated(Palette palette) {
                                applyPalette(palette, bgLinearLayout);
                            }
                        });
                    }

                    @Override
                    public void onError() {

                    }
                });
    } else {
        iv.setImageDrawable(null);
    }
}
 
Example #27
Source Project: firebase-android-sdk   Author: firebase   File: FirebaseInAppMessagingDisplayTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void streamListener_whenImageUrlExists_loadsImage() {
  when(windowManager.isFiamDisplayed()).thenReturn(true);
  resumeActivity(activity);
  listener.displayMessage(IMAGE_MESSAGE_MODEL, callbacks);

  verify(fakeRequestCreator).tag(TestActivity.class);
  verify(fakeRequestCreator).placeholder(R.drawable.image_placeholder);
  verify(fakeRequestCreator).into(any(ImageView.class), any(Callback.class));
}
 
Example #28
Source Project: firebase-android-sdk   Author: firebase   File: FirebaseInAppMessagingDisplayTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void streamListener_whenNoImageUrlExists_doesNotLoadImage() {
  resumeActivity(activity);
  listener.displayMessage(null, callbacks);
  verify(fakeRequestCreator, times(0)).tag(TestActivity.class);
  verify(fakeRequestCreator, times(0)).placeholder(R.drawable.image_placeholder);
  verify(fakeRequestCreator, times(0)).into(any(ImageView.class), any(Callback.class));
}
 
Example #29
Source Project: firebase-android-sdk   Author: firebase   File: FiamImageLoaderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void into_invokesUnderlyingRequestCreator() {
  ImageView imageView = mock(ImageView.class);
  Callback callback = mock(Callback.class);

  when(picasso.load(IMAGE_URL)).thenReturn(requestCreator);
  FiamImageLoader.FiamImageRequestCreator fiamImageRequestCreator = imageLoader.load(IMAGE_URL);
  fiamImageRequestCreator.into(imageView, callback);

  verify(requestCreator).into(imageView, callback);
}
 
Example #30
Source Project: Material-Movies   Author: saulmm   File: MoviesAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(final MovieViewHolder holder, final int position) {

    Movie selectedMovie = mMovieList.get(position);

    holder.titleTextView.setText(selectedMovie.getTitle());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        holder.coverImageView.setTransitionName("cover" + position);

    String posterURL = Constants.BASIC_STATIC_URL + selectedMovie.getPoster_path();

    Picasso.with(mContext)
        .load(posterURL)
        .fit().centerCrop()
        .into(holder.coverImageView, new Callback() {
            @Override
            public void onSuccess() {

                mMovieList.get(position).setMovieReady(true);
            }

            @Override
            public void onError() {

            }
        });
}