Search in sources :

Example 1 with ClassField

use of com.android.builder.model.ClassField in project android by JetBrains.

the class StringResourceDataTest method setUpData.

private void setUpData() {
    Collection<VirtualFile> resourceDirectories = Collections.singletonList(resourceDirectory);
    ClassField field = Mockito.mock(ClassField.class);
    Mockito.when(field.getType()).thenReturn("string");
    Mockito.when(field.getName()).thenReturn("dynamic_key1");
    Mockito.when(field.getValue()).thenReturn("L\\'Étranger");
    Map<String, ClassField> values = Collections.singletonMap("dynamic_key1", field);
    LocalResourceRepository otherDelegate = DynamicResourceValueRepository.createForTest(myFacet, values);
    Disposer.register(myFacet, otherDelegate);
    Collection<LocalResourceRepository> otherDelegates = Collections.singletonList(otherDelegate);
    data = StringResourceParser.parse(myFacet, ModuleResourceRepository.createForTest(myFacet, resourceDirectories, otherDelegates));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalResourceRepository(com.android.tools.idea.res.LocalResourceRepository) ClassField(com.android.builder.model.ClassField)

Example 2 with ClassField

use of com.android.builder.model.ClassField in project android by JetBrains.

the class DynamicResourceValueRepository method addValues.

private void addValues(Map<String, ClassField> resValues) {
    for (Map.Entry<String, ClassField> entry : resValues.entrySet()) {
        ClassField field = entry.getValue();
        String name = field.getName();
        assert entry.getKey().equals(name) : entry.getKey() + " vs " + name;
        ResourceType type = ResourceType.getEnum(field.getType());
        if (type == null) {
            LOG.warn("Ignoring field " + name + "(" + field + "): unknown type " + field.getType());
            continue;
        }
        ListMultimap<String, ResourceItem> map = mItems.get(type);
        if (map == null) {
            map = ArrayListMultimap.create();
            mItems.put(type, map);
        } else if (map.containsKey(name)) {
            // Masked by higher priority source provider
            continue;
        }
        ResourceItem item = new DynamicResourceValueItem(type, field);
        map.put(name, item);
    }
}
Also used : ResourceType(com.android.resources.ResourceType) ResourceItem(com.android.ide.common.res2.ResourceItem) Map(java.util.Map) ClassField(com.android.builder.model.ClassField)

Aggregations

ClassField (com.android.builder.model.ClassField)2 ResourceItem (com.android.ide.common.res2.ResourceItem)1 ResourceType (com.android.resources.ResourceType)1 LocalResourceRepository (com.android.tools.idea.res.LocalResourceRepository)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Map (java.util.Map)1