package com.ktereyp.rsync.ui;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.view.View;

import com.ktereyp.rsync.R;

public class HideView extends View {
    private Paint paint;
    private Bitmap mBitmap;
    private int left;
    private int top;
    private int width;
    private int height;

    public HideView(Context context) {
        this(context, null);
    }

    public HideView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public HideView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setStyle(Style.FILL);
        mBitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.pause)).getBitmap();
        width = mBitmap.getWidth();
        height = mBitmap.getHeight();
    }

    @Override
    public void onSizeChanged(int w, int h, int oldw, int oldh) {
        left = w / 2 - width / 2;
        top = h / 2 - height / 2;
    }

    @Override
    public void onDraw(Canvas canvas) {
        canvas.drawBitmap(mBitmap, left, top, paint);
    }

}
