本文整理汇总了Java中org.jetbrains.android.util.AndroidUtils类的典型用法代码示例。如果您正苦于以下问题:Java AndroidUtils类的具体用法?Java AndroidUtils怎么用?Java AndroidUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AndroidUtils类属于org.jetbrains.android.util包,在下文中一共展示了AndroidUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLibsDir
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
private VirtualFile getLibsDir() {
AndroidFacet androidFacet = AndroidFacet.getInstance(mModule);
if (androidFacet == null) {
throw new XposedPluginException("No Android facet found in module");
}
VirtualFile rootDir = AndroidRootUtil.getMainContentRoot(androidFacet);
if (rootDir == null) {
throw new XposedPluginException("Failed to find main content root");
}
Project project = mModule.getProject();
try {
return AndroidUtils.createChildDirectoryIfNotExist(project, rootDir, "libs");
} catch (IOException e) {
throw new XposedPluginException("Failed to create libs directory", e);
}
}
示例2: chooseModule
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
private AndroidFacet chooseModule() {
List<AndroidFacet> facets = AndroidUtils.getApplicationFacets(project);
if (facets.isEmpty()) {
showErrorNotification("Can't find any modules");
return null;
}
if (facets.size() == 1) {
return facets.get(0);
}
return new ChooseDialog<AndroidFacet>(project, "Choose Module", facets) {
@Override
protected String getItemName(AndroidFacet item) {
return item.getModule().getName();
}
}
.showAndGetResult();
}
示例3: buildLocalDbFileOsPath
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@NotNull
public static String buildLocalDbFileOsPath(@Nullable String deviceId,
@Nullable String packageName,
@Nullable String databaseName,
boolean external) {
if (deviceId == null ||
packageName == null ||
databaseName == null ||
deviceId.length() == 0 ||
packageName.length() == 0 ||
databaseName.length() == 0) {
return "";
}
return AndroidUtils.getAndroidSystemDirectoryOsPath() +
File.separator + "databases" +
File.separator + deviceId +
File.separator + packageName +
File.separator + (external ? "external" : "internal") +
File.separator + databaseName;
}
示例4: isImplicitParameterUsage
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
private static boolean isImplicitParameterUsage(@NotNull PsiParameter parameter) {
if (AndroidFacet.getInstance(parameter) == null) {
return false;
}
final PsiMethod method = PsiTreeUtil.getParentOfType(parameter, PsiMethod.class);
if (method == null ||
!OnClickConverter.CONVERTER_FOR_LAYOUT.checkSignature(method) &&
!OnClickConverter.CONVERTER_FOR_MENU.checkSignature(method)) {
return false;
}
final PsiClass aClass = PsiTreeUtil.getParentOfType(method, PsiClass.class);
if (aClass == null) {
return false;
}
final PsiClass activityBaseClass = JavaPsiFacade.getInstance(aClass.getProject()).
findClass(AndroidUtils.ACTIVITY_BASE_CLASS_NAME, parameter.getResolveScope());
if (activityBaseClass == null) {
return false;
}
return aClass.isInheritor(activityBaseClass, true);
}
示例5: setupFacet
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@Override
protected void setupFacet(AndroidFacet facet, MavenProject mavenProject) {
String mavenProjectDirPath = FileUtil.toSystemIndependentName(mavenProject.getDirectory());
facet.getConfiguration().init(facet.getModule(), mavenProjectDirPath);
AndroidMavenProviderImpl.setPathsToDefault(mavenProject, facet.getModule(), facet.getConfiguration());
final boolean hasApkSources = AndroidMavenProviderImpl.hasApkSourcesDependency(mavenProject);
AndroidMavenProviderImpl.configureAaptCompilation(mavenProject, facet.getModule(), facet.getConfiguration(), hasApkSources);
final String packaging = mavenProject.getPackaging();
if (AndroidMavenUtil.APKLIB_DEPENDENCY_AND_PACKAGING_TYPE.equals(packaging) ||
AndroidMavenUtil.AAR_DEPENDENCY_AND_PACKAGING_TYPE.equals(packaging)) {
facet.setLibraryProject(true);
}
facet.getConfiguration().setIncludeAssetsFromLibraries(true);
if (hasApkSources) {
AndroidUtils.reportImportErrorToEventLog("'apksources' dependency is deprecated and can be poorly supported by IDE. " +
"It is strongly recommended to use 'apklib' dependency instead.",
facet.getModule().getName(), facet.getModule().getProject());
}
if (Boolean.parseBoolean(findConfigValue(mavenProject, DEX_CORE_LIBRARY_PROPERTY))) {
AndroidDexCompilerConfiguration.getInstance(facet.getModule().getProject()).CORE_LIBRARY = true;
}
}
示例6: doImport
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@Override
public void doImport(@NotNull Project project, @NotNull List<Module> modules) {
for (Module module : modules) {
final VirtualFile contentRoot = chooseMainContentRoot(module);
if (contentRoot == null) {
AndroidUtils.reportImportErrorToEventLog("Cannot find content root containing " +
SdkConstants.FN_ANDROID_MANIFEST_XML + " file", module.getName(), project);
continue;
}
final AndroidFacet facet = AndroidUtils.addAndroidFacetInWriteAction(module, contentRoot, false);
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
AndroidFrameworkDetector.doImportSdkAndFacetConfiguration(facet, modifiableModel);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
modifiableModel.commit();
}
});
}
ImportDependenciesUtil.doImportDependencies(project, modules, true);
}
示例7: getDefaultRootTagByResourceType
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@NotNull
public static String getDefaultRootTagByResourceType(@NotNull ResourceFolderType resourceType) {
switch (resourceType) {
case XML:
return "PreferenceScreen";
case DRAWABLE:
return "selector";
case COLOR:
return "selector";
case VALUES:
return "resources";
case MENU:
return "menu";
case ANIM:
return "set";
case ANIMATOR:
return "set";
case LAYOUT:
return AndroidUtils.TAG_LINEAR_LAYOUT;
case TRANSITION:
return TransitionDomUtil.DEFAULT_ROOT;
default:
}
throw new IllegalArgumentException("Incorrect resource folder type");
}
示例8: removeUnambiguousNames
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@NotNull
public static Collection<String> removeUnambiguousNames(@NotNull Map<String, PsiClass> viewClassMap) {
final Map<String, String> class2Name = new HashMap<String, String>();
for (String tagName : viewClassMap.keySet()) {
final PsiClass viewClass = viewClassMap.get(tagName);
if (!AndroidUtils.isAbstract(viewClass)) {
final String qName = viewClass.getQualifiedName();
final String prevTagName = class2Name.get(qName);
if (prevTagName == null || tagName.indexOf('.') == -1) {
class2Name.put(qName, tagName);
}
}
}
return class2Name.values();
}
示例9: getVariants
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
final PsiClass viewClass = JavaPsiFacade.getInstance(myElement.getProject())
.findClass(AndroidUtils.VIEW_CLASS_NAME, myFacet.getModule().getModuleWithDependenciesAndLibrariesScope(false));
if (viewClass == null) {
return EMPTY_ARRAY;
}
final Set<Object> shortNames = new HashSet<Object>();
ClassInheritorsSearch.search(viewClass, myFacet.getModule().getModuleWithDependenciesScope(), true).
forEach(new Processor<PsiClass>() {
@Override
public boolean process(PsiClass aClass) {
final String name = aClass.getName();
if (name != null) {
shortNames.add(JavaLookupElementBuilder.forClass(aClass, name, true));
}
return true;
}
});
return shortNames.toArray();
}
示例10: getDomElementAndBaseClassQName
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@Nullable
public static Pair<AndroidDomElement, String> getDomElementAndBaseClassQName(@NotNull XmlTag tag) {
final PsiFile file = tag.getContainingFile();
if (!(file instanceof XmlFile)) return null;
Project project = file.getProject();
if (project.isDefault()) return null;
final DomManager domManager = DomManager.getDomManager(project);
if (domManager.getFileElement((XmlFile)file, AndroidDomElement.class) == null) return null;
final DomElement domElement = domManager.getDomElement(tag);
if (!(domElement instanceof AndroidDomElement)) {
return null;
}
String className = null;
if (domElement instanceof LayoutViewElement) {
className = AndroidUtils.VIEW_CLASS_NAME;
}
else if (domElement instanceof XmlResourceElement) {
className = AndroidXmlResourcesUtil.PREFERENCE_CLASS_NAME;
}
return Pair.create((AndroidDomElement)domElement, className);
}
示例11: registerClassNameSubtags
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
private static void registerClassNameSubtags(XmlTag tag,
Map<String, PsiClass> classMap,
Type type,
Set<String> registeredSubtags,
MyCallback callback) {
final Set<String> allAllowedTags = new HashSet<String>();
final Map<String, String> class2Name = new HashMap<String, String>();
for (String tagName : classMap.keySet()) {
final PsiClass aClass = classMap.get(tagName);
if (!AndroidUtils.isAbstract(aClass)) {
allAllowedTags.add(tagName);
final String qName = aClass.getQualifiedName();
final String prevTagName = class2Name.get(qName);
if (prevTagName == null || tagName.indexOf('.') == -1) {
class2Name.put(qName, tagName);
}
}
}
registerSubtags(callback, tag, allAllowedTags, class2Name.values(), registeredSubtags, type);
}
示例12: findConverterForAttribute
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@Nullable
private static ResolvingConverter findConverterForAttribute(String nsPrefix,
String localName,
@NotNull AndroidFacet facet,
@NotNull GenericDomValue element) {
ResourceManager manager = facet.getResourceManager("android".equals(nsPrefix)
? AndroidUtils.SYSTEM_RESOURCE_PACKAGE
: null, element.getXmlElement());
if (manager != null) {
AttributeDefinitions attrDefs = manager.getAttributeDefinitions();
if (attrDefs != null) {
AttributeDefinition attr = attrDefs.getAttrDefByName(localName);
if (attr != null) {
return AndroidDomUtil.getConverter(attr);
}
}
}
return null;
}
示例13: doOKAction
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@Override
protected void doOKAction() {
if (getKeyStorePath().length() == 0) {
Messages.showErrorDialog(myPanel, "Specify key store path", CommonBundle.getErrorTitle());
return;
}
try {
AndroidUtils.checkNewPassword(myPasswordField, myConfirmedPassword);
myNewKeyForm.createKey();
}
catch (CommitStepException e) {
Messages.showErrorDialog(myPanel, e.getMessage(), CommonBundle.getErrorTitle());
return;
}
super.doOKAction();
}
示例14: getActivityClass
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@Nullable
private static PsiClass getActivityClass(Location location, ConfigurationContext context) {
final Module module = context.getModule();
if (module == null) return null;
location = JavaExecutionUtil.stepIntoSingleClass(location);
if (location == null) {
return null;
}
PsiElement element = location.getPsiElement();
JavaPsiFacade facade = JavaPsiFacade.getInstance(element.getProject());
GlobalSearchScope scope = module.getModuleWithDependenciesAndLibrariesScope(true);
PsiClass activityClass = facade.findClass(AndroidUtils.ACTIVITY_BASE_CLASS_NAME, scope);
if (activityClass == null) return null;
PsiClass elementClass = PsiTreeUtil.getParentOfType(element, PsiClass.class, false);
while (elementClass != null) {
if (elementClass.isInheritor(activityClass, true)) {
return elementClass;
}
elementClass = PsiTreeUtil.getParentOfType(elementClass, PsiClass.class);
}
return null;
}
示例15: isConfigurationFromContext
import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@Override
public boolean isConfigurationFromContext(AndroidRunConfiguration configuration, ConfigurationContext context) {
final Location location = context.getLocation();
if (location == null) {
return false;
}
final PsiClass activity = getActivityClass(location, context);
if (activity == null) {
return false;
}
final String activityName = activity.getQualifiedName();
if (activityName == null) {
return false;
}
final Module contextModule = AndroidUtils.getAndroidModule(context);
final Module confModule = configuration.getConfigurationModule().getModule();
return Comparing.equal(contextModule, confModule) && activityName.equals(configuration.ACTIVITY_CLASS);
}