package com.unique.yyz.tilelistview.library;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;


/**
 * TODO: document your custom view class.
 */
public class TileListView extends View {
    private String mExampleString; // TODO: use a default from R.string...
    private int mExampleColor = Color.RED; // TODO: use a default from R.color...
    private float mExampleDimension = 0; // TODO: use a default from R.dimen...
    private Drawable mExampleDrawable;

    private TextPaint mTextPaint;
    private float mTextWidth;
    private float mTextHeight;

    public TileListView(Context context) {
        super(context);
        init(null, 0);
    }

    public TileListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(attrs, 0);
    }

    public TileListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(attrs, defStyle);
    }

    private void init(AttributeSet attrs, int defStyle) {
        // Load attributes
        final TypedArray a = getContext().obtainStyledAttributes(
                attrs, R.styleable.TileListView, defStyle, 0);

        mExampleString = a.getString(
                R.styleable.TileListView_exampleString);
        mExampleColor = a.getColor(
                R.styleable.TileListView_exampleColor,
                mExampleColor);
        // Use getDimensionPixelSize or getDimensionPixelOffset when dealing with
        // values that should fall on pixel boundaries.
        mExampleDimension = a.getDimension(
                R.styleable.TileListView_exampleDimension,
                mExampleDimension);

        if (a.hasValue(R.styleable.TileListView_exampleDrawable)) {
            mExampleDrawable = a.getDrawable(
                    R.styleable.TileListView_exampleDrawable);
            mExampleDrawable.setCallback(this);
        }

        a.recycle();

        // Set up a default TextPaint object
        mTextPaint = new TextPaint();
        mTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
        mTextPaint.setTextAlign(Paint.Align.LEFT);

        // Update TextPaint and text measurements from attributes
        invalidateTextPaintAndMeasurements();
    }

    private void invalidateTextPaintAndMeasurements() {
        mTextPaint.setTextSize(mExampleDimension);
        mTextPaint.setColor(mExampleColor);
        mTextWidth = mTextPaint.measureText(mExampleString);

        Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();
        mTextHeight = fontMetrics.bottom;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        // TODO: consider storing these as member variables to reduce
        // allocations per draw cycle.
        int paddingLeft = getPaddingLeft();
        int paddingTop = getPaddingTop();
        int paddingRight = getPaddingRight();
        int paddingBottom = getPaddingBottom();

        int contentWidth = getWidth() - paddingLeft - paddingRight;
        int contentHeight = getHeight() - paddingTop - paddingBottom;

        // Draw the text.
        canvas.drawText(mExampleString,
                paddingLeft + (contentWidth - mTextWidth) / 2,
                paddingTop + (contentHeight + mTextHeight) / 2,
                mTextPaint);

        // Draw the example drawable on top of the text.
        if (mExampleDrawable != null) {
            mExampleDrawable.setBounds(paddingLeft, paddingTop,
                    paddingLeft + contentWidth, paddingTop + contentHeight);
            mExampleDrawable.draw(canvas);
        }
    }

    /**
     * Gets the example string attribute value.
     *
     * @return The example string attribute value.
     */
    public String getExampleString() {
        return mExampleString;
    }

    /**
     * Sets the view's example string attribute value. In the example view, this string
     * is the text to draw.
     *
     * @param exampleString The example string attribute value to use.
     */
    public void setExampleString(String exampleString) {
        mExampleString = exampleString;
        invalidateTextPaintAndMeasurements();
    }

    /**
     * Gets the example color attribute value.
     *
     * @return The example color attribute value.
     */
    public int getExampleColor() {
        return mExampleColor;
    }

    /**
     * Sets the view's example color attribute value. In the example view, this color
     * is the font color.
     *
     * @param exampleColor The example color attribute value to use.
     */
    public void setExampleColor(int exampleColor) {
        mExampleColor = exampleColor;
        invalidateTextPaintAndMeasurements();
    }

    /**
     * Gets the example dimension attribute value.
     *
     * @return The example dimension attribute value.
     */
    public float getExampleDimension() {
        return mExampleDimension;
    }

    /**
     * Sets the view's example dimension attribute value. In the example view, this dimension
     * is the font size.
     *
     * @param exampleDimension The example dimension attribute value to use.
     */
    public void setExampleDimension(float exampleDimension) {
        mExampleDimension = exampleDimension;
        invalidateTextPaintAndMeasurements();
    }

    /**
     * Gets the example drawable attribute value.
     *
     * @return The example drawable attribute value.
     */
    public Drawable getExampleDrawable() {
        return mExampleDrawable;
    }

    /**
     * Sets the view's example drawable attribute value. In the example view, this drawable is
     * drawn above the text.
     *
     * @param exampleDrawable The example drawable attribute value to use.
     */
    public void setExampleDrawable(Drawable exampleDrawable) {
        mExampleDrawable = exampleDrawable;
    }
}

@@ -338,16 +338,48 @@
 w.View;%0A
