当前位置: 首页>>代码示例>>Java>>正文


Java AndroidUtils类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:apsun,项目名称:XposedPlugin,代码行数:19,代码来源:XposedBridgeJarManager.java

示例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();
}
 
开发者ID:shchurov,项目名称:SharedPreferences-Editor-Plugin,代码行数:18,代码来源:OpenEditorAction.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AndroidRemoteDataBaseManager.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidImplicitUsagesProvider.java

示例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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:AndroidFacetImporterBase.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidEclipseNatureImporter.java

示例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");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:CreateTypedResourceFileAction.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AndroidDomUtil.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:DeclareStyleableNameConverter.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidDomElementDescriptorProvider.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AndroidDomExtender.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StyleItemConverter.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:NewKeyStoreDialog.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidConfigurationProducer.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AndroidConfigurationProducer.java


注:本文中的org.jetbrains.android.util.AndroidUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。