Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 7b2052b

Browse files
committed
tests(aaptcompiler): fix NoClassDefFoundError error
1 parent 80d1aab commit 7b2052b

File tree

1 file changed

+38
-20
lines changed
  • subprojects/layoutlib-api/src/main/java/com/itsaky/androidide/layoutlib/resources

1 file changed

+38
-20
lines changed

subprojects/layoutlib-api/src/main/java/com/itsaky/androidide/layoutlib/resources/ResourceType.java

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@
2222
import com.google.common.base.Strings;
2323
import com.google.common.collect.ImmutableMap;
2424
import com.google.common.collect.ImmutableSet;
25-
import com.google.common.collect.Sets;
26-
27-
import org.w3c.dom.Element;
28-
import org.w3c.dom.Node;
29-
30-
import java.util.Arrays;
3125
import java.util.Collection;
3226
import java.util.function.BiFunction;
3327
import java.util.function.Function;
28+
import org.w3c.dom.Element;
29+
import org.w3c.dom.Node;
3430

3531
/**
3632
* Enum representing a type of compiled resource.
@@ -84,7 +80,9 @@ public enum ResourceType {
8480
*/
8581
OVERLAYABLE("overlayable", "Overlayable tag", Kind.SYNTHETIC),
8682

87-
/** Represents item tags inside a style definition. */
83+
/**
84+
* Represents item tags inside a style definition.
85+
*/
8886
STYLE_ITEM("item", "Style Item", Kind.SYNTHETIC),
8987

9088
/**
@@ -101,7 +99,9 @@ public enum ResourceType {
10199
MACRO("macro", "Macro resource replacement", Kind.SYNTHETIC),
102100
;
103101

104-
/** The set of all types of resources that can be referenced by other resources. */
102+
/**
103+
* The set of all types of resources that can be referenced by other resources.
104+
*/
105105
public static final ImmutableSet<ResourceType> REFERENCEABLE_TYPES;
106106
private static final ImmutableMap<String, ResourceType> TAG_NAMES;
107107
private static final ImmutableMap<String, ResourceType> CLASS_NAMES;
@@ -129,16 +129,25 @@ public enum ResourceType {
129129

130130
TAG_NAMES = tagNames.build();
131131
CLASS_NAMES = classNames.build();
132-
REFERENCEABLE_TYPES =
133-
Arrays.stream(values())
134-
.filter(ResourceType::getCanBeReferenced)
135-
.collect(Sets.toImmutableEnumSet());
132+
133+
final ImmutableSet.Builder<ResourceType> setBuilder = ImmutableSet.builder();
134+
for (ResourceType type : values()) {
135+
if (type.getCanBeReferenced()) {
136+
setBuilder.add(type);
137+
}
138+
}
139+
140+
REFERENCEABLE_TYPES = setBuilder.build();
136141
}
137142

138-
@NonNull private final String mName;
139-
@NonNull private final Kind mKind;
140-
@NonNull private final String mDisplayName;
141-
@NonNull private final String[] mAlternateXmlNames;
143+
@NonNull
144+
private final String mName;
145+
@NonNull
146+
private final Kind mKind;
147+
@NonNull
148+
private final String mDisplayName;
149+
@NonNull
150+
private final String[] mAlternateXmlNames;
142151

143152
ResourceType(
144153
@NonNull String name, @NonNull String displayName, @NonNull String... alternateXmlNames) {
@@ -147,6 +156,7 @@ public enum ResourceType {
147156
mDisplayName = displayName;
148157
mAlternateXmlNames = alternateXmlNames;
149158
}
159+
150160
ResourceType(@NonNull String name, @NonNull String displayName, @NonNull Kind kind) {
151161
mName = name;
152162
mKind = kind;
@@ -247,7 +257,9 @@ public static Collection<String> getClassNames() {
247257
return CLASS_NAMES.keySet();
248258
}
249259

250-
/** Returns a translated display name for the resource type. */
260+
/**
261+
* Returns a translated display name for the resource type.
262+
*/
251263
@NonNull
252264
public String getDisplayName() {
253265
return mDisplayName;
@@ -264,7 +276,9 @@ public boolean getCanBeReferenced() {
264276
return (mKind == Kind.REAL && this != ATTR) || this == MACRO;
265277
}
266278

267-
/** Returns true if this type is a synthetic type, such as {@link #PUBLIC} */
279+
/**
280+
* Returns true if this type is a synthetic type, such as {@link #PUBLIC}
281+
*/
268282
public boolean isSynthetic() {
269283
return mKind == Kind.SYNTHETIC;
270284
}
@@ -276,14 +290,18 @@ public String toString() {
276290
return getName();
277291
}
278292

279-
/** Returns the resource type name, as used by XML files. */
293+
/**
294+
* Returns the resource type name, as used by XML files.
295+
*/
280296
@NonNull
281297
public String getName() {
282298
return mName;
283299
}
284300

285301
private enum Kind {
286-
/** These types are used both in the R and as XML tag names. */
302+
/**
303+
* These types are used both in the R and as XML tag names.
304+
*/
287305
REAL,
288306

289307
/**

0 commit comments

Comments
 (0)