+import android.widget.ListView;%0A
 %0A%0A/**%0A *
@@ -460,386 +460,18 @@
 nds 
+List
 View %7B
-%0A    private String mExampleString; // TODO: use a default from R.string...%0A    private int mExampleColor = Color.RED; // TODO: use a default from R.color...%0A    private float mExampleDimension = 0; // TODO: use a default from R.dimen...%0A    private Drawable mExampleDrawable;%0A%0A    private TextPaint mTextPaint;%0A    private float mTextWidth;%0A    private float mTextHeight;
 %0A%0A  
@@ -539,31 +539,8 @@
 t);%0A
-        init(null, 0);%0A
     
@@ -640,32 +640,8 @@
 s);%0A
-        init(attrs, 0);%0A
     
@@ -769,4916 +769,10 @@
     
-    init(attrs, defStyle);%0A    %7D%0A%0A    private void init(AttributeSet attrs, int defStyle) %7B%0A        // Load attributes%0A        final TypedArray a = getContext().obtainStyledAttributes(%0A                attrs, R.styleable.TileListView, defStyle, 0);%0A%0A        mExampleString = a.getString(%0A                R.styleable.TileListView_exampleString);%0A        mExampleColor = a.getColor(%0A                R.styleable.TileListView_exampleColor,%0A                mExampleColor);%0A        // Use getDimensionPixelSize or getDimensionPixelOffset when dealing with%0A        // values that should fall on pixel boundaries.%0A        mExampleDimension = a.getDimension(%0A                R.styleable.TileListView_exampleDimension,%0A                mExampleDimension);%0A%0A        if (a.hasValue(R.styleable.TileListView_exampleDrawable)) %7B%0A            mExampleDrawable = a.getDrawable(%0A                    R.styleable.TileListView_exampleDrawable);%0A            mExampleDrawable.setCallback(this);%0A        %7D%0A%0A        a.recycle();%0A%0A        // Set up a default TextPaint object%0A        mTextPaint = new TextPaint();%0A        mTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);%0A        mTextPaint.setTextAlign(Paint.Align.LEFT);%0A%0A        // Update TextPaint and text measurements from attributes%0A        invalidateTextPaintAndMeasurements();%0A    %7D%0A%0A    private void invalidateTextPaintAndMeasurements() %7B%0A        mTextPaint.setTextSize(mExampleDimension);%0A        mTextPaint.setColor(mExampleColor);%0A        mTextWidth = mTextPaint.measureText(mExampleString);%0A%0A        Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();%0A        mTextHeight = fontMetrics.bottom;%0A    %7D%0A%0A    @Override%0A    protected void onDraw(Canvas canvas) %7B%0A        super.onDraw(canvas);%0A%0A        // TODO: consider storing these as member variables to reduce%0A        // allocations per draw cycle.%0A        int paddingLeft = getPaddingLeft();%0A        int paddingTop = getPaddingTop();%0A        int paddingRight = getPaddingRight();%0A        int paddingBottom = getPaddingBottom();%0A%0A        int contentWidth = getWidth() - paddingLeft - paddingRight;%0A        int contentHeight = getHeight() - paddingTop - paddingBottom;%0A%0A        // Draw the text.%0A        canvas.drawText(mExampleString,%0A                paddingLeft + (contentWidth - mTextWidth) / 2,%0A                paddingTop + (contentHeight + mTextHeight) / 2,%0A                mTextPaint);%0A%0A        // Draw the example drawable on top of the text.%0A        if (mExampleDrawable != null) %7B%0A            mExampleDrawable.setBounds(paddingLeft, paddingTop,%0A                    paddingLeft + contentWidth, paddingTop + contentHeight);%0A            mExampleDrawable.draw(canvas);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Gets the example string attribute value.%0A     *%0A     * @return The example string attribute value.%0A     */%0A    public String getExampleString() %7B%0A        return mExampleString;%0A    %7D%0A%0A    /**%0A     * Sets the view's example string attribute value. In the example view, this string%0A     * is the text to draw.%0A     *%0A     * @param exampleString The example string attribute value to use.%0A     */%0A    public void setExampleString(String exampleString) %7B%0A        mExampleString = exampleString;%0A        invalidateTextPaintAndMeasurements();%0A    %7D%0A%0A    /**%0A     * Gets the example color attribute value.%0A     *%0A     * @return The example color attribute value.%0A     */%0A    public int getExampleColor() %7B%0A        return mExampleColor;%0A    %7D%0A%0A    /**%0A     * Sets the view's example color attribute value. In the example view, this color%0A     * is the font color.%0A     *%0A     * @param exampleColor The example color attribute value to use.%0A     */%0A    public void setExampleColor(int exampleColor) %7B%0A        mExampleColor = exampleColor;%0A        invalidateTextPaintAndMeasurements();%0A    %7D%0A%0A    /**%0A     * Gets the example dimension attribute value.%0A     *%0A     * @return The example dimension attribute value.%0A     */%0A    public float getExampleDimension() %7B%0A        return mExampleDimension;%0A    %7D%0A%0A    /**%0A     * Sets the view's example dimension attribute value. In the example view, this dimension%0A     * is the font size.%0A     *%0A     * @param exampleDimension The example dimension attribute value to use.%0A     */%0A    public void setExampleDimension(float exampleDimension) %7B%0A        mExampleDimension = exampleDimension;%0A        invalidateTextPaintAndMeasurements();%0A    %7D%0A%0A    /**%0A     * Gets the example drawable attribute value.%0A     *%0A     * @return The example drawable attribute value.%0A     */%0A    public Drawable getExampleDrawable() %7B%0A        return mExampleDrawable;%0A    %7D%0A%0A    /**%0A     * Sets the view's example drawable attribute value. In the example view, this drawable is%0A     * drawn above the text.%0A     *%0A     * @param exampleDrawable The example drawable attribute value to use.%0A     */%0A    public void setExampleDrawable(Drawable exampleDrawable) %7B%0A        mExampleDrawable = exampleDrawable;%0A    %7D
+%7D%0A%0A
 %0A%7D%0A

remove useless thing from library