Java 类android.os.Build 实例源码

项目:RelativeRadioGroup    文件:RelativeRadioGroup.java   
/**
 * {@inheritDoc}
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onChildViewAdded(View parent, View child) {
    if (parent == RelativeRadioGroup.this && child instanceof RadioButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = View.generateViewId();
            child.setId(id);
        }
        ((RadioButton) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
项目:PicKing    文件:Attacher.java   
private void postOnAnimation(View view, Runnable runnable) {
    if (Build.VERSION.SDK_INT >= 16) {
        view.postOnAnimation(runnable);
    } else {
        view.postDelayed(runnable, 16L);
    }
}
项目:webtrekk-android-sdk    文件:WebtrekkBaseSDKTest.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
static public void finishActivitySync(Activity activity, Instrumentation instrumentation, boolean doFinish)
{
    if (doFinish)
        activity.finish();
    //give activity one minute to finish
    long currentTime = System.currentTimeMillis();
    boolean finishTimeout = false;
    int activityHash = activity.hashCode();
    boolean isDestroyed = false;

    while (!isDestroyed && !finishTimeout) {
        instrumentation.waitForIdleSync();
        finishTimeout = (System.currentTimeMillis() - currentTime) > 140000;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            isDestroyed = activity.isDestroyed();
        }else {
            isDestroyed = (Boolean)callMethod(null, activity.getWindow(), "isDestroyed", null);
        }
    }

    if (finishTimeout) {
        WebtrekkLogging.log("finishActivitySync: finished by timeout. Hash:" + activityHash);
    }
}
项目:container    文件:RemoteViewsUtils.java   
private void init(Context context) {
    if (notification_panel_width == 0) {
        Context systemUi = null;
        try {
            systemUi = context.createPackageContext("com.android.systemui", Context.CONTEXT_IGNORE_SECURITY);
        } catch (PackageManager.NameNotFoundException e) {
        }
        if (Build.VERSION.SDK_INT <= 19) {
            notification_side_padding = 0;
        } else {
            notification_side_padding = getDimem(context, systemUi, "notification_side_padding",
                    R.dimen.notification_side_padding);
        }
        notification_panel_width = getDimem(context, systemUi, "notification_panel_width",
                R.dimen.notification_panel_width);
        if (notification_panel_width <= 0) {
            notification_panel_width = context.getResources().getDisplayMetrics().widthPixels;
        }
        notification_min_height = getDimem(context, systemUi, "notification_min_height",
                R.dimen.notification_min_height);
        // getDimem(context, systemUi, "notification_row_min_height", 0);
        // if (notification_min_height == 0) {
        // notification_min_height =
        // }
        notification_max_height = getDimem(context, systemUi, "notification_max_height",
                R.dimen.notification_max_height);
        notification_mid_height = getDimem(context, systemUi, "notification_mid_height",
                R.dimen.notification_mid_height);
        notification_padding = getDimem(context, systemUi, "notification_padding", R.dimen.notification_padding);
        // notification_collapse_second_card_padding
    }
}
项目:GitHub    文件:VersionedGestureDetector.java   
public static GestureDetector newInstance(Context context,
                                          OnGestureListener listener) {
    final int sdkVersion = Build.VERSION.SDK_INT;
    GestureDetector detector;

    if (sdkVersion < Build.VERSION_CODES.ECLAIR) {
        detector = new CupcakeGestureDetector(context);
    } else if (sdkVersion < Build.VERSION_CODES.FROYO) {
        detector = new EclairGestureDetector(context);
    } else {
        detector = new FroyoGestureDetector(context);
    }

    detector.setOnGestureListener(listener);

    return detector;
}
项目:BuddyBook    文件:InsertEditBookActivity.java   
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onRequestPermissionsResult(int requestCode,
                                       @NonNull String[] permissions,
                                       @NonNull int[] grantResults) {

    if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
        if (requestCode == RC_HANDLE_WRITE_PERM) {
            callPickPhoto();
        } else if (requestCode == RC_CAMERA_PERM) {

            int rc = ActivityCompat.checkSelfPermission(mContext, Manifest.permission.WRITE_EXTERNAL_STORAGE);
            if (rc == PackageManager.PERMISSION_GRANTED) {
                callCamera();
            } else {
                requestWriteExternalStoragePermission(RC_CAMERA_PERM);
            }
        }
    }
}
项目:EvolvingNetLib    文件:SDCardUtil.java   
/**
 * 获取SD卡全部内存空间大小
 *
 * @return
 */
