Skip to content

Instantly share code, notes, and snippets.

@kebbbnnn
Last active August 29, 2015 14:13
Show Gist options
  • Save kebbbnnn/a5b14c23254ecdd0182a to your computer and use it in GitHub Desktop.
Save kebbbnnn/a5b14c23254ecdd0182a to your computer and use it in GitHub Desktop.
code snippet in getting the primary and primary dark colors when using picasso
private int colorPrimary;
private int colorPrimaryDark;
Picasso.with(context).load(URL).into(new Target() {
@Override
public void
onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
imageView.setImageBitmap(bitmap);
Palette palette = Palette.generate(bitmap);
colorPrimary = palette.getLightVibrantSwatch().getRgb();
colorPrimaryDark = palette.getDarkVibrantSwatch().getRgb();
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment