Giter Site home page Giter Site logo

glidepalette's Introduction

GlidePalette

Alt sample

Android app on Google Play

Download

Buy Me a Coffee at ko-fi.com

In your module Download

compile 'com.github.florent37:glidepalette:2.1.2'

compile 'com.github.bumptech.glide:glide:4.6.1'

Sample

Glide.with(this).load(url)
         .listener(GlidePalette.with(url)
               .use(GlidePalette.Profile.MUTED_DARK)
                   .intoBackground(textView)
                   .intoTextColor(textView)

               .use(GlidePalette.Profile.VIBRANT)
                    .intoBackground(titleView, GlidePalette.Swatch.RGB)
                    .intoTextColor(titleView, GlidePalette.Swatch.BODY_TEXT_COLOR)
                    .crossfade(true)
         );
         .into(imageView);

Initialisation

First, init GlidePalette with an Url

GlidePalette.with(url)

Palettes

You can successively use following Palettes :

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

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

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

Swatches

With the following Swatches

  • 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)

with optional Background Crossfade effect

.crossfade(true)
    // will use default 300ms crossfade
.crossfade(true, 1000)
    // specify own crossfade speed in ms

CallBack

Or simply return into CallBack

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

TODO

Community

Looking for contributors, feel free to fork !

Dependencies

Credits

Author: Florent Champigny

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

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.

glidepalette's People

Contributors

bryant1410 avatar erhanbicer avatar florent37 avatar itscalebjones avatar kabouzeid avatar timusus avatar tomaszrykala 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  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

glidepalette's Issues

methode for Context ?

The with method inherits only a String.

It would be better if he could inherit an int

I do not know how to use this on a onBindViewHolder

(RecyclerView.ViewHolder)

New LruCache is created for every entry.

Instead of using a single LRUCache and drawing from it when necessary, a new LruCache is being created with every call to start(), thus the cache is never actually hit.
#8 fixes this.

Glide 3.6.1

It seems like Glide has updated to version 3.6.1 instead of the expected version 3.6.0

I suppose this is the reason why this is not working: [..]
Edit: messed that up, thanks for the helpful answer.

Failed to resolve: com.github.bumptech.glide:glide:4.0.0-SNAPSHOT

I've added dependency
compile 'com.github.florent37:glidepalette:2.0.0'
and I'm getting:
Error:Failed to resolve: com.github.bumptech.glide:glide:4.0.0-SNAPSHOT <a href="openFile:/home/githubzz/App/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Crossfade

Similar to Glide's crossfade method, it would be nice to have an ability to provide crossfade animation between current color into new ones.

NPE while scrolling

I was scrolling through a recyclerView using GlidePalette and ran into this NPE.

java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference
	at com.github.florent37.glidepalette.BitmapPalette.apply(BitmapPalette.java:128)
	at com.github.florent37.glidepalette.BitmapPalette.start(BitmapPalette.java:218)
	at com.github.florent37.glidepalette.GlidePalette.onResourceReady(GlidePalette.java:111)
	at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:539)
	at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:516)
	at com.bumptech.glide.request.SingleRequest.begin(SingleRequest.java:231)
	at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:373)
	at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:428)

Relevant adapter code:

@Override
public void onBindViewHolder(ViewHolder viewHolder, final int pos) {
	RequestOptions options = new RequestOptions()
			.placeholder(R.drawable.map_default_square)
			.centerCrop();
	Glide.with(context)
			.load(styles.get(pos).getImageUrl())
			.apply(options)
			.listener(GlidePalette.with(styles.get(pos).getImageUrl())
					.use(GlidePalette.Profile.MUTED_DARK)
					.intoBackground(viewHolder.container)
			)
			.transition(DrawableTransitionOptions.withCrossFade())
			.into(viewHolder.styleImage);
}

Using Glide 4.1.1, GlidePalette 2.1.1, Nexus 6P on Android Oreo.

Glide: Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored

Crossfade changes layout

Crossfading the background color of a TextView removes the padding after the color is set. Tested on Android 4.0.3.

Glide.with(context).load(imageUrl).listener(GlidePalette.with(imageUrl).use(GlidePalette.Profile.VIBRANT)
                    .intoBackground(holder.titleView, GlidePalette.Swatch.RGB).intoCallBack(
                            new GlidePalette.CallBack() {
                                @Override
                                public void onPaletteLoaded(Palette palette) {
                                    holder.headerBgColor = palette.getVibrantColor(-1);
                                }
                            }).crossfade(true))
                    .into(holder.imageView);
<TextView
            android:id="@+id/titel_tv"
            style="@style/MyTextTitleResourceInverse"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@color/cardview_dark_background"
            android:ellipsize="end"
            android:gravity="center"
            android:maxLines="2"
            android:paddingBottom="6dp"
            android:paddingLeft="12dp"
            android:paddingRight="12dp"
            android:paddingTop="6dp"
            android:textSize="16sp"
            android:transitionName="@string/transaction_resources_toc_to_resource"
            tools:ignore="UnusedAttribute" tools:text="Test Title with some longer text so I can see if the padding really works"/>

Android support library error (Update the glide palette sdk)

After updating Android Studio and the SDKs, I'm getting error in build.gradle dependencies saying that android support library mismatch. All the SDKs have been updated while Glide palette still uses old SDKs (mixing versions can lead to runtime crashes). Please update the glide palette sdk with latest support library.

My android-support SDK is at: 26.0.0-alpha1

intoBackground() overrides CardView corner radius

When the target is a android.support.v7.widget.CardView, intoBackground() overrides the corner radius and elevation settings of the cardview.

GlidePalette.with(imageURL)
    .use(GlidePalette.Profile.MUTED_LIGHT)
    .intoBackground(aCardView)

Update SDK to Android O: v26.0.0

After updating Android Studio and the SDKs, I'm getting error in build.gradle dependencies saying that android support library mismatch. All the SDKs have been updated while Glide palette still uses old SDKs (mixing versions can lead to runtime crashes). Please update the glide palette sdk with latest support library.

My android-support SDK is at: 26.0.0-alpha1

Not working on glide v4.8

Both of the followinf calls are not working. Second intoCallback is never executed.

            GlidePalette.with(paletteString)
                    .use(GlidePalette.Profile.MUTED)
                    .intoBackground(layout);
            GlidePalette.with(paletteString)
                    .use(GlidePalette.Profile.MUTED)
                    .intoCallBack(
                            palette -> {
                                int bgColor = getBackgroundColor(palette);
                                if (bgColor != -1)
                                    layout.setBackgroundColor(bgColor);
                            });

Whether it has a glide failed callback?

When I use gilde, i always use a placeholder image resouce. So gilde will set the placeholder into the target imageview at first. When glide load image failed, the target imageview will show the placeholder image.

When I use GlidePalette, the onPaletteLoaded(Palette palette) just only called when the glide loaded the image successfully. if load image failed, it won't callback.
I think it's better to add a callback when glide load image failed. Then I can use my default palette color just like placeholder image.

forget my poor English...

jcenter Migration

Now that jcenter has reached it's end of life, will you be migrating this library over to MavenCentral?

Update Glide

Hi, can we have an update to latest Glide (4.6.1 atm), please? It's progressing quite fast.

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.