From 4366e134cf99321ca8166a8021b3cdb031b7d246 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Tue, 23 Feb 2016 08:27:09 +0100 Subject: [PATCH] Prevent NPE --- .../antennapod/activity/AudioplayerActivity.java | 9 +++++++-- .../antennapod/activity/MediaplayerActivity.java | 13 ++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index 2dacb5121..b4e8d4d71 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -139,7 +139,9 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - drawerToggle.onConfigurationChanged(newConfig); + if(drawerToggle != null) { + drawerToggle.onConfigurationChanged(newConfig); + } } private void loadLastFragment() { @@ -283,7 +285,10 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe } public void notifyMediaPositionChanged() { - ChaptersFragment chaptersFragment = mPagerAdapter.getChaptersFragment(); + if(pagerAdapter == null) { + return; + } + ChaptersFragment chaptersFragment = pagerAdapter.getChaptersFragment(); if(chaptersFragment != null) { ChaptersListAdapter adapter = (ChaptersListAdapter) chaptersFragment.getListAdapter(); if (adapter != null) { diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index 27212acd6..0d878b556 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -206,8 +206,10 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O @Override protected void onPause() { super.onPause(); - controller.reinitServiceIfPaused(); - controller.pause(); + if(controller != null) { + controller.reinitServiceIfPaused(); + controller.pause(); + } } /** @@ -582,7 +584,9 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O super.onResume(); Log.d(TAG, "onResume()"); StorageUtils.checkStorageAvailability(this); - controller.init(); + if(controller != null) { + controller.init(); + } } /** @@ -618,6 +622,9 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O private void updateProgressbarPosition(int position, int duration) { Log.d(TAG, "updateProgressbarPosition(" + position + ", " + duration + ")"); + if(sbPosition == null) { + return; + } float progress = ((float) position) / duration; sbPosition.setProgress((int) (progress * sbPosition.getMax())); }