Extract getting of seek duration into a function

This commit is contained in:
Xiang Rong Lin committed 2019-12-13 07:14:17 +01:00
1 parent 17146c2c13
commit 949c01b37f
1 file changed
+7 -6
@@ -954,20 +954,21 @@ public abstract class BasePlayer implements
public void onFastRewind() {
if (DEBUG) Log.d(TAG, "onFastRewind() called");
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
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);
final int duration = getSeekDuration();
seekBy(-duration);
}
public void onFastForward() {
if (DEBUG) Log.d(TAG, "onFastForward() called");
final int duration = getSeekDuration();
seekBy(duration);
}
private int getSeekDuration() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
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);
return Integer.parseInt(value);
}
public void onPlayPrevious() {