Commit f454768c authored by Thomas Krex's avatar Thomas Krex

Revert "new try with the surfaceView"

This reverts commit 065dc09f.
parent 065dc09f
......@@ -14,7 +14,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
<SurfaceView
<ImageView
android:id="@+id/playerView_fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
......
......@@ -12,12 +12,10 @@ 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;
......@@ -48,7 +46,7 @@ public class PlayerActivity extends SherlockActivity implements
static final int LAYOUT_MODE_EXTENDED = 1;
public String fileName;
public String filePath;
public SurfaceView surfaceView;
public ImageView imgV;
private ViewSwitcher switcher;
private ScrollView scrollView;
private Recording recording;
......@@ -66,8 +64,8 @@ public class PlayerActivity extends SherlockActivity implements
switcher = (ViewSwitcher) findViewById(R.id.viewSwitcher);
// default fullscreen
surfaceView= (SurfaceView) findViewById(R.id.playerView_fullscreen);
imgV = (ImageView) findViewById(R.id.playerView_fullscreen);
fileName = getIntent().getStringExtra(DownloadService.FILE_NAME);
setTitle(fileName);
filePath = getIntent().getStringExtra(DownloadService.FILE_PATH);
......@@ -106,7 +104,7 @@ public class PlayerActivity extends SherlockActivity implements
protected Void doInBackground(Void... params) {
try {
recording = new Recording(getApplicationContext(), tttFile,
audioPlayer,surfaceView.getHolder(), scrollView);
audioPlayer, imgV, scrollView);
/*
* create listeners for prev/next buttons of mediaController
......@@ -135,7 +133,7 @@ public class PlayerActivity extends SherlockActivity implements
audioController.setPrevNextListeners(nextListener,
prevListener);
audioController.setAnchorView(surfaceView);
audioController.setAnchorView(imgV);
} catch (IOException e) {
// TODO Auto-generated catch block
......@@ -336,8 +334,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);
......@@ -345,8 +343,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,8 +13,6 @@ 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;
/**
......@@ -28,7 +26,7 @@ import android.widget.ImageView;
public class GraphicsContext implements MessageConsumer {
private final BitmapContainer bitmapContainer;
private SurfaceHolder holder;;
private ImageView imgView;
private boolean refreshEnabled = false;
private final MessageProducer producer;
......@@ -39,8 +37,8 @@ public class GraphicsContext implements MessageConsumer {
private final byte[] hextile_fg_encoded;
private final int[] pixels;
public GraphicsContext(SurfaceHolder holder, Recording record) {
this.holder=holder;
public GraphicsContext(ImageView imgV, Recording record) {
setImageView(imgV);
this.producer = record;
this.recording = record;
producer.addMessageConsumer(this);
......@@ -50,7 +48,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];
......@@ -65,6 +63,9 @@ public class GraphicsContext implements MessageConsumer {
return refreshEnabled;
}
public void setImageView(ImageView imgV) {
this.imgView = imgV;
}
public int[] getPixels() {
return this.pixels;
......@@ -101,22 +102,29 @@ public class GraphicsContext implements MessageConsumer {
*/
public void updateView(boolean setBitmap) {
Canvas canvas = holder.lockCanvas();
if (canvas != null) {
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.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() {
holder.unlockCanvasAndPost(canvas);
@Override
public void run() {
// assign bitmap to imageview in UI-Thread
imgView.setImageBitmap(bitmap);
}
});
else
// invalidate ImageView in UI-Thread
imgView.postInvalidate();
}
}
......@@ -301,14 +309,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,8 +38,6 @@ 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;
......@@ -81,7 +79,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
}
public Recording(Context context, File tttFile, MediaPlayer audioPlayer,
SurfaceHolder holder, ScrollView scrollView) throws IOException {
ImageView imgV, ScrollView scrollView) throws IOException {
this.tttFile = tttFile;
// read
messages = new Messages(this);
......@@ -92,7 +90,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// read messages + extensions
read(this.tttFile);
graphicsContext = new GraphicsContext(holder, this);
graphicsContext = new GraphicsContext(imgV, 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