• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AndroidUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jetbrains.android.util.AndroidUtils的典型用法代码示例。如果您正苦于以下问题:Java AndroidUtils类的具体用法?Java AndroidUtils怎么用?Java AndroidUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AndroidUtils类属于org.jetbrains.android.util包,在下文中一共展示了AndroidUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: findActivityAlias

import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
@Nullable
private static ActivityAlias findActivityAlias(@NotNull AndroidFacet facet, @NotNull String name) {
  ActivityAlias alias = doFindActivityAlias(facet, name);

  if (alias != null) {
    return alias;
  }
  for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(facet.getModule(), true)) {
    alias = doFindActivityAlias(depFacet, name);

    if (alias != null) {
      return alias;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidRunConfiguration.java


示例17: isWatchFaceApp

import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
/**
 * Returns whether the given module corresponds to a watch face app.
 * A module is considered to be a watch face app if there are no activities, and a single service with
 * a specific intent filter. This definition is likely stricter than it needs to be to but we are only
 * interested in matching the watch face template application.
 */
public static boolean isWatchFaceApp(@NotNull AndroidFacet facet) {
  ManifestInfo info = ManifestInfo.get(facet.getModule(), true);
  if (!info.getActivities().isEmpty()) {
    return false;
  }

  final List<Service> services = info.getServices();
  if (services.size() != 1) {
    return false;
  }

  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      List<IntentFilter> filters = services.get(0).getIntentFilters();
      return filters.size() == 1 &&
             AndroidDomUtil.containsAction(filters.get(0), AndroidUtils.WALLPAPER_SERVICE_ACTION_NAME) &&
             AndroidDomUtil.containsCategory(filters.get(0), AndroidUtils.WATCHFACE_CATEGORY_NAME);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:AndroidRunConfiguration.java


示例18: setupConfiguration

import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
private boolean setupConfiguration(AndroidTestRunConfiguration configuration,
                                   PsiElement element,
                                   ConfigurationContext context,
                                   Ref<PsiElement> sourceElement) {
  final Module module = AndroidUtils.getAndroidModule(context);

  if (module == null) {
    return false;
  }
  sourceElement.set(element);
  setupConfigurationModule(context, configuration);

  final TargetSelectionMode targetSelectionMode = AndroidUtils
    .getDefaultTargetSelectionMode(module, AndroidTestRunConfigurationType.getInstance(), AndroidRunConfigurationType.getInstance());

  if (targetSelectionMode != null) {
    configuration.setTargetSelectionMode(targetSelectionMode);
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AndroidTestConfigurationProducer.java


示例19: computeRepositories

import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
private static List<LocalResourceRepository> computeRepositories(@NotNull final AndroidFacet facet) {
  LocalResourceRepository main = ModuleResourceRepository.getModuleResources(facet, true);

  // List of module facets the given module depends on
  List<AndroidFacet> dependentFacets = AndroidUtils.getAllAndroidDependencies(facet.getModule(), true);
  if (dependentFacets.isEmpty()) {
    return Collections.singletonList(main);
  }

  List<LocalResourceRepository> resources = Lists.newArrayListWithExpectedSize(dependentFacets.size());

  for (AndroidFacet f : dependentFacets) {
    LocalResourceRepository r = ModuleResourceRepository.getModuleResources(f, true);
    resources.add(r);
  }

  resources.add(main);

  return resources;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ProjectResourceRepository.java


示例20: syncWithReadPermission

import org.jetbrains.android.util.AndroidUtils; //导入依赖的package包/类
private void syncWithReadPermission() {
  ApplicationManager.getApplication().assertReadAccessAllowed();

  List<Manifest> manifests = Lists.newArrayListWithExpectedSize(myManifestFiles.size());
  for (VirtualFile f : myManifestFiles) {
    PsiFile psiFile = PsiManager.getInstance(myModule.getProject()).findFile(f);
    if (psiFile instanceof XmlFile) {
      Manifest m = AndroidUtils.loadDomElementWithReadPermission(myModule.getProject(), (XmlFile)psiFile, Manifest.class);
      // If the file reported as a manifest is invalid, m will be null.
      if (m != null) {
        manifests.add(m);
      }
    }
  }

  myManifestsRef.set(manifests);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MergedManifestInfo.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CRFTrainerByStochasticGradient类代码示例发布时间:2022-05-22
下一篇:
Java GetFuture类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap