Refactor
This commit is contained in:
parent
04026ca48c
commit
0564988357
|
@ -178,7 +178,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
}
|
||||
|
||||
protected void onPlaybackSpeedChange() {
|
||||
updateButPlaybackSpeed();
|
||||
updatePlaybackSpeedButtonText();
|
||||
}
|
||||
|
||||
protected void onServiceQueried() {
|
||||
|
@ -647,6 +647,22 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void updatePlaybackSpeedButtonText() {
|
||||
if (controller != null && butPlaybackSpeed != null) {
|
||||
float speed = 1.0f;
|
||||
try {
|
||||
speed = Float.parseFloat(UserPreferences.getPlaybackSpeed());
|
||||
} catch(NumberFormatException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
UserPreferences.setPlaybackSpeed(String.valueOf(speed));
|
||||
}
|
||||
String speedStr = String.format("%.2fx", speed);
|
||||
butPlaybackSpeed.setText(speedStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void setupGUI() {
|
||||
setContentView(getContentViewResourceId());
|
||||
sbPosition = (SeekBar) findViewById(R.id.sbPosition);
|
||||
|
@ -874,20 +890,6 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
}
|
||||
}
|
||||
|
||||
private void updateButPlaybackSpeed() {
|
||||
if (controller != null && butPlaybackSpeed != null) {
|
||||
float speed = 1.0f;
|
||||
try {
|
||||
speed = Float.parseFloat(UserPreferences.getPlaybackSpeed());
|
||||
} catch(NumberFormatException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
UserPreferences.setPlaybackSpeed(String.valueOf(speed));
|
||||
}
|
||||
String speedStr = String.format("%.2fx", speed);
|
||||
butPlaybackSpeed.setText(speedStr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
if (controller != null) {
|
||||
|
|
|
@ -512,8 +512,7 @@ public class PlaybackService extends Service {
|
|||
|
||||
@Override
|
||||
public void playbackSpeedChanged(float s) {
|
||||
sendNotificationBroadcast(
|
||||
NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE, 0);
|
||||
sendNotificationBroadcast(NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,8 @@ import android.view.WindowManager;
|
|||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import org.antennapod.audio.MediaPlayer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
@ -1050,7 +1052,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
|
|||
return mp;
|
||||
}
|
||||
|
||||
private final org.antennapod.audio.MediaPlayer.OnCompletionListener audioCompletionListener =
|
||||
private final MediaPlayer.OnCompletionListener audioCompletionListener =
|
||||
mp -> genericOnCompletion();
|
||||
|
||||
private final android.media.MediaPlayer.OnCompletionListener videoCompletionListener =
|
||||
|
@ -1060,7 +1062,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
|
|||
endPlayback(false);
|
||||
}
|
||||
|
||||
private final org.antennapod.audio.MediaPlayer.OnBufferingUpdateListener audioBufferingUpdateListener =
|
||||
private final MediaPlayer.OnBufferingUpdateListener audioBufferingUpdateListener =
|
||||
(mp, percent) -> genericOnBufferingUpdate(percent);
|
||||
|
||||
private final android.media.MediaPlayer.OnBufferingUpdateListener videoBufferingUpdateListener =
|
||||
|
@ -1070,7 +1072,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
|
|||
callback.onBufferingUpdate(percent);
|
||||
}
|
||||
|
||||
private final org.antennapod.audio.MediaPlayer.OnInfoListener audioInfoListener =
|
||||
private final MediaPlayer.OnInfoListener audioInfoListener =
|
||||
(mp, what, extra) -> genericInfoListener(what);
|
||||
|
||||
private final android.media.MediaPlayer.OnInfoListener videoInfoListener =
|
||||
|
@ -1080,7 +1082,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
|
|||
return callback.onMediaPlayerInfo(what);
|
||||
}
|
||||
|
||||
private final org.antennapod.audio.MediaPlayer.OnErrorListener audioErrorListener =
|
||||
private final MediaPlayer.OnErrorListener audioErrorListener =
|
||||
(mp, what, extra) -> {
|
||||
if(mp.canFallback()) {
|
||||
mp.fallback();
|
||||
|
@ -1096,7 +1098,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
|
|||
return callback.onMediaPlayerError(inObj, what, extra);
|
||||
}
|
||||
|
||||
private final org.antennapod.audio.MediaPlayer.OnSeekCompleteListener audioSeekCompleteListener =
|
||||
private final MediaPlayer.OnSeekCompleteListener audioSeekCompleteListener =
|
||||
mp -> genericSeekCompleteListener();
|
||||
|
||||
private final android.media.MediaPlayer.OnSeekCompleteListener videoSeekCompleteListener =
|
||||
|
|
Loading…
Reference in New Issue