Giter Site home page Giter Site logo

florent37 / picassopalette Goto Github PK

View Code? Open in Web Editor NEW
365.0 12.0 35.0 1.18 MB

Android Lollipop Palette is now easy to use with Picasso !

Home Page: http://florent37.github.io/PicassoPalette

License: Apache License 2.0

Java 100.00%
picasso palette material v7 glide image loading color

picassopalette's Introduction

PicassoPalette

Android app on Google Play

Android Arsenal

Alt sample

Download

Buy Me a Coffee at ko-fi.com

In your module Download

compile 'com.github.florent37:picassopalette:2.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'

Sample

Picasso.with(this).load(url.toString()).into(imageView,
         PicassoPalette.with(url.toString(), imageView)
               .use(PicassoPalette.Profile.MUTED_DARK)
                   .intoBackground(textView)
                   .intoTextColor(textView)

               .use(PicassoPalette.Profile.VIBRANT)
                    .intoBackground(titleView, PicassoPalette.Swatch.RGB)
                    .intoTextColor(titleView, PicassoPalette.Swatch.BODY_TEXT_COLOR)
         );

Initialisation

First, init PicassoPalette with an Url and an ImageView

PicassoPalette.with(url.toString(), imageView)

Palettes

You can successively use following palettes :

  • Palette.VIBRANT
  • Palette.VIBRANT_DARK
  • Palette.VIBRANT_LIGHT
  • Palette.MUTED
  • Palette.MUTED_DARK
  • Palette.MUTED_LIGHT
.use(PicassoPalette.Profile.MUTED_DARK)

Each time you call "use" the next modification will follow this Profile

.use(PicassoPalette.Profile.MUTED_DARK)
    //next operations will use Profile.MUTED_DARK
.use(PicassoPalette.Profile.VIBRANT)
    //next operations will use Profile.VIBRANT

Swatches

With the following Swatchs

  • RGB
  • TITLE_TEXT_COLOR
  • BODY_TEXT_COLOR

Targets

Into Backgrounds

.intoBackground(view)
.intoBackground(view,Swatch.RGB)

And TextView Color

.intoTextColor(textView)
.intoTextColor(textView,Swatch.TITLE_TEXT_COLOR)

CallBack

Or simply return into CallBack

.intoCallBack(
    new PicassoPalette.CallBack() {
          @Override
          public void onPaletteLoaded(Palette palette) {
              //specific task
          }
    })

TODO

Community

Looking for contributors, feel free to fork !

Dependencies

Credits

Author: Florent Champigny

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2015 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

picassopalette's People

Contributors

bryant1410 avatar florent37 avatar melaniejae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

picassopalette's Issues

Kotlin crash with NoClassDefFoundError Palette$Builder

Hi

Im trying to use compile 'com.github.florent37:picassopalette:1.0.2@aar' from kotlin.

Picasso.with(holder.itemView.context)
                .load(item.picUrl)
                .placeholder(R.drawable.ic_face_black_48dp)
                .into(holder.itemView.itemImageView,
                        PicassoPalette.with(item.picUrl, holder.itemView.itemImageView)
                                .use(BitmapPalette.Profile.MUTED_DARK)
                                .intoBackground(holder.itemView.itemImageView)
                     )

But I get:

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/graphics/Palette$Builder; at com.github.florent37.picassopalette.BitmapPalette.start(BitmapPalette.java:159) at com.github.florent37.picassopalette.PicassoPalette.onBitmapLoaded(PicassoPalette.java:81) at com.github.florent37.picassopalette.PicassoPalette.onSuccess(PicassoPalette.java:99) at com.squareup.picasso.ImageViewAction.complete(ImageViewAction.java:51) at com.squareup.picasso.Picasso.deliverAction(Picasso.java:558) at com.squareup.picasso.Picasso.complete(Picasso.java:510) at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:117) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6843) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.graphics.Palette$Builder" on path: DexPathList[[zip file "/data/app/com.barista_v.wapa.stylist-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at com.github.florent37.picassopalette.BitmapPalette.start(BitmapPalette.java:159)  at com.github.florent37.picassopalette.PicassoPalette.onBitmapLoaded(PicassoPalette.java:81)  at com.github.florent37.picassopalette.PicassoPalette.onSuccess(PicassoPalette.java:99)  at com.squareup.picasso.ImageViewAction.complete(ImageViewAction.java:51)  at com.squareup.picasso.Picasso.deliverAction(Picasso.java:558)  at com.squareup.picasso.Picasso.complete(Picasso.java:510)  at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:117)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:6843)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)  Suppressed: java.lang.ClassNotFoundException: android.support.v7.graphics.Palette$Builder at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

Already tried using kapt:

    compile 'com.github.florent37:picassopalette:1.0.2@aar'
    kapt 'com.github.florent37:picassopalette:1.0.2@aar'
}

kapt {
  generateStubs = true
}

But still happens.
What can I do?

java.lang.AbstractMethodError: abstract method not implemented

