cid#1607171 Data race condition
[LibreOffice.git] / android / source / src / java / org / libreoffice / ui / PageView.java
blob4c3f69562250216ba6d5dd04589fee1f242c5496
1 /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 package org.libreoffice.ui;
5 import org.libreoffice.R;
7 import android.content.Context;
8 import android.graphics.Bitmap;
9 import android.graphics.BitmapFactory;
10 import android.graphics.Canvas;
11 import android.graphics.Paint;
12 import android.graphics.Rect;
13 import android.util.AttributeSet;
14 import android.util.Log;
15 import android.view.View;
17 public class PageView extends View{
18 private Bitmap bmp;
19 private Paint mPaintBlack;
20 private static final String LOGTAG = "PageView";
22 public PageView(Context context ) {
23 super(context);
24 bmp = BitmapFactory.decodeResource(getResources(), R.drawable.dummy_page);
25 initialise();
27 public PageView(Context context, AttributeSet attrs) {
28 super(context, attrs);
29 bmp = BitmapFactory.decodeResource(getResources(), R.drawable.dummy_page);
30 Log.d(LOGTAG, bmp.toString());
31 initialise();
33 public PageView(Context context, AttributeSet attrs, int defStyle) {
34 super(context, attrs, defStyle);
35 bmp = BitmapFactory.decodeResource(getResources(), R.drawable.dummy_page);//load a "page"
36 initialise();
39 private void initialise(){
40 mPaintBlack = new Paint();
41 mPaintBlack.setARGB(255, 0, 0, 0);
42 Log.d(LOGTAG, " Doing some set-up");
45 public void setBitmap(Bitmap bmp){
46 this.bmp = bmp;
49 @Override
50 protected void onDraw(Canvas canvas) {
51 super.onDraw(canvas);
52 Log.d(LOGTAG, "Draw");
53 Log.d(LOGTAG, Integer.toString(bmp.getHeight()));
54 if( bmp != null ){
55 int horizontalMargin = (int) (canvas.getWidth()*0.1);
56 //int verticalMargin = (int) (canvas.getHeight()*0.1);
57 int verticalMargin = horizontalMargin;
58 canvas.drawBitmap(bmp, new Rect(0, 0, bmp.getWidth(), bmp.getHeight()),
59 new Rect(horizontalMargin,verticalMargin,canvas.getWidth()-horizontalMargin,
60 canvas.getHeight()-verticalMargin),
61 mPaintBlack);//
63 if( bmp == null)
64 canvas.drawText(getContext().getString(R.string.bmp_null), 100, 100, new Paint());
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */