Android Drawable Color fixParallaxBackgroundPreJBMR1(final View view, final Drawable drawable)

Here you can find the source of fixParallaxBackgroundPreJBMR1(final View view, final Drawable drawable)

Description

Hack to fix pre JB MR1 Kudos to @cyrilmottier

Parameter

Parameter Description
view view drawable attached too.
drawable drawable which gets invalidated

Declaration

static void fixParallaxBackgroundPreJBMR1(final View view,
        final Drawable drawable) 

Method Source Code

//package com.java2s;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;

public class Main {
    /**//from  w  w  w . j a va 2  s .  c om
     * Hack to fix pre JB MR1 Kudos to @cyrilmottier
     *
     * @param view     view drawable attached too.
     * @param drawable drawable which gets invalidated
     */
    static void fixParallaxBackgroundPreJBMR1(final View view,
            final Drawable drawable) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
            drawable.setCallback(new Drawable.Callback() {
                @Override
                public void invalidateDrawable(Drawable who) {
                    view.setBackgroundDrawable(who);
                }

                @Override
                public void scheduleDrawable(Drawable who, Runnable what,
                        long when) {
                }

                @Override
                public void unscheduleDrawable(Drawable who, Runnable what) {
                }
            });
        }
    }
}

Related

  1. recolor(Resources res, Drawable drawable, int color)