public static long getSDCardSize() {
    long blockCount;
    long blockSize;

    if (isSDCardMounted()) {
        String dir = getSDCardBaseDir();
        //StatFs是从C语言引过来的
        StatFs statFs = new StatFs(dir);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            blockCount = statFs.getBlockCountLong();//有多少块
            blockSize = statFs.getBlockSizeLong();//每块有多大
        } else {
            blockCount = statFs.getBlockCount();//有多少块
            blockSize = statFs.getBlockSize();//每块有多大
        }

        return blockCount * blockSize / 1024 / 1024; //总大小
    }
    return 0;
}
项目:VirtualHook    文件:VPackageManagerService.java   
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ActivityInfo ai = getActivityInfo(comp, flags, userId);
        if (ai != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }

    // reader
    synchronized (mPackages) {
        final String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mActivities.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId);
        }
        return Collections.emptyList();
    }
}
项目:mobile-app-dev-book    文件:AudioActivity.java   
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == AUDIO_PERMISSION_REQUEST && permissions[0]
            .equals(android.Manifest.permission.RECORD_AUDIO)) {
        if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                boolean showAgain =
                        shouldShowRequestPermissionRationale
                                (android.Manifest.permission.RECORD_AUDIO);
                if (showAgain) {

                }
            }
            finish(); // can't use audio
        }
    } else
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
项目:atlas    文件:Framework.java   
public static File[] getExternalFilesDirs(Context context, String type) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 19) {
        //返回结果可能存在null值
        return context.getExternalFilesDirs(type);
    } else {
        return new File[] { context.getExternalFilesDir(type) };
    }
}
项目:simple-share-android    文件:AsyncTaskLoader.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
void dispatchOnCancelled(LoadTask task, D data) {
    onCanceled(data);
    if (mCancellingTask == task) {
        if (DEBUG) Log.v(TAG, "Cancelled task is now canceled!");
        if(Utils.hasJellyBeanMR2()){
            rollbackContentChanged();
        }
        mLastLoadCompleteTime = SystemClock.uptimeMillis();
        mCancellingTask = null;
        if (DEBUG) Log.v(TAG, "Delivering cancellation");
        if(Utils.hasJellyBeanMR2()){
            deliverCancellation();
        }
        executePendingTask();
    }
}
项目:rebase-android    文件:ScrollAwareFABBehavior.java   
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button)
            .scaleX(1.0F)
            .scaleY(1.0F)
            .alpha(1.0F)
            .setInterpolator(INTERPOLATOR)
            .withLayer()
            .setListener(null)
            .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
            android.support.design.R.anim.design_fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}
项目:RLibrary    文件:PlatformSupportManager.java   
public final T build() {
    for (Integer minVersion : implementations.keySet()) {
        if (Build.VERSION.SDK_INT >= minVersion) {
            String className = implementations.get(minVersion);
            try {
                Class<? extends T> clazz = Class.forName(className).asSubclass(managedInterface);
                Log.i(TAG, "Using implementation " + clazz + " of " + managedInterface + " for SDK " + minVersion);
                return clazz.getConstructor().newInstance();
            } catch (ClassNotFoundException cnfe) {
                Log.w(TAG, cnfe);
            } catch (IllegalAccessException iae) {
                Log.w(TAG, iae);
            } catch (InstantiationException ie) {
                Log.w(TAG, ie);
            } catch (NoSuchMethodException nsme) {
                Log.w(TAG, nsme);
            } catch (InvocationTargetException ite) {
                Log.w(TAG, ite);
            }
        }
    }
    Log.i(TAG, "Using default implementation " + defaultImplementation.getClass() + " of " + managedInterface);
    return defaultImplementation;
}
项目:letv    文件:CrashHandler.java   
public void collectCrashDeviceInfo(Context ctx) {
    try {
        PackageInfo pi = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 1);
        if (pi != null) {
            this.mDeviceCrashInfo.put(VERSION_NAME, pi.versionName == null ? "not set" : pi.versionName);
            this.mDeviceCrashInfo.put(VERSION_CODE, pi.versionCode + "");
        }
    } catch (NameNotFoundException e) {
        LogInfo.log(TAG, "Error while collect package info" + e);
    }
    for (Field field : Build.class.getDeclaredFields()) {
        try {
            field.setAccessible(true);
            this.mDeviceCrashInfo.put(field.getName(), field.get(null).toString());
            LogInfo.log(TAG, field.getName() + " : " + field.get(null));
        } catch (Exception e2) {
            LogInfo.log(TAG, "Error while collect crash info" + e2);
        }
    }
}
项目:TPlayer    文件:NotificationCompatCompatV21.java   
private ApplicationInfo getApplicationInfo(Notification notification) {
    ApplicationInfo ai = getApplicationInfo(notification.tickerView);
    if (ai != null) {
        return ai;
    }
    ai = getApplicationInfo(notification.contentView);
    if (ai != null) {
        return ai;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        ai = getApplicationInfo(notification.bigContentView);
        if (ai != null) {
            return ai;
        }
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ai = getApplicationInfo(notification.headsUpContentView);
        if (ai != null) {
            return ai;
        }
    }
    return null;
}
项目:Lunary-Ethereum-Wallet    文件:Dialogs.java   
public static void noImportWalletsFound(Context c) {
    AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT >= 24) // Otherwise buttons on 7.0+ are nearly invisible
        builder = new AlertDialog.Builder(c, R.style.AlertDialogTheme);
    else
        builder = new AlertDialog.Builder(c);
    builder.setTitle(R.string.dialog_no_wallets_found);
    builder.setMessage(R.string.dialog_no_wallets_found_text);
    builder.setNeutralButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}
