Last active
April 25, 2016 15:41
-
-
Save Rexee/123f653c27bc367dd679563c921b66ce to your computer and use it in GitHub Desktop.
Using "Palette"
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
final int bgColor = getResources().getColor(R.color.colorPrimary); | |
ImageLoader.getInstance().displayImage(user.getImageUrl(), header, new SimpleImageLoadingListener() { | |
@Override | |
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { | |
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { | |
Palette.from(loadedImage).generate(new PaletteAsyncListener() { | |
@SuppressLint("NewApi") | |
@Override | |
public void onGenerated(Palette palette) { | |
Swatch vibrant = palette.getVibrantSwatch(); | |
if (vibrant == null) { | |
vibrant = palette.getDarkVibrantSwatch(); | |
} | |
if (vibrant == null) return; | |
Window window = getWindow(); | |
window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | |
window.setStatusBarColor(vibrant.getRgb()); | |
toolbar.setBackgroundColor(palette.getMutedColor(bgColor)); | |
} | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment