OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.content.ComponentCallbacks; | 8 import android.content.ComponentCallbacks; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.res.Configuration; | 10 import android.content.res.Configuration; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 ThreadUtils.assertOnUiThread(); | 224 ThreadUtils.assertOnUiThread(); |
225 | 225 |
226 if (sInstance == null) { | 226 if (sInstance == null) { |
227 sInstance = new ScreenOrientationListener(); | 227 sInstance = new ScreenOrientationListener(); |
228 } | 228 } |
229 | 229 |
230 return sInstance; | 230 return sInstance; |
231 } | 231 } |
232 | 232 |
233 private ScreenOrientationListener() { | 233 private ScreenOrientationListener() { |
234 mBackend = Build.VERSION.SDK_INT >= 17 ? | 234 mBackend = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 |
235 new ScreenOrientationDisplayListener() : | 235 ? new ScreenOrientationDisplayListener() |
236 new ScreenOrientationConfigurationListener(); | 236 : new ScreenOrientationConfigurationListener(); |
237 } | 237 } |
238 | 238 |
239 /** | 239 /** |
240 * Add |observer| in the ScreenOrientationListener observer list and | 240 * Add |observer| in the ScreenOrientationListener observer list and |
241 * immediately call |onScreenOrientationChanged| on it with the current | 241 * immediately call |onScreenOrientationChanged| on it with the current |
242 * orientation value. | 242 * orientation value. |
243 * | 243 * |
244 * @param observer The observer that will get notified. | 244 * @param observer The observer that will get notified. |
245 * @param context The context associated with this observer. | 245 * @param context The context associated with this observer. |
246 */ | 246 */ |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 break; | 347 break; |
348 case Surface.ROTATION_270: | 348 case Surface.ROTATION_270: |
349 mOrientation = -90; | 349 mOrientation = -90; |
350 break; | 350 break; |
351 default: | 351 default: |
352 throw new IllegalStateException( | 352 throw new IllegalStateException( |
353 "Display.getRotation() shouldn't return that value"); | 353 "Display.getRotation() shouldn't return that value"); |
354 } | 354 } |
355 } | 355 } |
356 } | 356 } |
OLD | NEW |