mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Daily arc lint --take GOOGLEJAVAFORMAT
Summary: Changelog: [Internal] Reviewed By: zertosh Differential Revision: D20027840 fbshipit-source-id: 94501d8aadf271d3a10e1bd5b1a254e1e3914d7b
This commit is contained in:
committed by
Facebook Github Bot
parent
dd9832c400
commit
c18fa702fb
@@ -16,9 +16,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.SoftAssertions;
|
||||
@@ -47,7 +45,7 @@ public class ReactDrawableHelper {
|
||||
}
|
||||
if (!context.getTheme().resolveAttribute(attrID, sResolveOutValue, true)) {
|
||||
throw new JSApplicationIllegalArgumentException(
|
||||
"Attribute " + attr + " couldn't be resolved into a drawable");
|
||||
"Attribute " + attr + " couldn't be resolved into a drawable");
|
||||
}
|
||||
Drawable drawable = getDefaultThemeDrawable(context);
|
||||
return setRadius(drawableDescriptionDict, drawable);
|
||||
@@ -61,18 +59,17 @@ public class ReactDrawableHelper {
|
||||
|
||||
private static Drawable getDefaultThemeDrawable(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
return context
|
||||
.getResources()
|
||||
.getDrawable(sResolveOutValue.resourceId, context.getTheme());
|
||||
return context.getResources().getDrawable(sResolveOutValue.resourceId, context.getTheme());
|
||||
} else {
|
||||
return context.getResources().getDrawable(sResolveOutValue.resourceId);
|
||||
}
|
||||
}
|
||||
|
||||
private static RippleDrawable getRippleDrawable(Context context, ReadableMap drawableDescriptionDict) {
|
||||
private static RippleDrawable getRippleDrawable(
|
||||
Context context, ReadableMap drawableDescriptionDict) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
throw new JSApplicationIllegalArgumentException(
|
||||
"Ripple drawable is not available on " + "android API <21");
|
||||
"Ripple drawable is not available on " + "android API <21");
|
||||
}
|
||||
int color = getColor(context, drawableDescriptionDict);
|
||||
Drawable mask = getMask(drawableDescriptionDict);
|
||||
@@ -84,8 +81,8 @@ public class ReactDrawableHelper {
|
||||
|
||||
private static Drawable setRadius(ReadableMap drawableDescriptionDict, Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& drawableDescriptionDict.hasKey("rippleRadius")
|
||||
&& drawable instanceof RippleDrawable) {
|
||||
&& drawableDescriptionDict.hasKey("rippleRadius")
|
||||
&& drawable instanceof RippleDrawable) {
|
||||
RippleDrawable rippleDrawable = (RippleDrawable) drawable;
|
||||
double rippleRadius = drawableDescriptionDict.getDouble("rippleRadius");
|
||||
rippleDrawable.setRadius((int) PixelUtil.toPixelFromDIP(rippleRadius));
|
||||
@@ -95,16 +92,16 @@ public class ReactDrawableHelper {
|
||||
|
||||
private static int getColor(Context context, ReadableMap drawableDescriptionDict) {
|
||||
if (drawableDescriptionDict.hasKey(ViewProps.COLOR)
|
||||
&& !drawableDescriptionDict.isNull(ViewProps.COLOR)) {
|
||||
&& !drawableDescriptionDict.isNull(ViewProps.COLOR)) {
|
||||
return drawableDescriptionDict.getInt(ViewProps.COLOR);
|
||||
} else {
|
||||
if (context
|
||||
.getTheme()
|
||||
.resolveAttribute(android.R.attr.colorControlHighlight, sResolveOutValue, true)) {
|
||||
.getTheme()
|
||||
.resolveAttribute(android.R.attr.colorControlHighlight, sResolveOutValue, true)) {
|
||||
return context.getResources().getColor(sResolveOutValue.resourceId);
|
||||
} else {
|
||||
throw new JSApplicationIllegalArgumentException(
|
||||
"Attribute colorControlHighlight " + "couldn't be resolved into a drawable");
|
||||
"Attribute colorControlHighlight " + "couldn't be resolved into a drawable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user