OSDN Git Service

Use SharedPreferences$Editor.apply to reduce latency.
authorWu-cheng Li <wuchengli@google.com>
Wed, 8 Sep 2010 18:12:43 +0000 (11:12 -0700)
committerWu-cheng Li <wuchengli@google.com>
Wed, 8 Sep 2010 18:23:22 +0000 (11:23 -0700)
Replace all commit with apply.
bug:2978683
Change-Id: I6c057fab588aada7c35d03f6237fb850d2a2e856

src/com/android/camera/Camera.java
src/com/android/camera/CameraSettings.java
src/com/android/camera/ui/HeadUpDisplay.java

index 565b537..61c66d1 100644 (file)
@@ -278,7 +278,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
         if (!CameraSettings.EXPOSURE_DEFAULT_VALUE.equals(value)) {
             Editor editor = mPreferences.edit();
             editor.putString(CameraSettings.KEY_EXPOSURE, "0");
-            editor.commit();
+            editor.apply();
             if (mHeadUpDisplay != null) {
                 mHeadUpDisplay.reloadPreferences();
             }
index 3bebb93..29eb187 100644 (file)
@@ -100,7 +100,7 @@ public class CameraSettings {
                 SharedPreferences.Editor editor = ComboPreferences
                         .get(context).edit();
                 editor.putString(KEY_PICTURE_SIZE, candidate);
-                editor.commit();
+                editor.apply();
                 return;
             }
         }
@@ -272,7 +272,7 @@ public class CameraSettings {
         if (version == CURRENT_LOCAL_VERSION) return;
         SharedPreferences.Editor editor = pref.edit();
         editor.putInt(KEY_LOCAL_VERSION, CURRENT_LOCAL_VERSION);
-        editor.commit();
+        editor.apply();
     }
 
     public static void upgradeGlobalPreferences(SharedPreferences pref) {
@@ -317,7 +317,7 @@ public class CameraSettings {
             editor.remove("pref_camera_video_duration_key");
         }
         editor.putInt(KEY_VERSION, CURRENT_VERSION);
-        editor.commit();
+        editor.apply();
     }
 
     public static void upgradeAllPreferences(ComboPreferences pref) {
@@ -347,6 +347,6 @@ public class CameraSettings {
             int cameraId) {
         Editor editor = pref.edit();
         editor.putInt(KEY_CAMERA_ID, cameraId);
-        editor.commit();
+        editor.apply();
     }
 }
index 98e885e..05d575d 100644 (file)
@@ -405,7 +405,7 @@ public class HeadUpDisplay extends GLView {
         Context context = getGLRootView().getContext();
         Editor editor = mSharedPrefs.edit();
         editor.clear();
-        editor.commit();
+        editor.apply();
         CameraSettings.upgradeAllPreferences(mSharedPrefs);
         CameraSettings.initialCameraPictureSize(context, param);
         reloadPreferences();