Android Open Source - android-placeholder Block Transformation Method






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.text.method;
/*from ww w  .j  av a 2  s . co  m*/
import android.text.method.ReplacementTransformationMethod;
import android.view.Gravity;
import android.widget.TextView;

/**
*
*/
public class BlockTransformationMethod extends ReplacementTransformationMethod {

    public static void asTransformationFor(TextView tv) {
        tv.setTransformationMethod(new BlockTransformationMethod());
        // For some reason the unicode blocks behave like ltr-text
        // so we explicitly set gravity here to avoid weirdness
        tv.setGravity(Gravity.LEFT);
    }

    private static final char BLOCK_FULL = '\u2588';
    private static final char BLOCK_THREE_QUARTERS = '\u2586';

    private static char[] mOriginal = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
    private static char[] mReplacement;
    static {
        int l = mOriginal.length;
        mReplacement = new char[mOriginal.length];
        for (int i=0; i<l;i++) {
            mReplacement[i] = BLOCK_THREE_QUARTERS;
        }
    }

    @Override
    protected char[] getOriginal() {
        return mOriginal;
    }

    @Override
    protected char[] getReplacement() {
        return mReplacement;
    }
}




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