summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fietz <Martin.Fietz@gmail.com>2016-03-24 17:14:43 +0100
committerMartin Fietz <Martin.Fietz@gmail.com>2016-03-25 13:14:33 +0100
commitbae78fe7af98b4d7fa8a99a1c30610188e20f55c (patch)
treecbf7b2f49093658ceee53f9284abc3394d582124
parent025ace37227f968236154e04c92b51cc18f474e6 (diff)
downloadAntennaPod-bae78fe7af98b4d7fa8a99a1c30610188e20f55c.zip
Refactor
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java40
1 files changed, 23 insertions, 17 deletions
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 cad414118..8810f3375 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -645,33 +645,39 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
}
private void updatePlaybackSpeedButton() {
- if(butPlaybackSpeed != null) {
- if (controller == null) {
- butPlaybackSpeed.setVisibility(View.GONE);
- } else {
- butPlaybackSpeed.setVisibility(View.VISIBLE);
- if (controller.canSetPlaybackSpeed()) {
- ViewCompat.setAlpha(butPlaybackSpeed, 1.0f);
- } else {
- ViewCompat.setAlpha(butPlaybackSpeed, 0.5f);
- }
- }
- updatePlaybackSpeedButtonText();
+ if(butPlaybackSpeed == null) {
+ return;
+ }
+ if (controller == null) {
+ butPlaybackSpeed.setVisibility(View.GONE);
+ return;
}
+ updatePlaybackSpeedButtonText();
+ ViewCompat.setAlpha(butPlaybackSpeed, controller.canSetPlaybackSpeed() ? 1.0f : 0.5f);
+ butPlaybackSpeed.setVisibility(View.VISIBLE);
}
private void updatePlaybackSpeedButtonText() {
- if (controller != null && butPlaybackSpeed != null) {
- float speed = 1.0f;
+ if(butPlaybackSpeed == null) {
+ return;
+ }
+ if (controller == null) {
+ butPlaybackSpeed.setVisibility(View.GONE);
+ return;
+ }
+ float speed = 1.0f;
+ if(controller.canSetPlaybackSpeed()) {
try {
+ // we can only retrieve the playback speed from the controller/playback service
+ // once mediaplayer has been initialized
speed = Float.parseFloat(UserPreferences.getPlaybackSpeed());
- } catch(NumberFormatException e) {
+ } catch (NumberFormatException e) {
Log.e(TAG, Log.getStackTraceString(e));
UserPreferences.setPlaybackSpeed(String.valueOf(speed));
}
- String speedStr = String.format("%.2fx", speed);
- butPlaybackSpeed.setText(speedStr);
}
+ String speedStr = String.format("%.2fx", speed);
+ butPlaybackSpeed.setText(speedStr);
}