项目:DereHelper    文件:MainActivity.java   
private void askRestart(){
    SweetAlertDialog sweetAlertDialog = new SweetAlertDialog(mContext, SweetAlertDialog.WARNING_TYPE)
            .setTitleText(getString(R.string.locale_changed))
            .setContentText(getString(R.string.locale_changed_need_restart))
            .setConfirmText("OK")
            .setConfirmClickListener(dialog -> {
                Intent intent = getBaseContext().getPackageManager()
                        .getLaunchIntentForPackage(getBaseContext().getPackageName());
                PendingIntent restartIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT);
                AlarmManager mgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
                if(Build.VERSION.SDK_INT < 19){
                    mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 500, restartIntent);
                }else{
                    mgr.setExact(AlarmManager.RTC, System.currentTimeMillis() + 500, restartIntent);
                }
                System.exit(0);
            });
    sweetAlertDialog.setCancelable(false);
    sweetAlertDialog.show();
}
项目:TPlayer    文件:MethodProxies.java   
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    IInterface caller = (IInterface) args[0];
    IBinder token = (IBinder) args[1];
    Intent service = (Intent) args[2];
    String resolvedType = (String) args[3];
    IServiceConnection conn = (IServiceConnection) args[4];
    int flags = (int) args[5];
    int userId = VUserHandle.myUserId();
    if (isServerProcess()) {
        userId = service.getIntExtra("_VA_|_user_id_", VUserHandle.USER_NULL);
    }
    if (userId == VUserHandle.USER_NULL) {
        return method.invoke(who, args);
    }
    ServiceInfo serviceInfo = VirtualCore.get().resolveServiceInfo(service, userId);
    if (serviceInfo != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            service.setComponent(new ComponentName(serviceInfo.packageName, serviceInfo.name));
        }
        conn = ServiceConnectionDelegate.getDelegate(conn);
        return VActivityManager.get().bindService(caller.asBinder(), token, service, resolvedType,
                conn, flags, userId);
    }
    return method.invoke(who, args);
}
项目:LiuAGeAndroid    文件:CustomViewAbove.java   
/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = arrowScroll(FOCUS_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = arrowScroll(FOCUS_RIGHT);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (Build.VERSION.SDK_INT >= 11) {
                // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
                // before Android 3.0. Ignore the tab key on those devices.
                if (KeyEventCompat.hasNoModifiers(event)) {
                    handled = arrowScroll(FOCUS_FORWARD);
                } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
                    handled = arrowScroll(FOCUS_BACKWARD);
                }
            }
            break;
        }
    }
    return handled;
}
项目:DebugOverlay-Android    文件:OverlayViewManager.java   
public static boolean canDrawOnSystemLayer(@NonNull Context context, int systemWindowType) {
    if (isSystemLayer(systemWindowType)) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
            return Settings.canDrawOverlays(context);
        } else if (systemWindowType == TYPE_TOAST) {
            // since 7.1.1, TYPE_TOAST is not usable since it auto-disappears
            // otherwise, just use it since it does not require any special permission
            return true;
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            return Settings.canDrawOverlays(context);
        } else {
            return hasSystemAlertPermission(context);
        }
    }
    return true;
}
项目:trust-wallet-android    文件:CameraSource.java   
/**
 * Sets camera auto-focus move callback.
 *
 * @param cb the callback to run
 * @return {@code true} if the operation is supported (i.e. from Jelly Bean), {@code false} otherwise
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public boolean setAutoFocusMoveCallback(@Nullable AutoFocusMoveCallback cb) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        return false;
    }

    synchronized (mCameraLock) {
        if (mCamera != null) {
            CameraAutoFocusMoveCallback autoFocusMoveCallback = null;
            if (cb != null) {
                autoFocusMoveCallback = new CameraAutoFocusMoveCallback();
                autoFocusMoveCallback.mDelegate = cb;
            }
            mCamera.setAutoFocusMoveCallback(autoFocusMoveCallback);
        }
    }

    return true;
}
项目:NotifyTools    文件:FloatView.java   
public WindowManager.LayoutParams createLayoutParams(int x,int y,int w,int h){
    WindowManager.LayoutParams params = new WindowManager.LayoutParams();

    if (Build.VERSION.SDK_INT >= 23)
        params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
    else
        params.type = WindowManager.LayoutParams.TYPE_TOAST;
    params.format = PixelFormat.RGBA_8888;
    params.flags =WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH ;

    params.gravity = Gravity.LEFT | Gravity.TOP;

    params.width = w;
    params.height = h;
    params.x = x;
    params.y = y;

    return params;

}
项目:TPlayer    文件:VPackageManagerService.java   
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ActivityInfo ai = getActivityInfo(comp, flags, userId);
        if (ai != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }

    // reader
    synchronized (mPackages) {
        final String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mActivities.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId);
        }
        return Collections.emptyList();
    }
}
项目:Udacity_Sunshine    文件:TodayWidgetIntentService.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private int getWidgetWidthFromOptions(AppWidgetManager appWidgetManager, int appWidgetId) {
    Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
    if (options.containsKey(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH)) {
        int minWidthDp = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
        // The width returned is in dp, but we'll convert it to pixels to match the other widths
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, minWidthDp,
                displayMetrics);
    }
    return  getResources().getDimensionPixelSize(R.dimen.widget_today_default_width);
}
项目:GCSApp    文件:LoginActivity.java   
public void doPower() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        String packageName = getPackageName();
        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        if (!pm.isIgnoringBatteryOptimizations(packageName)) {
            try {
                //some device doesn't has activity to handle this intent
                //so add try catch
                Intent intent = new Intent();
                intent.setAction(android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
                intent.setData(Uri.parse("package:" + packageName));
                startActivity(intent);
            } catch (Exception e) {
            }
        }
    }
}
项目:GCSApp    文件:CreateACActivity.java   
public void takePicture() {
    try {
        mPhotoPath = sdcardPath + "/icon.png";
        mPhotoFile = new File(mPhotoPath);
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        if (Build.VERSION.SDK_INT >= 23) {
            Uri uri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".provider", mPhotoFile);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);

        }else {

            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mPhotoFile));
        }
        startActivityForResult(intent, 1);
    } catch (Exception e) {
    }
}
项目:Lunary-Ethereum-Wallet    文件:ExternalStorageHandler.java   
public static boolean hasReadPermission(Context c) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (c.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
            return true;
        }
    } else {
        return true;
    }
    return false;
}
项目:Coder    文件:ImmersionBar.java   
/**
 * 判断手机支不支持状态栏变色
 * Is support status bar dark font boolean.
 *
 * @return the boolean
 */
