Settings: Make SeekBarVolumizer more null-resilient.

Now that the instances are reusable, ensure all "post" methods
do a handler check, and ensure they are all internal.

Bug: 18063070
Change-Id: Idc478c636686f666f5656f3d07bf2738ba3e9a5a
This commit is contained in:
John Spurlock
2014-10-21 14:23:24 -04:00
parent a9a550dd8e
commit 735f9ebc18
2 changed files with 6 additions and 3 deletions

View File

@@ -130,6 +130,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
}
private void postStartSample() {
if (mHandler == null) return;
mHandler.removeMessages(MSG_START_SAMPLE);
mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_START_SAMPLE),
isSamplePlaying() ? CHECK_RINGTONE_PLAYBACK_DELAY_MS : 0);
@@ -150,7 +151,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
}
}
void postStopSample() {
private void postStopSample() {
if (mHandler == null) return;
// remove pending delayed start messages
mHandler.removeMessages(MSG_START_SAMPLE);
mHandler.removeMessages(MSG_STOP_SAMPLE);
@@ -200,7 +202,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
postSetVolume(progress);
}
void postSetVolume(int progress) {
private void postSetVolume(int progress) {
if (mHandler == null) return;
// Do the volume changing separately to give responsive UI
mLastProgress = progress;
mHandler.removeMessages(MSG_SET_STREAM_VOLUME);

View File

@@ -117,7 +117,7 @@ public class VolumePreference extends SeekBarDialogPreference implements
public void onActivityStop() {
if (mSeekBarVolumizer != null) {
mSeekBarVolumizer.postStopSample();
mSeekBarVolumizer.stopSample();
}
}