Last active
August 29, 2015 14:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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