From d79dd76d9a44c3b6cc57d5d946652aa8b01cbf56 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Tue, 10 Jul 2012 22:31:24 +0200 Subject: Improved orientation change handling --- src/de/podfetcher/activity/MediaplayerActivity.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/de') diff --git a/src/de/podfetcher/activity/MediaplayerActivity.java b/src/de/podfetcher/activity/MediaplayerActivity.java index 0afbce1c9..134ca7204 100644 --- a/src/de/podfetcher/activity/MediaplayerActivity.java +++ b/src/de/podfetcher/activity/MediaplayerActivity.java @@ -145,11 +145,6 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements if (positionObserver != null) { positionObserver.cancel(true); } - if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - setContentView(R.layout.mediaplayer_activity); - } else { - setContentView(R.layout.mediaplayer_activity); - } setupGUI(); handleStatus(); @@ -177,9 +172,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements orientation = getResources().getConfiguration().orientation; manager = FeedManager.getInstance(); getWindow().setFormat(PixelFormat.TRANSPARENT); - this.setContentView(R.layout.mediaplayer_activity); - setupGUI(); bindToService(); } @@ -327,6 +320,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements } private void setupGUI() { + setContentView(R.layout.mediaplayer_activity); sbPosition = (SeekBar) findViewById(R.id.sbPosition); txtvPosition = (TextView) findViewById(R.id.txtvPosition); txtvLength = (TextView) findViewById(R.id.txtvLength); @@ -503,6 +497,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements if ((requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && orientation == Configuration.ORIENTATION_LANDSCAPE) || (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && orientation == Configuration.ORIENTATION_PORTRAIT)) { Log.d(TAG, "Orientation correct"); + setupGUI(); handleStatus(); } else { Log.d(TAG, @@ -671,7 +666,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements } public static class MediaPlayerPagerAdapter extends - FragmentStatePagerAdapter { + FragmentPagerAdapter { private int numItems; private MediaplayerActivity activity; @@ -725,7 +720,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements @Override public int getItemPosition(Object object) { - return POSITION_NONE; + return POSITION_UNCHANGED; } } -- cgit v1.2.3