Commit 6fb3e53e authored by Thomas Krex's avatar Thomas Krex

Handling der Messages überarbeitet. Bitmap wird nur noch neu gezeichnet wenn notwendig.

parent aec08a36
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
android:layout_gravity="start" android:layout_gravity="start"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/my_border"
android:fillViewport="false" /> android:fillViewport="false" />
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
\ No newline at end of file
...@@ -10,10 +10,7 @@ ...@@ -10,10 +10,7 @@
<item <item
android:id="@+id/next" android:id="@+id/next"
android:icon="@drawable/abs__ic_go" android:icon="@drawable/abs__ic_go"
android:showAsAction="always"/> android:showAsAction="always" android:title="Next"/>
<item
android:id="@+id/extend"
android:icon="@drawable/ic_action_full_screen"
android:showAsAction="always"/>
</menu> </menu>
\ No newline at end of file
...@@ -36,7 +36,6 @@ import android.widget.AdapterView; ...@@ -36,7 +36,6 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener; import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -47,7 +46,7 @@ import de.tum.in.tttclient.R; ...@@ -47,7 +46,7 @@ import de.tum.in.tttclient.R;
/** /**
* Activity parses feed items at each start via ParseService and stores them in * Activity parses feed items at each start via ParseService and stores them in
* the database via FeedItemDbManager. Can download lectures via DOwnloadService * the database via FeedItemDbManager. Can download lectures via DownloadService
* and start the playback. * and start the playback.
* *
* @author Thomas Krex * @author Thomas Krex
...@@ -150,7 +149,7 @@ public class FeedDetailActivity extends SherlockActivity implements ...@@ -150,7 +149,7 @@ public class FeedDetailActivity extends SherlockActivity implements
setContentView(R.layout.feed_details_activity); setContentView(R.layout.feed_details_activity);
// haptic feedback for longclick // haptic feedback for longclick
myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE); myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
// init progress dialog for showing downloading/unzipping progress // init progress dialog for showing downloading/unzipping progress
progressDialog = new ProgressDialog(FeedDetailActivity.this); progressDialog = new ProgressDialog(FeedDetailActivity.this);
progressDialog.setIndeterminate(true); progressDialog.setIndeterminate(true);
...@@ -170,48 +169,49 @@ public class FeedDetailActivity extends SherlockActivity implements ...@@ -170,48 +169,49 @@ public class FeedDetailActivity extends SherlockActivity implements
feedItemLv.setEmptyView(findViewById(R.id.empty)); feedItemLv.setEmptyView(findViewById(R.id.empty));
// displaying items in listview // displaying items in listview
manager = new FeedItemDbManager(this); manager = new FeedItemDbManager(this);
// manager.deleteTable(); // manager.deleteTable();
Cursor cursor = manager.getAllFromDB(feed.getId()); Cursor cursor = manager.getAllFromDB(feed.getId());
adapter = new SimpleCursorAdapter(this, R.layout.list_feeditems, adapter = new SimpleCursorAdapter(this, R.layout.list_feeditems,
cursor, new String[] { FeedItemDbManager.COLUMN_TITLE, cursor, new String[] { FeedItemDbManager.COLUMN_TITLE,
FeedItemDbManager.COLUMN_STATUS ,FeedItemDbManager.COLUMN_DATE}, new int[] { FeedItemDbManager.COLUMN_STATUS,
R.id.itemTitle, R.id.statusIcon,R.id.listHeader }); FeedItemDbManager.COLUMN_DATE }, new int[] {
R.id.itemTitle, R.id.statusIcon, R.id.listHeader });
// set Binder to change icon depending on download status // set Binder to change icon depending on download status
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
@Override @Override
public boolean setViewValue(View view, Cursor cursor, public boolean setViewValue(View view, Cursor cursor,
int columnIndex) { int columnIndex) {
boolean state=false; boolean state = false;
// insert month separator // insert month separator
if(view.getId()==R.id.listHeader){ if (view.getId() == R.id.listHeader) {
TextView tx = (TextView) view; TextView tx = (TextView) view;
Date currDate= Utils.stringToDate(cursor.getString(cursor.getColumnIndex(FeedItemDbManager.COLUMN_DATE))); Date currDate = Utils.stringToDate(cursor.getString(cursor
Date prevDate= null; .getColumnIndex(FeedItemDbManager.COLUMN_DATE)));
Date prevDate = null;
if (cursor.getPosition() > 0 && cursor.moveToPrevious()) { if (cursor.getPosition() > 0 && cursor.moveToPrevious()) {
prevDate = Utils.stringToDate(cursor.getString(cursor.getColumnIndex(FeedItemDbManager.COLUMN_DATE))); prevDate = Utils.stringToDate(cursor.getString(cursor
.getColumnIndex(FeedItemDbManager.COLUMN_DATE)));
cursor.moveToNext();
} cursor.moveToNext();
if(prevDate==null||prevDate.getMonth()!=currDate.getMonth()){
tx.setText(new DateFormatSymbols().getMonths()[currDate.getMonth()]);
tx.setVisibility(View.VISIBLE);
} }
else{ if (prevDate == null
|| prevDate.getMonth() != currDate.getMonth()) {
tx.setText(new DateFormatSymbols().getMonths()[currDate
.getMonth()]);
tx.setVisibility(View.VISIBLE);
} else {
tx.setVisibility(View.GONE); tx.setVisibility(View.GONE);
} }
state=true; state = true;
} }
// change icon depending on status // change icon depending on status
if (view.getId() == R.id.statusIcon) { if (view.getId() == R.id.statusIcon) {
ImageView icon = (ImageView) view; ImageView icon = (ImageView) view;
...@@ -227,7 +227,7 @@ public class FeedDetailActivity extends SherlockActivity implements ...@@ -227,7 +227,7 @@ public class FeedDetailActivity extends SherlockActivity implements
(R.drawable.ic_action_download))); (R.drawable.ic_action_download)));
} }
state=true; state = true;
} }
......
...@@ -51,12 +51,19 @@ public class PlayerActivity extends SherlockFragmentActivity implements ...@@ -51,12 +51,19 @@ public class PlayerActivity extends SherlockFragmentActivity implements
MediaPlayerControl { MediaPlayerControl {
static final int LAYOUT_MODE_FULL = 0; static final int LAYOUT_MODE_FULL = 0;
static final int LAYOUT_MODE_EXTENDED = 1; static final int LAYOUT_MODE_EXTENDED = 1;
public String fileName; public String fileName;
public String filePath; public String filePath;
private File tttFile;
private File audioFile;
private ProgressDialog dialog;
private LinearLayout content; private LinearLayout content;
private LinearLayout container; private LinearLayout container;
public SurfaceView surfaceView; public SurfaceView surfaceView;
private ScrollView scrollView; private ScrollView scrollView;
private Recording recording; private Recording recording;
private MediaPlayer audioPlayer; private MediaPlayer audioPlayer;
private MediaController audioController; private MediaController audioController;
...@@ -114,7 +121,7 @@ public class PlayerActivity extends SherlockFragmentActivity implements ...@@ -114,7 +121,7 @@ public class PlayerActivity extends SherlockFragmentActivity implements
getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
/******************************************************************************************************************* /*******************************************************************************************************************
* Main Initialization * * Initialization of all Views *
********************************************************************************************************************/ ********************************************************************************************************************/
scrollView = (ScrollView) findViewById(R.id.indexScrollView); scrollView = (ScrollView) findViewById(R.id.indexScrollView);
...@@ -133,29 +140,6 @@ public class PlayerActivity extends SherlockFragmentActivity implements ...@@ -133,29 +140,6 @@ public class PlayerActivity extends SherlockFragmentActivity implements
} }
}); });
fileName = getIntent().getStringExtra(DownloadService.FILE_NAME);
setTitle(fileName);
filePath = getIntent().getStringExtra(DownloadService.FILE_PATH);
final File tttFile = new File(filePath + "/" + fileName + ".ttt");
File audioFile = new File(filePath + "/" + fileName + ".mp3");
// audioPlayer for controlling mp3-file
audioPlayer = MediaPlayer.create(this, Uri.fromFile(audioFile));
// creates a MediaController without fastforward and rewind buttons
audioController = new MediaController(new ContextThemeWrapper(this,
R.style.android_Theme_MusicPlayer), false);
audioController.setMediaPlayer(this);
// show dialog parse ttt-File
final ProgressDialog dialog = new ProgressDialog(PlayerActivity.this);
dialog.setTitle("Please Wait");
dialog.setMessage("Prepare File ...");
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
/** /**
* asynchronous task for creating the recording object. prevents ui from * asynchronous task for creating the recording object. prevents ui from
...@@ -166,8 +150,35 @@ public class PlayerActivity extends SherlockFragmentActivity implements ...@@ -166,8 +150,35 @@ public class PlayerActivity extends SherlockFragmentActivity implements
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute(); super.onPreExecute();
fileName = getIntent()
.getStringExtra(DownloadService.FILE_NAME);
setTitle(fileName);
filePath = getIntent()
.getStringExtra(DownloadService.FILE_PATH);
tttFile = new File(filePath + "/" + fileName + ".ttt");
audioFile = new File(filePath + "/" + fileName + ".mp3");
// audioPlayer for controlling mp3-file
audioPlayer = MediaPlayer.create(getApplicationContext(),
Uri.fromFile(audioFile));
// creates a MediaController without fastforward and rewind
// buttons
audioController = new MediaController(
new ContextThemeWrapper(PlayerActivity.this,
R.style.android_Theme_MusicPlayer), false);
audioController.setMediaPlayer(PlayerActivity.this);
// show dialog parse ttt-File
dialog = new ProgressDialog(PlayerActivity.this);
dialog.setTitle("Please Wait");
dialog.setMessage("Prepare File ...");
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
dialog.show(); dialog.show();
} }
...@@ -369,7 +380,7 @@ public class PlayerActivity extends SherlockFragmentActivity implements ...@@ -369,7 +380,7 @@ public class PlayerActivity extends SherlockFragmentActivity implements
return true; return true;
} }
boolean isExtendend = false; // boolean isExtendend = false;
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
...@@ -380,24 +391,24 @@ public class PlayerActivity extends SherlockFragmentActivity implements ...@@ -380,24 +391,24 @@ public class PlayerActivity extends SherlockFragmentActivity implements
} }
switch (item.getItemId()) { switch (item.getItemId()) {
// handle layout switch // handle layout switch
case R.id.extend: // case R.id.extend:
if (!isExtendend) { // if (!isExtendend) {
// switchLayout(LAYOUT_MODE_EXTENDED); // // switchLayout(LAYOUT_MODE_EXTENDED);
// item.setIcon(getResources().getDrawable( // // item.setIcon(getResources().getDrawable(
// R.drawable.ic_action_full_screen)); // // R.drawable.ic_action_full_screen));
scrollView.setVisibility(View.VISIBLE); // scrollView.setVisibility(View.VISIBLE);
isExtendend = true; // isExtendend = true;
} else if (isExtendend) { // } else if (isExtendend) {
// switchLayout(LAYOUT_MODE_FULL); // // switchLayout(LAYOUT_MODE_FULL);
// item.setIcon(getResources().getDrawable( // // item.setIcon(getResources().getDrawable(
// R.drawable.ic_action_return_from_full_screen)); // // R.drawable.ic_action_return_from_full_screen));
scrollView.setVisibility(View.GONE); // scrollView.setVisibility(View.GONE);
isExtendend = false; // isExtendend = false;
//
} // }
return true; // return true;
// go to next search result // go to next search result
case R.id.next: case R.id.next:
if (!searchView.getQuery().toString().isEmpty()) if (!searchView.getQuery().toString().isEmpty())
recording.getIndex().nextSearchResult(); recording.getIndex().nextSearchResult();
...@@ -448,7 +459,7 @@ public class PlayerActivity extends SherlockFragmentActivity implements ...@@ -448,7 +459,7 @@ public class PlayerActivity extends SherlockFragmentActivity implements
float aspectRatio = (float) display.getHeight() float aspectRatio = (float) display.getHeight()
/ (float) recording.getProtocolPreferences().framebufferHeight; / (float) recording.getProtocolPreferences().framebufferHeight;
LayoutParams lp = container.getLayoutParams(); LayoutParams lp = container.getLayoutParams();
lp.width = (int) (aspectRatio * recording.getProtocolPreferences().framebufferWidth); lp.width = (int) (aspectRatio * recording.getProtocolPreferences().framebufferWidth) - 1;
container.setLayoutParams(lp); container.setLayoutParams(lp);
} }
......
...@@ -7,6 +7,8 @@ import tttclient.messages.MessageConsumer; ...@@ -7,6 +7,8 @@ import tttclient.messages.MessageConsumer;
import tttclient.messages.MessageProducer; import tttclient.messages.MessageProducer;
import tttclient.messages.WhiteboardMessage; import tttclient.messages.WhiteboardMessage;
import tttclient.messages.annotations.Annotation; import tttclient.messages.annotations.Annotation;
import tttclient.messages.annotations.DeleteAllAnnotation;
import tttclient.messages.annotations.DeleteAnnotation;
import tttclient.utils.BitmapContainer; import tttclient.utils.BitmapContainer;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Bitmap.Config; import android.graphics.Bitmap.Config;
...@@ -103,18 +105,14 @@ public class GraphicsContext implements MessageConsumer { ...@@ -103,18 +105,14 @@ public class GraphicsContext implements MessageConsumer {
public void updateView(boolean setBitmap) { public void updateView(boolean setBitmap) {
Canvas canvas = holder.lockCanvas(); Canvas canvas = holder.lockCanvas();
int savecount = 0;
if (canvas != null) { if (canvas != null) {
// if (setBitmap) { if (setBitmap) {
canvas.drawBitmap(pixels, 0, canvas.drawBitmap(pixels, 0,
recording.getProtocolPreferences().framebufferWidth, 0, 0, recording.getProtocolPreferences().framebufferWidth, 0,
recording.getProtocolPreferences().framebufferWidth, 0, recording.getProtocolPreferences().framebufferWidth,
recording.getProtocolPreferences().framebufferHeight, recording.getProtocolPreferences().framebufferHeight,
false, null); false, null);
}
// savecount = canvas.save();
// } else
// canvas.restoreToCount(savecount);
if (isWhiteboardEnabled()) if (isWhiteboardEnabled())
paintWhiteboard(canvas); paintWhiteboard(canvas);
paintAnnotations(canvas); paintAnnotations(canvas);
...@@ -165,13 +163,22 @@ public class GraphicsContext implements MessageConsumer { ...@@ -165,13 +163,22 @@ public class GraphicsContext implements MessageConsumer {
} }
/** /**
* updateView if messages is an Annotation * Painting of all Messages is done here
*/ */
@Override @Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
// delegates message to corresponding class
message.paint(this); message.paint(this);
updateView(false);
// updating Canvas denpending on type of message
if (message instanceof DeleteAllAnnotation
|| message instanceof DeleteAnnotation)
updateView(true);
else if (message instanceof Annotation)
updateView(false);
else
updateView(true);
} }
...@@ -285,7 +292,7 @@ public class GraphicsContext implements MessageConsumer { ...@@ -285,7 +292,7 @@ public class GraphicsContext implements MessageConsumer {
public void setWhiteboardPage(int whiteboardPage) { public void setWhiteboardPage(int whiteboardPage) {
this.whiteboardPage = whiteboardPage; this.whiteboardPage = whiteboardPage;
clearAnnotations(); clearAnnotations();
updateView(false); // updateView(false);
} }
// updates for late comers and recorders // updates for late comers and recorders
......
...@@ -465,10 +465,7 @@ public class Recording extends MessageProducerAdapter implements Runnable { ...@@ -465,10 +465,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// focusCurrentIndexEntry(time); // focusCurrentIndexEntry(time);
index.setCorrespondingIndex(time); index.setCorrespondingIndex(time);
setAudioPlayerTime(time); setAudioPlayerTime(time);
if (time == 0) graphicsContext.updateView(true);
graphicsContext.updateView(true);
else
graphicsContext.updateView(false);
} }
// while loop is started again // while loop is started again
......
...@@ -51,7 +51,7 @@ public class DeleteAnnotation extends Annotation { ...@@ -51,7 +51,7 @@ public class DeleteAnnotation extends Annotation {
@Override @Override
public void paint(GraphicsContext graphicsContext) { public void paint(GraphicsContext graphicsContext) {
graphicsContext.removeAnnotationsAt(x, y); graphicsContext.removeAnnotationsAt(x, y);
graphicsContext.updateView(false);
} }
@Override @Override
......
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