Commit 065dc09f authored by Thomas Krex's avatar Thomas Krex

new try with the surfaceView

parent 2d18810f
......@@ -14,7 +14,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
<SurfaceView
android:id="@+id/playerView_fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
......
......@@ -12,10 +12,12 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.MediaController.MediaPlayerControl;
import android.widget.ScrollView;
......@@ -46,7 +48,7 @@ public class PlayerActivity extends SherlockActivity implements
static final int LAYOUT_MODE_EXTENDED = 1;
public String fileName;
public String filePath;
public ImageView imgV;
public SurfaceView surfaceView;
private ViewSwitcher switcher;
private ScrollView scrollView;
private Recording recording;
......@@ -64,8 +66,8 @@ public class PlayerActivity extends SherlockActivity implements
switcher = (ViewSwitcher) findViewById(R.id.viewSwitcher);
// default fullscreen
imgV = (ImageView) findViewById(R.id.playerView_fullscreen);
surfaceView= (SurfaceView) findViewById(R.id.playerView_fullscreen);
fileName = getIntent().getStringExtra(DownloadService.FILE_NAME);
setTitle(fileName);
filePath = getIntent().getStringExtra(DownloadService.FILE_PATH);
......@@ -104,7 +106,7 @@ public class PlayerActivity extends SherlockActivity implements
protected Void doInBackground(Void... params) {
try {
recording = new Recording(getApplicationContext(), tttFile,
audioPlayer, imgV, scrollView);
audioPlayer,surfaceView.getHolder(), scrollView);
/*
* create listeners for prev/next buttons of mediaController
......@@ -133,7 +135,7 @@ public class PlayerActivity extends SherlockActivity implements
audioController.setPrevNextListeners(nextListener,
prevListener);
audioController.setAnchorView(imgV);
audioController.setAnchorView(surfaceView);
} catch (IOException e) {
// TODO Auto-generated catch block
......@@ -334,8 +336,8 @@ public class PlayerActivity extends SherlockActivity implements
// switch to fullscreen
if (mode == LAYOUT_MODE_FULL) {
imgV = (ImageView) findViewById(R.id.playerView_fullscreen);
recording.graphicsContext().setImageView(imgV);
// imgV = (ImageView) findViewById(R.id.playerView_fullscreen);
// recording.graphicsContext().setImageView(imgV);
recording.graphicsContext().updateView(true);
switcher.setDisplayedChild(LAYOUT_MODE_FULL);
......@@ -343,8 +345,8 @@ public class PlayerActivity extends SherlockActivity implements
// switch to extended View
if (mode == LAYOUT_MODE_EXTENDED) {
imgV = (ImageView) findViewById(R.id.playerView_extended);
recording.graphicsContext().setImageView(imgV);
// imgV = (ImageView) findViewById(R.id.playerView_extended);
// recording.graphicsContext().setImageView(imgV);
recording.graphicsContext().updateView(true);
switcher.setDisplayedChild(LAYOUT_MODE_EXTENDED);
scrollView.scrollTo(0, recording.getIndex().scrollPos);
......
......@@ -13,6 +13,8 @@ import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.ImageView;
/**
......@@ -26,7 +28,7 @@ import android.widget.ImageView;
public class GraphicsContext implements MessageConsumer {
private final BitmapContainer bitmapContainer;
private ImageView imgView;
private SurfaceHolder holder;;
private boolean refreshEnabled = false;
private final MessageProducer producer;
......@@ -37,8 +39,8 @@ public class GraphicsContext implements MessageConsumer {
private final byte[] hextile_fg_encoded;
private final int[] pixels;
public GraphicsContext(ImageView imgV, Recording record) {
setImageView(imgV);
public GraphicsContext(SurfaceHolder holder, Recording record) {
this.holder=holder;
this.producer = record;
this.recording = record;
producer.addMessageConsumer(this);
......@@ -48,7 +50,7 @@ public class GraphicsContext implements MessageConsumer {
prefs.framebufferWidth, prefs.framebufferHeight,
Config.ARGB_4444));
this.pixels = bitmapContainer.getPixels();
this.pixels = bitmapContainer.getPixels();
hextile_bg_encoded = new byte[prefs.bytesPerPixel];
hextile_fg_encoded = new byte[prefs.bytesPerPixel];
......@@ -63,9 +65,6 @@ public class GraphicsContext implements MessageConsumer {
return refreshEnabled;
}
public void setImageView(ImageView imgV) {
this.imgView = imgV;
}
public int[] getPixels() {
return this.pixels;
......@@ -102,29 +101,22 @@ public class GraphicsContext implements MessageConsumer {
*/
public void updateView(boolean setBitmap) {
if (refreshEnabled) {
// get Bitmap without Annotations or highlighted search results
final Bitmap bitmap = bitmapContainer.getBitmap();
// define canvas, which draws in the bitmap
Canvas canvas = new Canvas(bitmap);
Canvas canvas = holder.lockCanvas();
if (canvas != null) {
canvas.drawBitmap(pixels, 0,
recording.getProtocolPreferences().framebufferWidth, 0, 0,
recording.getProtocolPreferences().framebufferWidth,
recording.getProtocolPreferences().framebufferHeight,
false, null);
if (isWhiteboardEnabled())
paintWhiteboard(canvas);
paintAnnotations(canvas);
recording.highlightSearchResults(canvas);
if (setBitmap)
imgView.post(new Runnable() {
@Override
public void run() {
// assign bitmap to imageview in UI-Thread
imgView.setImageBitmap(bitmap);
}
});
else
// invalidate ImageView in UI-Thread
imgView.postInvalidate();
holder.unlockCanvasAndPost(canvas);
}
}
......@@ -309,14 +301,14 @@ public class GraphicsContext implements MessageConsumer {
}
public void setBitmap() {
imgView.post(new Runnable() {
@Override
public void run() {
imgView.setImageBitmap(bitmapContainer.getBitmap());
}
});
}
// public void setBitmap() {
// imgView.post(new Runnable() {
//
// @Override
// public void run() {
// imgView.setImageBitmap(bitmapContainer.getBitmap());
//
// }
// });
// }
}
\ No newline at end of file
......@@ -38,6 +38,8 @@ import tttclient.messages.MessageProducerAdapter;
import android.content.Context;
import android.graphics.Canvas;
import android.media.MediaPlayer;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.ImageView;
import android.widget.ScrollView;
......@@ -79,7 +81,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
}
public Recording(Context context, File tttFile, MediaPlayer audioPlayer,
ImageView imgV, ScrollView scrollView) throws IOException {
SurfaceHolder holder, ScrollView scrollView) throws IOException {
this.tttFile = tttFile;
// read
messages = new Messages(this);
......@@ -90,7 +92,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// read messages + extensions
read(this.tttFile);
graphicsContext = new GraphicsContext(imgV, this);
graphicsContext = new GraphicsContext(holder, this);
// compute Index if not available in extensions
if (!index.isValid())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment