Merge "Fix issue in ring volume sample not always being played." into pi-dev am: 1b899f2a0a
am: 284d10d112
Change-Id: I52f03ddd0686125263bc0c5e59bcc2355b7cca72
This commit is contained in:
@@ -25,6 +25,7 @@ import android.os.Message;
|
||||
import android.os.UserHandle;
|
||||
import android.preference.SeekBarVolumizer;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
|
||||
@@ -52,8 +53,22 @@ public class SoundSettings extends DashboardFragment {
|
||||
|
||||
private static final int SAMPLE_CUTOFF = 2000; // manually cap sample playback at 2 seconds
|
||||
|
||||
private final VolumePreferenceCallback mVolumeCallback = new VolumePreferenceCallback();
|
||||
private final H mHandler = new H();
|
||||
@VisibleForTesting
|
||||
static final int STOP_SAMPLE = 1;
|
||||
|
||||
@VisibleForTesting
|
||||
final VolumePreferenceCallback mVolumeCallback = new VolumePreferenceCallback();
|
||||
@VisibleForTesting
|
||||
final Handler mHandler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case STOP_SAMPLE:
|
||||
mVolumeCallback.stopSample();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private RingtonePreference mRequestPreference;
|
||||
|
||||
@@ -142,14 +157,17 @@ public class SoundSettings extends DashboardFragment {
|
||||
}
|
||||
mCurrent = sbv;
|
||||
if (mCurrent != null) {
|
||||
mHandler.removeMessages(H.STOP_SAMPLE);
|
||||
mHandler.sendEmptyMessageDelayed(H.STOP_SAMPLE, SAMPLE_CUTOFF);
|
||||
mHandler.removeMessages(STOP_SAMPLE);
|
||||
mHandler.sendEmptyMessageDelayed(STOP_SAMPLE, SAMPLE_CUTOFF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStreamValueChanged(int stream, int progress) {
|
||||
// noop
|
||||
if (mCurrent != null) {
|
||||
mHandler.removeMessages(STOP_SAMPLE);
|
||||
mHandler.sendEmptyMessageDelayed(STOP_SAMPLE, SAMPLE_CUTOFF);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopSample() {
|
||||
@@ -159,26 +177,6 @@ public class SoundSettings extends DashboardFragment {
|
||||
}
|
||||
}
|
||||
|
||||
// === Callbacks ===
|
||||
|
||||
|
||||
private final class H extends Handler {
|
||||
private static final int STOP_SAMPLE = 1;
|
||||
|
||||
private H() {
|
||||
super(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case STOP_SAMPLE:
|
||||
mVolumeCallback.stopSample();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
SoundSettings fragment, VolumeSeekBarPreference.Callback callback,
|
||||
Lifecycle lifecycle) {
|
||||
|
Reference in New Issue
Block a user