Reduce jank on 'touch sounds' switch.
Bug: 23360053 Change-Id: Iec47e1464cfa0bd53f40977f7fa58c37dd635853
This commit is contained in:
@@ -25,6 +25,7 @@ import android.content.res.Resources;
|
|||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
@@ -92,13 +93,19 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
|
|||||||
private static final SettingPref PREF_TOUCH_SOUNDS = new SettingPref(
|
private static final SettingPref PREF_TOUCH_SOUNDS = new SettingPref(
|
||||||
TYPE_SYSTEM, KEY_TOUCH_SOUNDS, System.SOUND_EFFECTS_ENABLED, DEFAULT_ON) {
|
TYPE_SYSTEM, KEY_TOUCH_SOUNDS, System.SOUND_EFFECTS_ENABLED, DEFAULT_ON) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean setSetting(Context context, int value) {
|
protected boolean setSetting(final Context context, final int value) {
|
||||||
final AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
AsyncTask.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final AudioManager am =
|
||||||
|
(AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
if (value != 0) {
|
if (value != 0) {
|
||||||
am.loadSoundEffects();
|
am.loadSoundEffects();
|
||||||
} else {
|
} else {
|
||||||
am.unloadSoundEffects();
|
am.unloadSoundEffects();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return super.setSetting(context, value);
|
return super.setSetting(context, value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user