Android Open Source - android-placeholder Abstract Placeholder Drawable






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.graphics.drawable;
/*  w ww.  jav a  2 s .c om*/
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;

/**
 * Abstract baseclass for placeholder drawables
 */
public abstract class AbstractPlaceholderDrawable extends Drawable {

    private PlaceHolderState mPlaceHolderState;

    AbstractPlaceholderDrawable() {
        this((PlaceHolderState)null);
    }

    AbstractPlaceholderDrawable(PlaceHolderState orig) {
        mPlaceHolderState = new PlaceHolderState(orig);
    }


    @Override public void setAlpha(int alpha) {
        mPlaceHolderState.mAlpha = alpha;
    }

    @Override
    public void setColorFilter(ColorFilter cf) {
        mPlaceHolderState.mPaint.setColorFilter(cf);
        invalidateSelf();
    }

    public Paint getPaint() {
        return mPlaceHolderState.mPaint;
    }

    public void setPaint(Paint p) {
        mPlaceHolderState.mPaint.set(p);
    }

    @Override
    public int getOpacity() { return PixelFormat.UNKNOWN; }

    /**
     * Common placeholder states
     */
    static class PlaceHolderState extends ConstantState {
        int mChangingConfigurations;
        Paint mPaint;
        int mAlpha;

        PlaceHolderState(PlaceHolderState orig) {
            if (orig != null) {
                mPaint = orig.mPaint;
                mAlpha = orig.mAlpha;
            } else {
                mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
            }

        }

        @Override
        public Drawable newDrawable() {
            return null;
        }

        @Override
        public int getChangingConfigurations() {
            return mChangingConfigurations;
        }
    }
}




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