From 981b14fd4afc0b9151bb5c781aa8b4d93ad95fb6 Mon Sep 17 00:00:00 2001 From: KalimochoAz Date: Tue, 7 Feb 2012 21:34:44 -0500 Subject: Fix restoring color multipliers --- .../settings/device/ColorTuningPreference.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'CrespoParts/src') diff --git a/CrespoParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java b/CrespoParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java index 6db5bb0..085cae7 100644 --- a/CrespoParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java +++ b/CrespoParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java @@ -25,6 +25,7 @@ import android.util.AttributeSet; import android.view.View; import android.widget.SeekBar; import android.widget.TextView; +import android.util.Log; /** * Special preference type that allows configuration of both the ring volume and @@ -104,20 +105,28 @@ public class ColorTuningPreference extends DialogPreference { * @param context The context to read the SharedPreferences from */ public static void restore(Context context) { + int iValue, iValue2; if (!isSupported()) { return; } SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); for (String filePath : FILE_PATH) { - int iValue; String sDefaultValue = Utils.readOneLine(filePath); + Log.d(TAG,"INIT: " + sDefaultValue); + try { + iValue2 = Integer.parseInt(sDefaultValue); + } catch (NumberFormatException e) { + iValue2 = MAX_VALUE; + } try { - iValue = sharedPrefs.getInt(filePath, Integer.parseInt(sDefaultValue)); + iValue = sharedPrefs.getInt(filePath, iValue2); + Log.d(TAG, "restore: iValue: " + iValue + " File: " + filePath); } catch (NumberFormatException e) { - iValue = MAX_VALUE; + iValue = iValue2; + Log.e(TAG, "restore ERROR: iValue: " + iValue + " File: " + filePath); } - Utils.writeColor(filePath, iValue); + Utils.writeColor(filePath, (int) iValue); } } -- cgit v1.1