package com.xixun.xixunplayer;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.TextPaint;
import android.view.View;

public class BackView extends View {

    Bitmap cosImg;
    Rect rect = new Rect();
    Paint[] paints = {new TextPaint(), new TextPaint()};
    String[] txts = {"0.00", ""};
    int size2 = Util.screenHeight/2;

    public BackView(Context context) {
        super(context);
        paints[0].setTextAlign(Paint.Align.RIGHT);
        paints[1].setTextAlign(Paint.Align.RIGHT);
        for(int i=0; i<2; i++) {
            paints[i].setTextSize(size2);
            paints[i].setColor(0xffffffff);
        }
        paints[0].setLinearText(true);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        rect.right = Util.screenWidth;
        rect.bottom = Util.screenHeight;
        canvas.clipRect(rect);
        if(cosImg!=null) canvas.drawBitmap(cosImg, null, rect, null);
        canvas.drawText(txts[0], Util.screenWidth-6, -paints[0].ascent(), paints[0]);
        canvas.drawText(txts[1], Util.screenWidth-6, (Util.screenHeight+paints[0].getTextSize()-paints[1].ascent()-paints[1].descent())/2, paints[1]);
    }
}
