Back to project page feeligo_android_sdk.
The source code is released under:
MIT License
If you think the Android project feeligo_android_sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package fr.baloomba.feeligo.helper; //from ww w . ja v a2 s . c o m import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; import android.os.Build; import android.support.v7.app.ActionBarActivity; public class ActionBarHelper { public static Drawable setColor(ActionBarActivity activity, int colorRes, Drawable.Callback drawableCallback) { Drawable colorDrawable = new ColorDrawable(colorRes); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) colorDrawable.setCallback(drawableCallback); else activity.getSupportActionBar().setBackgroundDrawable(colorDrawable); return colorDrawable; } public static Drawable setColor(ActionBarActivity activity, int colorRes, Drawable oldBackground, Drawable.Callback drawableCallback) { Drawable colorDrawable = new ColorDrawable(activity.getResources().getColor(colorRes)); if (oldBackground == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { colorDrawable.setCallback(drawableCallback); } else { activity.getSupportActionBar().setBackgroundDrawable(colorDrawable); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[]{oldBackground, colorDrawable}); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { activity.getSupportActionBar().setBackgroundDrawable(td); } td.startTransition(200); } return colorDrawable; } }