Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated setBackgroundDrawable use #23261

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,20 @@
package com.facebook.react.views.common;

import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;

/** Helper class for Views */
public class ViewHelper {

/**
* Set the background to a given Drawable, or remove the background. It calls {@link
* View#setBackground(Drawable)} or {@link View#setBackgroundDrawable(Drawable)} based on the sdk
* version.
* View#setBackground(Drawable)}.
*
* @param view {@link View} to apply the background.
* @param drawable {@link Drawable} The Drawable to use as the background, or null to remove the
* background
*/
public static void setBackground(View view, Drawable drawable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setBackground(drawable);
} else {
view.setBackgroundDrawable(drawable);
}
view.setBackground(drawable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -668,17 +668,13 @@ public void setOverflow(String overflow) {

/**
* Set the background for the view or remove the background. It calls {@link
* #setBackground(Drawable)} or {@link #setBackgroundDrawable(Drawable)} based on the sdk version.
* #setBackground(Drawable)}.
*
* @param drawable {@link Drawable} The Drawable to use as the background, or null to remove the
* background
*/
private void updateBackgroundDrawable(Drawable drawable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
super.setBackground(drawable);
} else {
super.setBackgroundDrawable(drawable);
}
super.setBackground(drawable);
}

@Override
Expand Down