From 76b6ae654b8b23334c977e4f56fd9157ea982585 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Mon, 6 Apr 2015 18:13:44 +0200 Subject: Refactorings --- .../antennapod/activity/AudioplayerActivity.java | 58 +++++++--------------- 1 file changed, 17 insertions(+), 41 deletions(-) (limited to 'app/src/main/java/de') 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 f056b107b..335958a40 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -29,7 +29,6 @@ import com.squareup.picasso.Picasso; import org.apache.commons.lang3.StringUtils; -import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.adapter.ChapterListAdapter; import de.danoeh.antennapod.adapter.NavListAdapter; @@ -96,30 +95,25 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc FragmentTransaction fT = getSupportFragmentManager().beginTransaction(); if (coverFragment != null) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Removing cover fragment"); + Log.d(TAG, "Removing cover fragment"); fT.remove(coverFragment); } if (descriptionFragment != null) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Removing description fragment"); + Log.d(TAG, "Removing description fragment"); fT.remove(descriptionFragment); } if (chapterFragment != null) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Removing chapter fragment"); + Log.d(TAG, "Removing chapter fragment"); fT.remove(chapterFragment); } if (currentlyShownFragment != null) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Removing currently shown fragment"); + 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 (BuildConfig.DEBUG) - Log.d(TAG, "Removing detached fragment"); + Log.d(TAG, "Removing detached fragment"); fT.remove(f); } } @@ -152,8 +146,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc } private void savePreferences() { - if (BuildConfig.DEBUG) - Log.d(TAG, "Saving preferences"); + Log.d(TAG, "Saving preferences"); SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); if (currentlyShownPosition >= 0 && controller != null @@ -180,9 +173,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc @Override protected void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); would cause crash - if (BuildConfig.DEBUG) - Log.d(TAG, "onSaveInstanceState"); - + Log.d(TAG, "onSaveInstanceState"); } @Override @@ -205,8 +196,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc * @return true if restoreFromPrefernces changed the activity's state */ private boolean restoreFromPreferences() { - if (BuildConfig.DEBUG) - Log.d(TAG, "Restoring instance state"); + Log.d(TAG, "Restoring instance state"); SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE); int savedPosition = prefs.getInt(PREF_KEY_SELECTED_FRAGMENT_POSITION, -1); @@ -220,15 +210,10 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc switchToFragment(savedPosition); return true; } else if (controller == null || controller.getMedia() == null) { - if (BuildConfig.DEBUG) - Log.d(TAG, - "Couldn't restore from preferences: controller or media was null"); + Log.d(TAG, "Couldn't restore from preferences: controller or media was null"); } else { - if (BuildConfig.DEBUG) - Log.d(TAG, - "Couldn't restore from preferences: savedPosition was -1 or saved identifier and playable identifier didn't match.\nsavedPosition: " - + savedPosition + ", id: " + playableId - ); + Log.d(TAG, "Couldn't restore from preferences: savedPosition was -1 or saved identifier and playable identifier didn't match.\nsavedPosition: " + + savedPosition + ", id: " + playableId); } return false; @@ -239,9 +224,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc super.onResume(); if (StringUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) { Intent intent = getIntent(); - if (BuildConfig.DEBUG) - Log.d(TAG, "Received VIEW intent: " - + intent.getData().getPath()); + Log.d(TAG, "Received VIEW intent: " + intent.getData().getPath()); ExternalMedia media = new ExternalMedia(intent.getData().getPath(), MediaType.AUDIO); Intent launchIntent = new Intent(this, PlaybackService.class); @@ -269,8 +252,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc @Override protected void onAwaitingVideoSurface() { - if (BuildConfig.DEBUG) - Log.d(TAG, "onAwaitingVideoSurface was called in audio player -> switching to video player"); + Log.d(TAG, "onAwaitingVideoSurface was called in audio player -> switching to video player"); startActivity(new Intent(this, VideoplayerActivity.class)); } @@ -295,8 +277,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc * @param pos Must be POS_COVER, POS_DESCR, or POS_CHAPTERS */ private void switchToFragment(int pos) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Switching contentView to position " + pos); + Log.d(TAG, "Switching contentView to position " + pos); if (currentlyShownPosition != pos && controller != null) { Playable media = controller.getMedia(); if (media != null) { @@ -354,9 +335,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc lastShownPosition = currentlyShownPosition; currentlyShownPosition = pos; if (detachedFragments[pos] != null) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Reattaching fragment at position " - + pos); + Log.d(TAG, "Reattaching fragment at position " + pos); ft.attach(detachedFragments[pos]); } else { ft.add(R.id.contentView, currentlyShownFragment); @@ -630,9 +609,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc @Override protected void onReloadNotification(int notificationCode) { if (notificationCode == PlaybackService.EXTRA_CODE_VIDEO) { - if (BuildConfig.DEBUG) - Log.d(TAG, - "ReloadNotification received, switching to Videoplayer now"); + Log.d(TAG, "ReloadNotification received, switching to Videoplayer now"); finish(); startActivity(new Intent(this, VideoplayerActivity.class)); @@ -729,8 +706,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc @Override public void update(EventDistributor eventDistributor, Integer arg) { if ((EventDistributor.FEED_LIST_UPDATE & arg) != 0) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Received contentUpdate Intent."); + Log.d(TAG, "Received contentUpdate Intent."); loadData(); } } -- cgit v1.2.3