@SuppressLint("InlinedApi") private static boolean isHandledMediaKey(int keyCode) { return keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD || keyCode == KeyEvent.KEYCODE_MEDIA_REWIND || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE || keyCode == KeyEvent.KEYCODE_MEDIA_NEXT || keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS; }
@SuppressLint("InlinedApi") private boolean isDpadKey(int keyCode) { return keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_CENTER; }
@SuppressLint("NewApi") public AnimatedZoomJob(ViewPortHandler viewPortHandler, View v, Transformer trans, YAxis axis, float xAxisRange, float scaleX, float scaleY, float xOrigin, float yOrigin, float zoomCenterX, float zoomCenterY, float zoomOriginX, float zoomOriginY, long duration) { super(viewPortHandler, scaleX, scaleY, trans, v, xOrigin, yOrigin, duration); this.zoomCenterX = zoomCenterX; this.zoomCenterY = zoomCenterY; this.zoomOriginX = zoomOriginX; this.zoomOriginY = zoomOriginY; this.animator.addListener(this); this.yAxis = axis; this.xAxisRange = xAxisRange; }
@SuppressLint("NewApi") @Override public void run() { animator.start(); }
@SuppressLint("StaticFieldLeak") void startAsyncWork() { // This runnable is an anonymous class and therefore has a hidden reference to the outer // class MainActivity. If the activity gets destroyed before the thread finishes (e.g. rotation), // the activity instance will leak. Runnable work = new Runnable() { @Override public void run() { // Do some slow work in background SystemClock.sleep(20000); } }; new Thread(work).start(); } }
@VisibleForTesting @SuppressLint("ValidFragment") RequestManagerFragment(@NonNull ActivityFragmentLifecycle lifecycle) { this.lifecycle = lifecycle; }
@VisibleForTesting @SuppressLint("ValidFragment") public SupportRequestManagerFragment(@NonNull ActivityFragmentLifecycle lifecycle) { this.lifecycle = lifecycle; }
@SuppressLint("CheckResult") @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") protected RequestBuilder(Class<TranscodeType> transcodeClass, RequestBuilder<?> other) { this(other.glide, other.requestManager, transcodeClass, other.context); model = other.model; isModelSet = other.isModelSet; // This is safe because it will always mutate, no one else has access to the object. apply(other); }
@SuppressWarnings("unchecked") // addListener always returns the same instance. @SuppressLint("CheckResult") private void initRequestListeners(List<RequestListener<Object>> requestListeners) { for (RequestListener<Object> listener : requestListeners) { addListener((RequestListener<TranscodeType>) listener); } }
@SuppressLint("HandlerLeak") class EventPostHandler extends Handler { public EventPostHandler(Looper looper) { super(looper); } @Override public void handleMessage(Message msg) { eventBus.post(msg.obj); } void post(Object event) { sendMessage(obtainMessage(0, event)); } }
public MoreDetailsView(Context context, AttributeSet attrs) { super(context, attrs); Resources resources = getResources(); iconPaint = new Paint(Paint.ANTI_ALIAS_FLAG); float strokeSize = resources.getDimensionPixelSize(R.dimen.leak_canary_more_stroke_width); iconPaint.setStrokeWidth(strokeSize); // This lint check doesn't work for libraries which have a common prefix. @SuppressLint("CustomViewStyleable") // TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.leak_canary_MoreDetailsView); int plusColor = a.getColor(R.styleable.leak_canary_MoreDetailsView_leak_canary_plus_color, Color.BLACK); a.recycle(); iconPaint.setColor(plusColor); }
@SuppressLint("InlinedApi") /* package */ static AudioCapabilities getCapabilities(@Nullable Intent intent) { if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { return DEFAULT_AUDIO_CAPABILITIES; } return new AudioCapabilities( intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS), intent.getIntExtra( AudioManager.EXTRA_MAX_CHANNEL_COUNT, /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT)); }
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent event) { return inTouchableArea(event.getX(), event.getY()) && super.onTouchEvent(event); }
@SuppressLint("WrongConstant") private void saveLayerCompat(Canvas canvas, RectF rect, Paint paint, boolean all) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { // This method was deprecated in API level 26 and not recommended since 22, but its // 2-parameter replacement is only available starting at API level 21. canvas.saveLayer(rect, paint, all ? Canvas.ALL_SAVE_FLAG : SAVE_FLAGS); } else { canvas.saveLayer(rect, paint); } }
/** * Original method view.postInvalidateOnAnimation() only supportd in API >= * 16, This is a replica of the code from ViewCompat. * * @param view */ @SuppressLint("NewApi") public static void postInvalidateOnAnimation(View view) { if (Build.VERSION.SDK_INT >= 16) view.postInvalidateOnAnimation(); else view.postInvalidateDelayed(10); }
@SuppressLint("InlinedApi") @Override public void trimMemory(int level) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "trimMemory, level=" + level); } if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) { clearMemory(); } else if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN || level == android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) { trimToSize(getMaxSize() / 2); } }
@RequiresApi(28) @SuppressLint("Override") private static Bitmap decodeStreamP(Request request, BufferedSource bufferedSource) throws IOException { ImageDecoder.Source imageSource = ImageDecoder.createSource(ByteBuffer.wrap(bufferedSource.readByteArray())); return decodeImageSource(imageSource, request); }
@SuppressLint("InlinedApi") @Override public void trimMemory(int level) { if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) { // Entering list of cached background apps // Evict our entire bitmap cache clearMemory(); } else if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN || level == android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) { // The app's UI is no longer visible, or app is in the foreground but system is running // critically low on memory // Evict oldest half of our bitmap cache trimToSize(getMaxSize() / 2); } } }
@SuppressLint("CheckResult") @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") protected RequestBuilder( @NonNull Glide glide, RequestManager requestManager, Class<TranscodeType> transcodeClass, Context context) { this.glide = glide; this.requestManager = requestManager; this.transcodeClass = transcodeClass; this.context = context; this.transitionOptions = requestManager.getDefaultTransitionOptions(transcodeClass); this.glideContext = glide.getGlideContext(); initRequestListeners(requestManager.getDefaultRequestListeners()); apply(requestManager.getDefaultRequestOptions()); }
@SuppressLint("InlinedApi") @Test public void testConstants() { // Sanity check that constant values match those defined by the platform. assertThat(C.BUFFER_FLAG_KEY_FRAME).isEqualTo(MediaCodec.BUFFER_FLAG_KEY_FRAME); assertThat(C.BUFFER_FLAG_END_OF_STREAM).isEqualTo(MediaCodec.BUFFER_FLAG_END_OF_STREAM); assertThat(C.CRYPTO_MODE_AES_CTR).isEqualTo(MediaCodec.CRYPTO_MODE_AES_CTR); }