/** * {@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); } }
private void postOnAnimation(View view, Runnable runnable) { if (Build.VERSION.SDK_INT >= 16) { view.postOnAnimation(runnable); } else { view.postDelayed(runnable, 16L); } }
@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); } }
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 } }
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; }
@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); } } } }
/** * 获取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; }
@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(); } }
@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); }
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) }; } }
@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(); } }
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); } }
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; }
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); } } }
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; }
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(); }
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(); }
@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); }
/** * 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; }
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; }
/** * 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; }
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; }
@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); }
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) { } } } }
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) { } }
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; }
/** * 判断手机支不支持状态栏变色 * 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; }
@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); }
/** * 透明导航栏 * * @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); } }
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); } }
@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); }
@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); } }
@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); }
@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); } }
@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(); }
/** * 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; } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void drawableHotspotChanged(float x, float y) { super.drawableHotspotChanged(x, y); if (mForegroundSelector != null) { mForegroundSelector.setHotspot(x, y); } }
/** * 为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); } }
/** * 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); } }