Commit 00b9fb47 by Thomas Krex

scrollview scrollt zum aktuellen index entry

-trick ist die position des parent abzufragen
parent 5c8642b3
......@@ -95,8 +95,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
protected Void doInBackground(Void... params) {
try {
recording = new Recording(getApplicationContext(), tttFile,
audioPlayer, imgV, surfaceView, scrollView,
screenWidth, screenHeight);
audioPlayer, imgV, scrollView);
OnClickListener prevListener = new OnClickListener() {
......@@ -307,21 +306,21 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
}
void switchSurface(int index) {
if (index == 0) {
surfaceView.setVisibility(View.INVISIBLE);
surfaceView = (SurfaceView) findViewById(R.id.playerView_fullscreen);
recording.graphicsContext().setSurfaceView(surfaceView);
// recording.focusCurrentIndexEntry(recording.getLastIndexFired() -
// 1);
switcher.setDisplayedChild(0);
}
if (index == 1) {
surfaceView.setVisibility(View.INVISIBLE);
surfaceView = (SurfaceView) findViewById(R.id.playerView_extended);
recording.graphicsContext().setSurfaceView(surfaceView);
recording.graphicsContext().updateOverlay();
}
}
// void switchSurface(int index) {
// if (index == 0) {
// surfaceView.setVisibility(View.INVISIBLE);
// surfaceView = (SurfaceView) findViewById(R.id.playerView_fullscreen);
// recording.graphicsContext().setSurfaceView(surfaceView);
// // recording.focusCurrentIndexEntry(recording.getLastIndexFired() -
// // 1);
// switcher.setDisplayedChild(0);
// }
// if (index == 1) {
// surfaceView.setVisibility(View.INVISIBLE);
// surfaceView = (SurfaceView) findViewById(R.id.playerView_extended);
// recording.graphicsContext().setSurfaceView(surfaceView);
// recording.graphicsContext().updateOverlay();
// }
// }
}
......@@ -20,9 +20,8 @@ import android.media.Image;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.ImageView;
import android.widget.LinearLayout;
@SuppressLint("NewApi")
public class GraphicsContext implements MessageConsumer {
......@@ -39,16 +38,12 @@ public class GraphicsContext implements MessageConsumer {
private final BitmapContainer bitmapContainer;
private final Canvas canvas;
private ImageView imgView;
private SurfaceView overlay;
private SurfaceHolder sHolder;
private boolean refreshEnabled = false;
private final MessageProducer producer;
private final ProtocolPreferences prefs;
private final Recording recording;
private final double scaleFactorX;
private final double scaleFactorY;
private final int screenWidth;
private final int screenHeight;
private final byte[] hextile_bg_encoded;
private final byte[] hextile_fg_encoded;
private final int[] pixels;
......@@ -57,25 +52,13 @@ public class GraphicsContext implements MessageConsumer {
return recording;
}
public GraphicsContext(ImageView imgV, SurfaceView surfaceView,
Recording record, int width, int height) {
public GraphicsContext(ImageView imgV, Recording record) {
setImageView(imgV);
this.producer = record;
this.recording = record;
producer.addMessageConsumer(this);
this.prefs = record.getProtocolPreferences();
// // init SurfaceView
// setSurfaceView(surfaceView);
//
// compute scale factor
this.screenWidth = width;
this.screenHeight = height;
scaleFactorX = width / prefs.framebufferWidth;
scaleFactorY = height / prefs.framebufferHeight;
this.bitmapContainer = new BitmapContainer(Bitmap.createBitmap(
prefs.framebufferWidth, prefs.framebufferHeight,
Config.ARGB_8888));
......@@ -96,9 +79,6 @@ public class GraphicsContext implements MessageConsumer {
// Gets the image task from the incoming Message object.
Bitmap bitmap = (Bitmap) inputMessage.obj;
// TODO
// updateOverlay();
paintAnnotations(canvas);
recording.highlightSearchResults(canvas);
......@@ -113,19 +93,23 @@ public class GraphicsContext implements MessageConsumer {
// Gets the image task from the incoming Message object.
int indexNumber = inputMessage.arg1;
int color = inputMessage.arg2;
recording.getIndex().get(indexNumber - 1)
.setBackgroundColor(color);
IndexEntry entry = recording.getIndex().get(indexNumber - 1);
entry.setBackgroundColor(color);
LinearLayout parent = (LinearLayout) entry.getParent();
recording.getIndexViewer().scrollTo(0,
parent.getTop() - parent.getHeight() / 2);
}
};
}
public void setSurfaceView(SurfaceView surfaceView) {
this.overlay = surfaceView;
overlay.setZOrderOnTop(true);
sHolder = overlay.getHolder();
sHolder.setFixedSize(prefs.framebufferWidth, prefs.framebufferHeight);
}
// public void setSurfaceView(SurfaceView surfaceView) {
// this.overlay = surfaceView;
// overlay.setZOrderOnTop(true);
// sHolder = overlay.getHolder();
// sHolder.setFixedSize(prefs.framebufferWidth, prefs.framebufferHeight);
//
// }
public static void fillRect(int[] array, Rect r, int color, int screenWidth) {
int x = r.left;
......@@ -166,17 +150,17 @@ public class GraphicsContext implements MessageConsumer {
}
}
public void updateOverlay() {
Canvas canvas = sHolder.lockCanvas();
if (canvas != null) {
canvas.drawBitmap(bitmapContainer.getBimap(), 0, 0, null);
paintAnnotations(canvas);
recording.highlightSearchResults(canvas);
sHolder.unlockCanvasAndPost(canvas);
}
}
// public void updateOverlay() {
//
// Canvas canvas = sHolder.lockCanvas();
// if (canvas != null) {
// canvas.drawBitmap(bitmapContainer.getBimap(), 0, 0, null);
// paintAnnotations(canvas);
// recording.highlightSearchResults(canvas);
// sHolder.unlockCanvasAndPost(canvas);
// }
//
// }
public void enableRefresh(boolean refresh) {
this.refreshEnabled = refresh;
......
......@@ -43,7 +43,6 @@ import android.graphics.Color;
import android.media.MediaPlayer;
import android.util.Log;
import android.view.Gravity;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
......@@ -60,7 +59,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
private final Index index;
private final Context context;
private ScrollView indexViewer;
private final ScrollView indexViewer;
private File tttFile;
public Messages getMessages() {
......@@ -84,8 +83,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
}
public Recording(Context context, File tttFile, MediaPlayer audioPlayer,
ImageView imgV, SurfaceView surfaceView, ScrollView scrollView,
int screenWidth, int screenHeight) throws IOException {
ImageView imgV, ScrollView scrollView) throws IOException {
// read
this.context = context;
this.indexViewer = scrollView;
......@@ -98,8 +96,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// read messages + extensions
read(tttFile);
graphicsContext = new GraphicsContext(imgV, surfaceView, this,
screenWidth, screenHeight);
graphicsContext = new GraphicsContext(imgV, this);
if (!index.isValid())
index.computeIndex();
......@@ -113,26 +110,25 @@ public class Recording extends MessageProducerAdapter implements Runnable {
int audio_duration = audioPlayer.getDuration();
int max_duration = Math.max(audio_duration, desktop_duration);
// int desktop_diff = desktop_duration - max_duration;
// int audio_diff = audio_duration - max_duration;
// calculate replay factor for badly synced audio recordings (audio
// too short)
desktop_replay_factor = 1;
if (audio_duration > 0) {
desktop_replay_factor = (double) audio_duration / max_duration;
// audioPlayer.set(1 / desktop_replay_factor);
}
// messages.checkDuration(audioPlayer.getDuration());
}
graphicsContext.enableRefresh(true);
setTime(0, true);
}
public void setIndexViewer(ScrollView scrollView) {
this.indexViewer = scrollView;
// public void setIndexViewer(ScrollView scrollView) {
// this.indexViewer = scrollView;
// }
public ScrollView getIndexViewer() {
return indexViewer;
}
void read(File file) throws IOException {
......
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 sign in to comment