java.lang.AbstractMethodError: abstract method not implemented
at com.github.florent37.picassopalette.PicassoPalette.onError(PicassoPalette.java)
at com.squareup.picasso.ImageViewAction.error(ImageViewAction.java:72)
at com.squareup.picasso.Picasso.deliverAction(Picasso.java:581)
at com.squareup.picasso.Picasso.complete(Picasso.java:528)
at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:122)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5030)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:832)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:648)
at dalvik.system.NativeStart.main(Native Method)

artifact on jcenter only.

Please specify (within the README) that the artifact is only available on jcenter() :)
( not fetchable through mavenCentral() )
Thanks

Why the library has deprecated methods?

This library has deprected methods I still prefer the JakeWharton's code specified here to generate palettes with the following tweak

Could you please update the library with non-deprecated methods?

@Override
        public Bitmap transform(Bitmap source) {
            CACHE.put(source, new Palette.Builder(source).generate());
            return source;
        }

LruCache not found on api < 12

Hi there, when I try to execute the app on a devide with api < 12 I get the following error, this is because you've set minSdk 10 although you are using in your project file PicassoPalette.java the class android.util.LruCache which was introduced in api 12. You should consider either changing the minSdk to 12 or using android.support.v4.util.LruCache inside the support-v4 library.

I wish you take this into account. Thank you.

E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NoClassDefFoundError: android.util.LruCache at com.a.a.a.b.<init>(PicassoPalette.java:35) at com.a.a.a.b.a(PicassoPalette.java:75) at com.alm.popularmovies.f.onBindViewHolder(MoviesAdapter.java:1055) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6308) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6341) at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5287) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5550) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5392) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5388) at android.support.v7.widget.bt.a(LinearLayoutManager.java:2149) at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1496) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:593) at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3535) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3264) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3796) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.view.ViewRoot.performTraversals(ViewRoot.java:1146) at android.view.ViewRoot.handleMessage(ViewRoot.java:1865) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) at dalvik.system.NativeStart.main(Native Method)

Cache is instance local

Gave a cursory look at BitmapPalette and I'm curious as to why the cache is an instance variable. For my use case I'm instantiating new PicassoPalette inside an adapter's onBindView. Each instance is transient and it's cache wont warm up.

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/AsyncTaskCompat

FATAL EXCEPTION: main
Process: me.bakumon.ugank, PID: 29278
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/AsyncTaskCompat;
at android.support.v7.graphics.Palette$Builder.generate(Palette.java:830)
at com.github.florent37.picassopalette.PicassoPalette.start(PicassoPalette.java:190)
at com.github.florent37.picassopalette.PicassoPalette.onBitmapLoaded(PicassoPalette.java:206)
at com.github.florent37.picassopalette.PicassoPalette.onSuccess(PicassoPalette.java:224)
at com.squareup.picasso.ImageViewAction.complete(ImageViewAction.java:51)
at com.squareup.picasso.Picasso.deliverAction(Picasso.java:558)
at com.squareup.picasso.Picasso.a(Picasso.java:510)
at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:117)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7555)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.os.AsyncTaskCompat" on path: DexPathList[[zip file "/data/app/me.bakumon.ugank-WiOpbcMGHFCThYnDvJwWOQ==/base.apk"],nativeLibraryDirectories=[/data/app/me.bakumon.ugank-WiOpbcMGHFCThYnDvJwWOQ==/lib/arm64, /system/lib64, /vendor/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.support.v7.graphics.Palette$Builder.generate(Palette.java:830) 
at com.github.florent37.picassopalette.PicassoPalette.start(PicassoPalette.java:190) 
at com.github.florent37.picassopalette.PicassoPalette.onBitmapLoaded(PicassoPalette.java:206) 
at com.github.florent37.picassopalette.PicassoPalette.onSuccess(PicassoPalette.java:224) 
at com.squareup.picasso.ImageViewAction.complete(ImageViewAction.java:51) 
at com.squareup.picasso.Picasso.deliverAction(Picasso.java:558) 
at com.squareup.picasso.Picasso.a(Picasso.java:510) 
at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:117) 
at android.os.Handler.dispatchMessage(Handler.java:109) 
at android.os.Looper.loop(Looper.java:166) 
at android.app.ActivityThread.main(ActivityThread.java:7555) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963) 

Palette, Profile, Swatch - need help to understand the terms

First - thanks for the great library. I need some help to properly understand the terms - palette, proflle and swatch. Ok, palette should be a collection of colors. Profile - a predefined palette. Right? But this swatch thing is quite confusing. What means "RGB swatch" Why exactly RGB? That's a color representation scheme. How's that related to the actual target?
Then this text color...

public PicassoPalette intoTextColor(TextView textView) {
      return this.intoBackground(textView, Swatch.TITLE_TEXT_COLOR);
}

How come setting the text color actually assigns a background or do I miss something!? The library is very useful and it already improved my view appearance a lot. But some more explanations in the docs are needed to get the most of it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.