public static boolean isSupportStatusBarDarkFont() {
    if (OSUtils.isMIUI6More() || OSUtils.isFlymeOS4More()
            || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)) {
        return true;
    } else
        return false;
}
项目:EasyAppleSyncAdapter    文件:AccountSettings.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public AccountSettings(@NonNull Context context, @NonNull Account account) throws InvalidAccountException {
    this.context = context;
    this.account = account;

    accountManager = AccountManager.get(context);
}
项目:TitleLayout    文件:ScreenUtil.java   
/**
 * 透明导航栏
 *
 * @param activity
 */
public static void setNavigationTranslucent(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //透明导航栏
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }
}
项目:fefereader    文件:Html.java   
public static Spanned fromHtml(String htmlText) {
    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        //noinspection deprecation
        return android.text.Html.fromHtml(htmlText);
    }
    else {
        return android.text.Html.fromHtml(htmlText, android.text.Html.FROM_HTML_MODE_COMPACT);
    }
}
项目:Linux-notifier-Android    文件:MainActivity.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();

    NetworkTools.getInstance(this);
    IOClass ioClass = IOClass.getInstance();
    ioClass.setContext(this.getApplicationContext());

    this.pingService = PingService.getInstance();
    this.communicatorThread = NetworkCommunicator.getInstance();
    this.deviceHandler = DeviceHandler.getInstance(this);
    this.sender = DiscoverySender.getInstance();
    this.receiver = DiscoveryReceiver.getInstance();

    startThreads();

    checkAndUpdatePermissions();

    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addOnItemTouchListener(new RecyclerViewTouchHandler(getApplicationContext(), recyclerView, new ClickListenerHandler()));
    recyclerViewAdapter = new RecyclerViewAdapter(deviceHandler.getDeviceList());
    recyclerView.setAdapter(recyclerViewAdapter);
}
项目:RLibrary    文件:BarUtils.java   
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int count = decorView.getChildCount();
    if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
        decorView.removeViewAt(count - 1);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
        rootView.setPadding(0, 0, 0, 0);
    }
}
项目:BTNotifierAndroid    文件:Message.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void writeNotificationLollipop(JsonWriter writer, Notification notification) throws IOException {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;
    }

    String category = notification.category;
    if (category != null) {
        writer.name("category").value(category);
    }
    writer.name("color").value(notification.color);
    writer.name("visibility").value(notification.visibility);
}
项目:androidgithub    文件:LinearBreadcrumbView.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setAlpha(View view, int alpha) {
    if (view instanceof ImageView && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        ((ImageView) view).setImageAlpha(alpha);
    } else {
        ViewCompat.setAlpha(view, alpha);
    }
}
项目:GitHub    文件:RealmJsonTests.java   
@Test
public void createObjectFromJson_streamNullClass() throws IOException {
    assumeThat(Build.VERSION.SDK_INT, greaterThanOrEqualTo(Build.VERSION_CODES.HONEYCOMB));

    InputStream in = TestHelper.loadJsonFromAssets(context, "array.json");
    realm.beginTransaction();
    assertNull(realm.createObjectFromJson(null, in));
    realm.commitTransaction();
    in.close();
}
项目:cwac-document    文件:DocumentFileCompat.java   
/**
 * Create a {@link DocumentFileCompat} representing the document tree rooted at
 * the given {@link Uri}. This is only useful on devices running
 * {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later, and will return
 * {@code null} when called on earlier platform versions.
 *
 * @param treeUri the {@link Intent#getData()} from a successful
 *            {@link Intent#ACTION_OPEN_DOCUMENT_TREE} request.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static DocumentFileCompat fromTreeUri(Context context, Uri treeUri) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 21) {
        return new TreeDocumentFile(null, context,
                DocumentsContractApi21.prepareTreeUri(treeUri));
    } else {
        return null;
    }
}
项目:Android-DFU-App    文件:ForegroundLinearLayout.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void drawableHotspotChanged(float x, float y) {
    super.drawableHotspotChanged(x, y);
    if (mForegroundSelector != null) {
        mForegroundSelector.setHotspot(x, y);
    }
}
项目:EasyAndroid    文件:BarTool.java   
/**
 * 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 * @param color        状态栏颜色值
 */
