本文整理汇总了Java中com.android.resources.ResourceFolderType.LAYOUT属性的典型用法代码示例。如果您正苦于以下问题:Java ResourceFolderType.LAYOUT属性的具体用法?Java ResourceFolderType.LAYOUT怎么用?Java ResourceFolderType.LAYOUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.android.resources.ResourceFolderType
的用法示例。
在下文中一共展示了ResourceFolderType.LAYOUT属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appliesTo
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
return folderType == ResourceFolderType.VALUES
|| folderType == ResourceFolderType.COLOR
|| folderType == ResourceFolderType.DRAWABLE
|| folderType == ResourceFolderType.LAYOUT;
}
示例2: appliesTo
@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;
}
示例3: isUnknownCustomView
private static boolean isUnknownCustomView(XmlTag tag) {
PsiFile file = tag.getContainingFile();
if (file != null) {
ResourceFolderType type = ResourceHelper.getFolderType(file);
if (type == ResourceFolderType.LAYOUT && tag.getName().indexOf('.') != -1) {
return true;
}
}
return false;
}
示例4: forkResourceFile
/**
* Create a variation (copy) of a given resource file (of a given type).
*
* @param xmlFile the XML resource file to fork
* @param myNewFolder the resource folder to create, or null to ask the user
* @param open if true, open the file after creating it
*/
public static void forkResourceFile(@NotNull final XmlFile xmlFile, @Nullable String myNewFolder, boolean open) {
VirtualFile file = xmlFile.getVirtualFile();
if (file == null) {
return;
}
Module module = AndroidPsiUtils.getModuleSafely(xmlFile);
if (module == null) {
return;
}
ResourceFolderType folderType = ResourceHelper.getFolderType(xmlFile);
if (folderType == null || folderType == ResourceFolderType.VALUES) {
return;
}
Configuration configuration = null;
if (folderType == ResourceFolderType.LAYOUT) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
configuration = facet.getConfigurationManager().getConfiguration(file);
}
}
// Suppress: IntelliJ claims folderType can be null here, but it can't (and inserting assert folderType != null is correctly
// identified as redundant)
//noinspection ConstantConditions
forkResourceFile(module, folderType, file, xmlFile, myNewFolder, configuration, open);
}
示例5: getLayoutEditor
/**
* Returns a fixture around the layout editor, <b>if</b> the currently edited file
* is a layout file and it is currently showing the layout editor tab or the parameter
* requests that it be opened if necessary
*
* @param switchToTabIfNecessary if true, switch to the design tab if it is not already showing
* @return a layout editor fixture, or null if the current file is not a layout file or the
* wrong tab is showing
*/
@Nullable
public LayoutEditorFixture getLayoutEditor(boolean switchToTabIfNecessary) {
VirtualFile currentFile = getCurrentFile();
if (ResourceHelper.getFolderType(currentFile) != ResourceFolderType.LAYOUT) {
return null;
}
if (switchToTabIfNecessary) {
selectEditorTab(Tab.DESIGN);
}
return execute(new GuiQuery<LayoutEditorFixture>() {
@Override
@Nullable
protected LayoutEditorFixture executeInEDT() throws Throwable {
FileEditorManager manager = FileEditorManager.getInstance(myFrame.getProject());
FileEditor[] editors = manager.getSelectedEditors();
if (editors.length == 0) {
return null;
}
FileEditor selected = editors[0];
if (!(selected instanceof AndroidDesignerEditor)) {
return null;
}
return new LayoutEditorFixture(robot, (AndroidDesignerEditor)selected);
}
});
}
示例6: formatFile
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);
}
}
}
示例7: appliesTo
@Override
public boolean appliesTo(ResourceFolderType folderType) {
return ResourceFolderType.LAYOUT == folderType;
}
示例8: appliesTo
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
return folderType == ResourceFolderType.LAYOUT;
}
示例9: appliesTo
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.MENU;
}
示例10: appliesTo
@Override
public boolean appliesTo(@NonNull ResourceFolderType folderType) {
return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.VALUES;
}
示例11: appliesTo
@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;
}
示例12: appliesTo
@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;
}
示例13: needSave
public static boolean needSave(@Nullable ResourceFolderType type) {
// Only layouts are delegates to the IProjectCallback#getParser where we can supply a
// parser directly from the live document; others read contents from disk via layoutlib.
// TODO: Work on adding layoutlib support for this.
return type != ResourceFolderType.LAYOUT;
}