summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/de')
-rw-r--r--src/de/danoeh/antennapod/activity/AudioplayerActivity.java84
-rw-r--r--src/de/danoeh/antennapod/activity/MediaplayerActivity.java12
-rw-r--r--src/de/danoeh/antennapod/activity/VideoplayerActivity.java5
3 files changed, 86 insertions, 15 deletions
diff --git a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
index 2809d638f..6231e2a22 100644
--- a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
@@ -1,6 +1,7 @@
package de.danoeh.antennapod.activity;
import android.content.Intent;
+import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@@ -47,6 +48,8 @@ public class AudioplayerActivity extends MediaplayerActivity {
private Fragment currentlyShownFragment;
private int currentlyShownPosition = -1;
+ /** Saved and restored on orientation change. */
+ private int savedPosition = -1;
private TextView txtvTitle;
private TextView txtvFeed;
@@ -54,6 +57,37 @@ public class AudioplayerActivity extends MediaplayerActivity {
private ImageButton butNavRight;
private void resetFragmentView() {
+ FragmentTransaction fT = getSupportFragmentManager().beginTransaction();
+
+ if (coverFragment != null) {
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Removing cover fragment");
+ fT.remove(coverFragment);
+ }
+ if (descriptionFragment != null) {
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Removing description fragment");
+ fT.remove(descriptionFragment);
+ }
+ if (chapterFragment != null) {
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Removing chapter fragment");
+ fT.remove(chapterFragment);
+ }
+ if (currentlyShownFragment != null) {
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Removing currently shown fragment");
+ fT.remove(currentlyShownFragment);
+ }
+ for (int i = 0; i < detachedFragments.length; i++) {
+ Fragment f = detachedFragments[i];
+ if (f != null) {
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Removing detached fragment");
+ fT.remove(f);
+ }
+ }
+ fT.commit();
currentlyShownFragment = null;
coverFragment = null;
descriptionFragment = null;
@@ -65,7 +99,7 @@ public class AudioplayerActivity extends MediaplayerActivity {
@Override
protected void onStop() {
super.onStop();
- resetFragmentView();
+ if (AppConfig.DEBUG) Log.d(TAG, "onStop");
}
@@ -78,6 +112,33 @@ public class AudioplayerActivity extends MediaplayerActivity {
}
@Override
+ public void onConfigurationChanged(Configuration newConfig) {
+
+ super.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ outState.putInt("selectedPosition", currentlyShownPosition);
+ resetFragmentView();
+ super.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Restoring instance state");
+ if (savedInstanceState != null) {
+ int p = savedInstanceState.getInt("selectedPosition", -1);
+ if (p != -1) {
+ savedPosition = p;
+ switchToFragment(savedPosition);
+ }
+ }
+ }
+
+ @Override
protected void onResume() {
super.onResume();
if (getIntent().getAction() != null
@@ -187,6 +248,7 @@ public class AudioplayerActivity extends MediaplayerActivity {
ft.add(R.id.contentView, currentlyShownFragment);
}
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+ ft.disallowAddToBackStack();
ft.commit();
updateNavButtonDrawable();
}
@@ -211,8 +273,8 @@ public class AudioplayerActivity extends MediaplayerActivity {
@Override
public void run() {
- ImageLoader.getInstance().loadThumbnailBitmap(
- media, butNavLeft);
+ ImageLoader.getInstance().loadThumbnailBitmap(media,
+ butNavLeft);
}
});
butNavRight.setImageDrawable(drawables.getDrawable(1));
@@ -223,8 +285,8 @@ public class AudioplayerActivity extends MediaplayerActivity {
@Override
public void run() {
- ImageLoader.getInstance().loadThumbnailBitmap(
- media, butNavLeft);
+ ImageLoader.getInstance().loadThumbnailBitmap(media,
+ butNavLeft);
}
});
butNavRight.setImageDrawable(drawables.getDrawable(0));
@@ -291,7 +353,12 @@ public class AudioplayerActivity extends MediaplayerActivity {
}
if (currentlyShownPosition == -1) {
- switchToFragment(POS_COVER);
+ if (savedPosition != -1) {
+ switchToFragment(savedPosition);
+ savedPosition = -1;
+ } else {
+ switchToFragment(POS_COVER);
+ }
}
if (currentlyShownFragment instanceof AudioplayerContentFragment) {
((AudioplayerContentFragment) currentlyShownFragment)
@@ -333,4 +400,9 @@ public class AudioplayerActivity extends MediaplayerActivity {
public void onDataSetChanged(Playable media);
}
+ @Override
+ protected int getContentViewResourceId() {
+ return R.layout.audioplayer_activity;
+ }
+
}
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
index 6d27a82e0..16b03809a 100644
--- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -3,7 +3,6 @@ package de.danoeh.antennapod.activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.net.Uri;
import android.os.Bundle;
@@ -331,13 +330,6 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
controller.init();
}
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- // ignore orientation change
-
- }
-
/**
* Called by 'handleStatus()' when the PlaybackService is in the
* AWAITING_VIDEO_SURFACE state.
@@ -399,7 +391,7 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
}
protected void setupGUI() {
- setContentView(R.layout.mediaplayer_activity);
+ setContentView(getContentViewResourceId());
sbPosition = (SeekBar) findViewById(R.id.sbPosition);
txtvPosition = (TextView) findViewById(R.id.txtvPosition);
txtvLength = (TextView) findViewById(R.id.txtvLength);
@@ -421,6 +413,8 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
}
+ protected abstract int getContentViewResourceId();
+
void handleError(int errorCode) {
final AlertDialog.Builder errorDialog = new AlertDialog.Builder(this);
errorDialog.setTitle(R.string.error_label);
diff --git a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java
index 2d9834a3e..b3567e417 100644
--- a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java
@@ -287,4 +287,9 @@ public class VideoplayerActivity extends MediaplayerActivity implements
videoOverlay.setVisibility(View.GONE);
}
+ @Override
+ protected int getContentViewResourceId() {
+ return R.layout.videoplayer_activity;
+ }
+
}