@Deprecated
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout,
                                               int color)
{
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 生成一个状态栏大小的矩形
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        if(contentLayout.getChildCount() > 0 && contentLayout
                .getChildAt(0) instanceof StatusBarView)
        {
            contentLayout.getChildAt(0).setBackgroundColor(
                    calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA));
        }
        else
        {
            // 添加 statusBarView 到布局中
            StatusBarView statusBarView = createStatusBarView(activity, color);
            contentLayout.addView(statusBarView, 0);
        }
        // 内容布局不是 LinearLayout 时,设置padding top
        if(!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null)
        {
            contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
        }
        // 设置属性
        ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
        drawerLayout.setFitsSystemWindows(false);
        contentLayout.setFitsSystemWindows(false);
        contentLayout.setClipToPadding(true);
        drawer.setFitsSystemWindows(false);
    }
}
项目:AndroidThings_RainbowHatDemo    文件:BoardDefaults.java   
/**
 * Return the GPIO pin that the LED is connected on.
 * For example, on Intel Edison Arduino breakout, pin "IO13" is connected to an onboard LED
 * that turns on when the GPIO pin is HIGH, and off when low.
 */
public static String getGPIOForRedLED() {
    switch (getBoardVariant()) {
        case DEVICE_EDISON_ARDUINO:
            return "IO13";
        case DEVICE_EDISON:
            return "GP45";
        case DEVICE_RPI3:
            return "BCM6";
        case DEVICE_NXP:
            return "GPIO4_IO20";
        default:
            throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
    }
}