Debian Codegraph @

apps/SdkController/src/com/android/tools/sdkcontroller/utils/ApiHelper.java

raw
1 /*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17 package com.android.tools.sdkcontroller.utils;
18
19 import android.annotation.TargetApi;
20 import android.os.Build;
21 import android.view.View;
22
23 /**
24 * Helper to deal with methods only available at certain API levels.
25 * Users should get use {@link ApiHelper#get()} to retrieve a singleton
26 * and then call the methods they desire. If the method is not available
27 * on the current API level, a stub or a nop will be used instead.
28 */
29 @TargetApi(7)
30 public class ApiHelper {
31
32 private static ApiHelper sApiHelper = null;
33
34 /** Creates a new ApiHelper adapted to the current runtime API level. */
35 public static ApiHelper get() {
36 if (sApiHelper == null) {
37 if (Build.VERSION.SDK_INT >= 11) {
38 sApiHelper = new ApiHelper_11();
39 } else {
40 sApiHelper = new ApiHelper();
41 }
42 }
43
44 return sApiHelper;
45 }
46
47 protected ApiHelper() {
48 }
49
50 /**
51 * Applies {@link View#setSystemUiVisibility(int)}, available only starting with API 11.
52 * Does nothing for API < 11.
53 */
54 public void View_setSystemUiVisibility(View view, int visibility) {
55 // nop
56 }
57 }