Commit c19fbf0d authored by Thomas Krex's avatar Thomas Krex

Skalierung angepasst: statt der Displayhöhe wird die tatsächliche Höhe des...

Skalierung angepasst: statt der Displayhöhe wird die tatsächliche Höhe des SurfaceViews herangezogen. Dazu benötigt man einen ViewTreeOberserver. Mit diesem kann die Höhe kurz vor dem Zeichnen des Views bestimmt werden. Dies ist die einzigeste Möglichkeit, da erst in diesem Moment die tatsächliche Höhe bekannt ist. Davor bekommt man nur den Wert 0 geliefert.
parent da8e0041
......@@ -7,6 +7,8 @@ import android.content.Intent;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import de.tum.in.tttclient.R;
......@@ -20,6 +22,27 @@ public class FeedActivity extends SherlockFragmentActivity implements
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getSupportMenuInflater().inflate(R.menu.feed_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.add) {
// addDialog.show();
Intent intent = new Intent(this, FeedWizardActivity.class);
startActivityForResult(intent, 0);
}
return true;
}
@Override
public void onFeedSelected(Feed feed) {
FeedDetailsFragment detailsFragment = (FeedDetailsFragment) getSupportFragmentManager()
......
......@@ -15,12 +15,12 @@ import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.DrawerLayout.DrawerListener;
import android.view.ContextThemeWrapper;
import android.view.Display;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver;
import android.view.inputmethod.EditorInfo;
import android.widget.LinearLayout;
import android.widget.MediaController;
......@@ -62,6 +62,7 @@ public class PlayerActivity extends SherlockFragmentActivity implements
private LinearLayout content;
private LinearLayout container;
public SurfaceView surfaceView;
private int screenHeight;
private ScrollView scrollView;
private Recording recording;
......@@ -141,6 +142,20 @@ public class PlayerActivity extends SherlockFragmentActivity implements
}
});
// height of the surfaceview can only be measured right before it's
// drawn. The actual height of the view is used for scaling.
ViewTreeObserver vto = surfaceView.getViewTreeObserver();
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
surfaceView.getViewTreeObserver().removeOnPreDrawListener(this);
screenHeight = surfaceView.getMeasuredHeight();
return true;
}
});
/**
* asynchronous task for creating the recording object. prevents ui from
* being stucked, while reading messages and creating thumbnails
......@@ -455,8 +470,8 @@ public class PlayerActivity extends SherlockFragmentActivity implements
*
*/
public void scaleView() {
Display display = getWindowManager().getDefaultDisplay();
float aspectRatio = (float) display.getHeight()
float aspectRatio = (float) screenHeight
/ (float) recording.getProtocolPreferences().framebufferHeight;
LayoutParams lp = container.getLayoutParams();
lp.width = (int) (aspectRatio * recording.getProtocolPreferences().framebufferWidth) - 1;
......
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