Commit 04a303bd authored by Thomas Krex's avatar Thomas Krex

next und prev implementiert

parent 031e923c
......@@ -6,7 +6,7 @@
<ScrollView
android:id="@+id/indexScrollView"
android:layout_width="100dp"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_weight="3" >
</ScrollView>
......
......@@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import tttclient.services.DownloadService;
import tttclient.ttt.IndexEntry;
import tttclient.ttt.Recording;
import android.app.Activity;
import android.graphics.Color;
......@@ -13,6 +14,8 @@ import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.MediaController;
......@@ -65,41 +68,29 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
audioController = new MediaController(this);
audioController.setMediaPlayer(this);
OnClickListener prevListener = new OnClickListener() {
@Override
public void onClick(View v) {
recording.previous();
}
};
OnClickListener nextListener = new OnClickListener() {
@Override
public void onClick(View v) {
recording.next();
}
};
audioController.setPrevNextListeners(nextListener, prevListener);
audioController.setAnchorView(imgV);
// final int topContainerId1 = getResources().getIdentifier(
// "mediacontroller_progress", "id", "android");
// final SeekBar seekbar = (SeekBar) audioController
// .findViewById(topContainerId1);
//
// seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
//
// @Override
// public void onStopTrackingTouch(SeekBar seekBar) {
// recording.adjusting = false;
// recording.sliderStateChanged(seekbar.getProgress());
//
// }
//
// @Override
// public void onStartTrackingTouch(SeekBar seekBar) {
// recording.adjusting = true;
//
// }
//
// @Override
// public void onProgressChanged(SeekBar seekBar, int progress,
// boolean fromUser) {
// seekTo(progress);
//
// }
// });
LinearLayout layout = new LinearLayout(getApplicationContext());
layout.setBackgroundColor(Color.MAGENTA);
//
Log.d("Index", " length " + recording.getIndex().size());
layout.addView(recording.getIndex().get(0));
scrollView.addView(layout);
initScrollView();
}
@Override
......@@ -117,6 +108,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
public boolean canSeekForward() {
// TODO Auto-generated method stub
return false;
}
@Override
......@@ -182,4 +174,21 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
recording = null;
audioPlayer.release();
}
public void initScrollView() {
LinearLayout layout = new LinearLayout(getApplicationContext());
layout.setBackgroundColor(Color.MAGENTA);
//
int length = recording.getIndex().size();
for (int i = 0; i < length; i++) {
IndexEntry entry = recording.getIndex().get(i);
layout.addView(entry);
System.out.println("Index " + i + " has thumbnail "
+ entry.hasThumbnail());
}
scrollView.addView(layout);
}
}
......@@ -66,6 +66,7 @@ public class Index {
// must contain at least one entry
// TODO: needed?
index.add(new IndexEntry(context, this));
}
public void close() {
......@@ -325,18 +326,8 @@ public class Index {
// buffer.write(searchableText.getBytes());
// }
//
// // thumbnail
// writeThumbnail(indexEntry, buffer);
// }
// buffer.flush();
//
// // write length of extension
// out.writeInt(byteArrayOutputStream.size());
// // write extension
// out.write(byteArrayOutputStream.toByteArray());
// } // else no index available
// }
// TODO bufferedImage in Bitmap transformieren
// read one image representing thumbnail
private void readThumbnail(DataInputStream in) throws IOException {
int image_size = in.readInt();
......@@ -780,7 +771,7 @@ public class Index {
// .fireIndexChangedEvent(nowPlayingIndex_startingAtZero + 1);
// update search result highligting
recording.graphicsContext().refresh();
// recording.graphicsContext().refresh();
break;
}
}
......
......@@ -15,6 +15,8 @@ public class IndexEntry extends ImageButton {
private final String searchbase_of_page;
private ArrayList<Annotation> annotations;
private boolean hasThumbnail = false;
// private ArrayList<SearchBaseEntry> words;
// private Index index;
......@@ -56,6 +58,7 @@ public class IndexEntry extends ImageButton {
this.thumbnail = thumbnail;
// set src of ImageButton
this.setImageBitmap(thumbnail);
hasThumbnail = true;
}
......@@ -63,4 +66,8 @@ public class IndexEntry extends ImageButton {
this.annotations = new ArrayList<Annotation>(annotations);
}
public boolean hasThumbnail() {
return hasThumbnail;
}
}
......@@ -120,6 +120,8 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// messages.checkDuration(audioPlayer.getDuration());
}
setTime(0, true);
}
void read(File file) throws IOException {
......@@ -429,7 +431,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
deliverMessage(message);
// update index viewer
// index.updateRunningIndex(message.getTimestamp());
index.updateRunningIndex(message.getTimestamp());
// increase message counter
next_message++;
......@@ -497,15 +499,17 @@ public class Recording extends MessageProducerAdapter implements Runnable {
}
//
// // set playback to next index
// synchronized public void next() {
// setTime(index.getNextIndex().getTimestamp());
// }
// set playback to next index
synchronized public void next() {
setTime(index.getNextIndex().getTimestamp(), true);
}
//
// // set playback to previous index
// synchronized public void previous() {
// setTime(index.getPreviousIndex().getTimestamp());
// }
// set playback to previous index
synchronized public void previous() {
setTime(index.getPreviousIndex().getTimestamp(), true);
}
//
public int timeset;
......@@ -531,11 +535,12 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// paint offscreen
messages.setTime_full_frame_check(time);
if (refresh) {
setAudioPlayerTime(time);
graphicsContext.refresh();
}
setAdjusting(false);
//
// index.setCorrespondingIndex(time);
index.setCorrespondingIndex(time);
// update display
// graphicsContext.enableRefresh(refreshStatus);
......@@ -595,38 +600,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// ///////////////////////////////////////////////////////////////////////
// event handling
// ///////////////////////////////////////////////////////////////////////
//
// // action commands
// public static final String PLAY = "play";
// public static final String PAUSE = "pause";
// public static final String STOP = "stop";
// public static final String NEXT = "next";
// public static final String PREVIOUS = "previous";
// public static final String INDEX = "index";
// public static final String FULLSCREEN = "fullscreen";
// public static final String SEARCH = "search";
//
// // receive action command
// public void actionPerformed(ActionEvent event) {
// String command = event.getActionCommand();
//
// if (command.equals(PLAY))
// play();
// else if (command.equals(PAUSE))
// pause();
// else if (command.equals(STOP))
// stop();
// else if (command.equals(NEXT))
// next();
// else if (command.equals(PREVIOUS))
// previous();
// else if (command.equals(INDEX))
// ;
// else if (command.equals(FULLSCREEN))
// ;
// else
// System.out.println("unknown player command: " + command);
// }
//
// set playback time according to slider movement
// performs visible scrolling while adjusting
......@@ -635,7 +609,6 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// bitmap is set and display is updated
setTime(pos, true);
setAudioPlayerTime(pos);
}
......
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