Android Open Source - android-placeholder View Compat






From Project

Back to project page android-placeholder.

License

The source code is released under:

Apache License

If you think the Android project android-placeholder listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package se.lightside.placeholder.util;
/* w  ww. java2 s .  c  o m*/
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;

/**
 * Helper class for view compatibility across API-levels
 */
public class ViewCompat {

    /** Do not instantiate */
    private ViewCompat() {}

    /**
     * Set background of a view appropriately for API level without annoying deprecation warnings
     *
     * @param view the view to set the background for
     * @param drawable the drawable to set as background
     */
    public static void setBackground(final View view, final Drawable drawable) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.setBackground(drawable);
        } else {
            setBackgroundPreJellyBean(view, drawable);
        }
    }

    @SuppressWarnings("deprecation")
    private static void setBackgroundPreJellyBean(final View view, final Drawable drawable) {
        view.setBackgroundDrawable(drawable);
    }

}




Java Source Code List

se.lightside.placeholder.ApplicationTest.java
se.lightside.placeholder.PlaceholderBuilder.java
se.lightside.placeholder.graphics.drawable.AbstractPlaceholderDrawable.java
se.lightside.placeholder.graphics.drawable.CrossDrawable.java
se.lightside.placeholder.graphics.drawable.DimensionsDrawable.java
se.lightside.placeholder.graphics.drawable.GridDrawable.java
se.lightside.placeholder.sample.DemoFragment.java
se.lightside.placeholder.sample.DemoHostActivity.java
se.lightside.placeholder.text.method.BlockTransformationMethod.java
se.lightside.placeholder.util.MetricsConverter.java
se.lightside.placeholder.util.ViewCompat.java
se.lightside.placeholder.view.RatioLineOverlay.java
se.lightside.placeholder.view.RatioLine.java
se.lightside.placeholder.widget.BlockedOutTextView.java
se.lightside.placeholder.widget.PlaceholderView.java