OSDN Git Service

Fix issues with wrong configuration being used to inflate layouts.
authorAnna Galusza <agalusza@google.com>
Mon, 21 Mar 2016 18:42:34 +0000 (11:42 -0700)
committerAnna Galusza <agalusza@google.com>
Mon, 21 Mar 2016 18:42:34 +0000 (11:42 -0700)
Bug: 27700406

Change-Id: I646e21b513ffe4b340769dcac6cb5537535ee432

src/com/android/settings/PreviewPagerAdapter.java

index 8032f92..68dc71f 100644 (file)
@@ -47,6 +47,10 @@ public class PreviewPagerAdapter extends PagerAdapter {
                                Configuration[] configurations) {
         mPreviewFrames = new TouchBlockingFrameLayout[previewSampleResIds.length];
 
+        // We need to get the copy of the original configuration before we call
+        // createConfigurationContext() as that call changes the current configuration for the App.
+        final Configuration origConfig = context.getResources().getConfiguration();
+
         for (int i = 0; i < previewSampleResIds.length; ++i) {
             mPreviewFrames[i] = (TouchBlockingFrameLayout) LayoutInflater.from(context)
                     .inflate(R.layout.preview_frame_container, null);
@@ -69,6 +73,10 @@ public class PreviewPagerAdapter extends PagerAdapter {
                 mPreviewFrames[i].addView(sampleView);
             }
         }
+
+        // Create a context with the original App configuration since the last configuration passed
+        // to createConfigurationContext() becomes the configuration for any new views inflated.
+        context.createConfigurationContext(origConfig);
     }
 
     @Override