Java Code Examples for com.android.resources.ResourceFolderType#LAYOUT

The following examples show how to use com.android.resources.ResourceFolderType#LAYOUT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceCycleDetector.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.VALUES
            || folderType == ResourceFolderType.COLOR
            || folderType == ResourceFolderType.DRAWABLE
            || folderType == ResourceFolderType.LAYOUT;
}
 
Example 2
Source File: ExtraTextDetector.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT
            || folderType == ResourceFolderType.MENU
            || folderType == ResourceFolderType.ANIM
            || folderType == ResourceFolderType.ANIMATOR
            || folderType == ResourceFolderType.DRAWABLE
            || folderType == ResourceFolderType.COLOR;
}
 
Example 3
Source File: PreferStubViewDetector.java    From Folivora with Apache License 2.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NotNull ResourceFolderType folderType) {
  return folderType == ResourceFolderType.LAYOUT;
}
 
Example 4
Source File: XmlPrettyPrinter.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private static void formatFile(@NonNull XmlFormatPreferences prefs, File file,
        boolean stdout) {
    if (file.isDirectory()) {
        File[] files = file.listFiles();
        if (files != null) {
            for (File child : files) {
                formatFile(prefs, child, stdout);
            }
        }
    } else if (file.isFile() && SdkUtils.endsWithIgnoreCase(file.getName(), DOT_XML)) {
        XmlFormatStyle style = null;
        if (file.getName().equals(SdkConstants.ANDROID_MANIFEST_XML)) {
            style = XmlFormatStyle.MANIFEST;
        } else {
            File parent = file.getParentFile();
            if (parent != null) {
                String parentName = parent.getName();
                ResourceFolderType folderType = ResourceFolderType.getFolderType(parentName);
                if (folderType == ResourceFolderType.LAYOUT) {
                    style = XmlFormatStyle.LAYOUT;
                } else if (folderType == ResourceFolderType.VALUES) {
                    style = XmlFormatStyle.RESOURCE;
                }
            }
        }

        try {
            String xml = Files.toString(file, Charsets.UTF_8);
            Document document = XmlUtils.parseDocumentSilently(xml, true);
            if (document == null) {
                System.err.println("Could not parse " + file);
                System.exit(1);
                return;
            }

            if (style == null) {
                style = XmlFormatStyle.get(document);
            }
            boolean endWithNewline = xml.endsWith("\n");
            int firstNewLine = xml.indexOf('\n');
            String lineSeparator = firstNewLine > 0 && xml.charAt(firstNewLine - 1) == '\r' ?
                    "\r\n" : "\n";
            String formatted = XmlPrettyPrinter.prettyPrint(document, prefs, style,
                    lineSeparator, endWithNewline);
            if (stdout) {
                System.out.println(formatted);
            } else {
                Files.write(formatted, file, Charsets.UTF_8);
            }
        } catch (IOException e) {
            System.err.println("Could not read " + file);
            System.exit(1);
        }
    }
}
 
Example 5
Source File: LayoutDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT;
}
 
Example 6
Source File: WrongIdDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.VALUES;
}
 
Example 7
Source File: ViewTypeDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT;
}
 
Example 8
Source File: DuplicateIdDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.MENU;
}
 
Example 9
Source File: PxUsageDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    // Look in both layouts (at attribute values) and in value files (at style definitions)
    return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.VALUES;
}
 
Example 10
Source File: LayoutConsistencyDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT;
}
 
Example 11
Source File: ButtonDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.VALUES;
}
 
Example 12
Source File: NegativeMarginDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    // Look in both layouts (at attribute values) and in value files (style and dimension
    // definitions)
    return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.VALUES;
}
 
Example 13
Source File: HardcodedValuesDetector.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.MENU;
}
 
Example 14
Source File: XmlPrettyPrinter.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
private static void formatFile(@NonNull XmlFormatPreferences prefs, File file,
        boolean stdout) {
    if (file.isDirectory()) {
        File[] files = file.listFiles();
        if (files != null) {
            for (File child : files) {
                formatFile(prefs, child, stdout);
            }
        }
    } else if (file.isFile() && SdkUtils.endsWithIgnoreCase(file.getName(), DOT_XML)) {
        XmlFormatStyle style = null;
        if (file.getName().equals(SdkConstants.ANDROID_MANIFEST_XML)) {
            style = XmlFormatStyle.MANIFEST;
        } else {
            File parent = file.getParentFile();
            if (parent != null) {
                String parentName = parent.getName();
                ResourceFolderType folderType = ResourceFolderType.getFolderType(parentName);
                if (folderType == ResourceFolderType.LAYOUT) {
                    style = XmlFormatStyle.LAYOUT;
                } else if (folderType == ResourceFolderType.VALUES) {
                    style = XmlFormatStyle.RESOURCE;
                }
            }
        }

        try {
            String xml = Files.toString(file, Charsets.UTF_8);
            Document document = XmlUtils.parseDocumentSilently(xml, true);
            if (document == null) {
                System.err.println("Could not parse " + file);
                System.exit(1);
                return;
            }

            if (style == null) {
                style = XmlFormatStyle.get(document);
            }
            boolean endWithNewline = xml.endsWith("\n");
            int firstNewLine = xml.indexOf('\n');
            String lineSeparator = firstNewLine > 0 && xml.charAt(firstNewLine - 1) == '\r' ?
                    "\r\n" : "\n";
            String formatted = XmlPrettyPrinter.prettyPrint(document, prefs, style,
                    lineSeparator, endWithNewline);
            if (stdout) {
                System.out.println(formatted);
            } else {
                Files.write(formatted, file, Charsets.UTF_8);
            }
        } catch (IOException e) {
            System.err.println("Could not read " + file);
            System.exit(1);
        }
    }
}
 
Example 15
Source File: LayoutIdFormat.java    From lewis with Apache License 2.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT;
}
 
Example 16
Source File: HardcodedTextDetectorModified.java    From lewis with Apache License 2.0 4 votes vote down vote up
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
    return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.MENU;
}