Using the Palatte API in a ListView Adapter

Well, at first everything, I have not yet converted to use RecylerView; if for any reason this answers this question, let me know.

In the meantime, I'm trying to add a splash of different colors in ListViewusing Palette.

Imagine this: on Twitter you have a timeline, each line has a user profile picture. I am making the equivalent of creating a background for each line based on a user profile image.

I also use Picassoto upload images.

In my adapter, I do this:

try {
    Picasso.with(context).load(url).placeholder(R.drawable.usericon).transform(new CircularTransform())
            .into(holder.i1);

    holder.i1.buildDrawingCache();
    Bitmap b = holder.i1.getDrawingCache();

    final ViewHolder finalHolder = holder;
    Palette.generateAsync(b, new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {

            Palette.Swatch vibrant = palette.getVibrantSwatch();
            if (vibrant != null) {
                finalHolder.r1.setBackgroundColor(
                        vibrant.getRgb());
                finalHolder.tv3.setTextColor(
                        vibrant.getTitleTextColor());
                finalHolder.l1.setBackgroundColor(
                        vibrant.getRgb());
                finalHolder.tv8.setTextColor(
                        vibrant.getTitleTextColor());
            }

        }
    });


} catch (Exception e) {

}

; , . 5 5 , , . ARE - , Swatch. , .

, : ? , ?

+4

All Articles