1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-26 04:52:29 +01:00

Extract getting of seek duration into a function

This commit is contained in:
Xiang Rong Lin 2019-11-25 11:16:59 +01:00
parent 17146c2c13
commit 949c01b37f

View File

@ -954,20 +954,21 @@ public abstract class BasePlayer implements
public void onFastRewind() { public void onFastRewind() {
if (DEBUG) Log.d(TAG, "onFastRewind() called"); if (DEBUG) Log.d(TAG, "onFastRewind() called");
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final int duration = getSeekDuration();
final String key = context.getString(R.string.seek_duration_key);
final String value = prefs.getString(key, FAST_FORWARD_REWIND_DEFAULT_AMOUNT_MILLIS);
final int duration = Integer.parseInt(value);
seekBy(-duration); seekBy(-duration);
} }
public void onFastForward() { public void onFastForward() {
if (DEBUG) Log.d(TAG, "onFastForward() called"); if (DEBUG) Log.d(TAG, "onFastForward() called");
final int duration = getSeekDuration();
seekBy(duration);
}
private int getSeekDuration() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
final String key = context.getString(R.string.seek_duration_key); final String key = context.getString(R.string.seek_duration_key);
final String value = prefs.getString(key, FAST_FORWARD_REWIND_DEFAULT_AMOUNT_MILLIS); final String value = prefs.getString(key, FAST_FORWARD_REWIND_DEFAULT_AMOUNT_MILLIS);
final int duration = Integer.parseInt(value); return Integer.parseInt(value);
seekBy(duration);
} }
public void onPlayPrevious() { public void onPlayPrevious() {