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 File: MainActivity.java    From ImageGallery with 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 #2
Source File: PicassoLoader.java    From ImageLoader with 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 #3
Source File: DetailActivity.java    From ListBuddies with 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 #4
Source File: FirebaseInAppMessagingDisplayTest.java    From firebase-android-sdk with 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 #5
Source File: PicassoImageEngine.java    From MNImageBrowser with 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 File: BankDealsAdapter.java    From px-android with 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 File: ProductListAdapter.java    From Jager with 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 File: ShowImageActivity.java    From TuentiTV with 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 File: MakeupProductFragment.java    From FaceT with 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 File: ColorizeFaceActivity.java    From FaceT with 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 File: ProductRecommentationActivity.java    From FaceT with 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 File: ProfileActivity.java    From FaceT with 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 File: MainActivity.java    From FaceT with 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 File: PublishActivity.java    From InstaMaterial with 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 #15
Source File: BoxingPicassoLoader.java    From kcanotify_h5-master with 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 #16
Source File: BookDetailsActivity.java    From NHentai-android with 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 #17
Source File: LoyalUtil.java    From LoyalNativeSlider with 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 #18
Source File: DetailActivity.java    From Dashboard with 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 #19
Source File: OnPicassoImageViewLoader.java    From LoopViewPagerLayout with 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 #20
Source File: TopRatedMovieListAdapter.java    From Movie-Check with 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 #21
Source File: CrewListAdapter.java    From Movie-Check with 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 #22
Source File: NowPlayingMovieListAdapter.java    From Movie-Check with 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 #23
Source File: PersonListAdapter.java    From Movie-Check with 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 #24
Source File: UserProfileAdapter.java    From InstaMaterial with 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 #25
Source File: BigimgActivity.java    From UGank with 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 #26
Source File: ProductDetailActivity.java    From FaceT with 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 #27
Source File: ZoomablePicassoSwippable.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
protected void onSetLayout(final String image_url, final String cctv) {
    mImage = (PhotoView) findViewById(R.id.ssz_uk_co_senab_photoview);
    mCurrMatrixTv = (TextView) findViewById(R.id.ssz_debug_textview);
    // mCurrMatrixTv.setText(cctv);
    mCaptv = (TextView) findViewById(R.id.ssz_caption_textview);
    setCaptionTextviewAdvance(mCaptv, cctv);


    final ProgressBar circle = (ProgressBar) findViewById(R.id.ns_loading_progress);
    Log.d(LOG_TAG, "load image with url : " + image_url + " title:" + cctv);
    picasso.load(image_url).into(mImage, new Callback() {
        @Override
        public void onSuccess() {
            mAttacher = new PhotoViewAttacher(mImage);
            mAttacher.setOnMatrixChangeListener(new MatrixChangeListener());
            mAttacher.setOnPhotoTapListener(new PhotoTapListener());
            circle.setVisibility(View.GONE);
            mImage.post(new Runnable() {
                @Override
                public void run() {
                    mAttacher.setScale(2f, mImage.getWidth() / 2, mImage.getHeight() / 2, true);
                }
            });

            //slidrInf.unlock();
            mAttacher.setScale(1.5f);

        }

        @Override
        public void onError() {
            circle.setVisibility(View.GONE);
        }
    });


}
 
Example #28
Source File: FiamImageLoaderTest.java    From firebase-android-sdk with 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 #29
Source File: ProfileActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
private void setupUserData() {

        mDatabaseUsers.child(mAuth.getCurrentUser().getUid()).addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {

                if (dataSnapshot.getValue() != null) {
                    Log.i("dataSnapshot.getValue()", dataSnapshot.getValue().toString());
                    final User user_data = dataSnapshot.getValue(User.class);
                    Log.e(user_data.getName(), "User data is null!");
                    mOwnNameField.setText(user_data.getName());
                    profile_email.setText(user_data.getEmail());
                    Picasso.with(getApplicationContext()).load(user_data.getImage()).networkPolicy(NetworkPolicy.OFFLINE).into(profilePic, new Callback() {
                        @Override
                        public void onSuccess() {
                        }

                        @Override
                        public void onError() {
                            Picasso.with(getApplicationContext())
                                    .load(user_data.getImage())
                                    .centerCrop()
                                    .fit()
                                    .into(profilePic);
                        }
                    });
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
 
Example #30
Source File: ExtViewQuery.java    From COCOQuery with Apache License 2.0 5 votes vote down vote up
/**
 * Load network image to current ImageView with callback
 * @param url
 * @param callback
 * @return
 */
public ExtViewQuery image(String url, Callback callback) {
    if (!TextUtils.isEmpty(url) && view instanceof ImageView) {
        Picasso.with(context).load(url).into((ImageView) view, callback);
    }
    return self();
}