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