本文整理汇总了Java中com.android.sdklib.AndroidVersion.getFeatureLevel方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidVersion.getFeatureLevel方法的具体用法?Java AndroidVersion.getFeatureLevel怎么用?Java AndroidVersion.getFeatureLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.sdklib.AndroidVersion
的用法示例。
在下文中一共展示了AndroidVersion.getFeatureLevel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prefCapableTargetInstalled
import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
/** Returns if a target capable of rendering preferences file is found. */
private static boolean prefCapableTargetInstalled(@NotNull PsiFile file) {
Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module != null) {
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform != null) {
IAndroidTarget[] targets = platform.getSdkData().getTargets();
for (int i = targets.length - 1; i >= 0; i--) {
IAndroidTarget target = targets[i];
if (target.isPlatform()) {
AndroidVersion version = target.getVersion();
int featureLevel = version.getFeatureLevel();
if (featureLevel >= PREFERENCES_MIN_API) {
return true;
}
}
}
}
}
return false;
}
示例2: getMinSdk
import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
protected int getMinSdk(Context context) {
if (mMinApi == -1) {
AndroidVersion minSdkVersion = context.getMainProject().getMinSdkVersion();
mMinApi = minSdkVersion.getFeatureLevel();
}
return mMinApi;
}
示例3: getPossibleRoots
import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
public static List<String> getPossibleRoots(AndroidFacet facet) {
AndroidVersion sdkVersion = AndroidModuleInfo.get(facet).getBuildSdkVersion();
List<String> result = Lists.newArrayListWithExpectedSize(DRAWABLE_ROOTS_V1.length + DRAWABLE_ROOTS_V21.length);
Collections.addAll(result, DRAWABLE_ROOTS_V1);
if (sdkVersion == null || sdkVersion.getFeatureLevel() >= 21 ||
ApplicationManager.getApplication().isUnitTestMode()) {
Collections.addAll(result, DRAWABLE_ROOTS_V21);
}
return result;
}
示例4: getLatestVersion
import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
@Nullable
public GradleCoordinate getLatestVersion(String artifact) {
int compileVersion = GradleImport.CURRENT_COMPILE_VERSION;
AndroidVersion version = getCompileSdkVersion();
if (version != AndroidVersion.DEFAULT) {
compileVersion = version.getFeatureLevel();
}
// If you're using for example android-14, you still need support libraries
// from version 18 (earliest version where we have all the libs in the m2 repository)
if (compileVersion < 18) {
compileVersion = 18;
}
String compileVersionString = Integer.toString(compileVersion);
if (myImporter.getSdkLocation() != null) {
@SuppressWarnings("UnnecessaryLocalVariable") String filter = compileVersionString;
GradleCoordinate max =
SdkMavenRepository.ANDROID.getHighestInstalledVersion(myImporter.getSdkLocation(), SUPPORT_GROUP_ID, artifact, filter, true);
if (max != null) {
return max;
}
}
String coordinate = SUPPORT_GROUP_ID + ':' + artifact + ':' + compileVersionString + ".+";
return GradleCoordinate.parseCoordinateString(coordinate);
}
示例5: preselectTargetAndBuildApi
import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
private void preselectTargetAndBuildApi() {
// In IntelliJ user chooses SDK entry, which also contains api level, in the first step,
// so we preselect "compile with" and "target api" options.
// This code shouldn't be executed in Android Studio: myWizardContext should be null.
if (myWizardContext != null) {
final ProjectBuilder builder = myWizardContext.getProjectBuilder();
if (builder instanceof ModuleBuilder) {
Sdk sdk = ((ModuleBuilder)builder).getModuleJdk();
if (sdk == null) {
sdk = myWizardContext.getProjectJdk();
}
if (sdk != null && sdk.getSdkType() instanceof AndroidSdkType) {
final AndroidPlatform platform = AndroidPlatform.getInstance(sdk);
if (platform != null) {
AndroidVersion version = platform.getTarget().getVersion();
final int apiLevel = version.getFeatureLevel();
myTemplateState.put(ATTR_TARGET_API, apiLevel);
myTemplateState.put(ATTR_TARGET_API_STRING, version.getApiString());
myTemplateState.put(ATTR_BUILD_API, apiLevel);
myTemplateState.put(ATTR_BUILD_API_STRING, TemplateMetadata.getBuildApiString(version));
myCompileWith.setEnabled(false);
}
}
}
}
}
示例6: hasCorrectJdkVersion
import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
static boolean hasCorrectJdkVersion(@NotNull Module module, @NotNull IdeaAndroidProject model) {
AndroidProject androidProject = model.getDelegate();
String compileTarget = androidProject.getCompileTarget();
AndroidVersion version = AndroidTargetHash.getPlatformVersion(compileTarget);
if (version != null && version.getFeatureLevel() >= 21) {
Sdk jdk = IdeSdks.getJdk();
if (jdk != null && !isApplicableJdk(jdk, LanguageLevel.JDK_1_7)) {
Project project = module.getProject();
List<NotificationHyperlink> hyperlinks = Lists.newArrayList();
hyperlinks.add(new OpenUrlHyperlink(Jdks.DOWNLOAD_JDK_7_URL, "Download JDK 7"));
ProjectSettingsService service = ProjectSettingsService.getInstance(project);
if (service instanceof AndroidProjectSettingsService) {
hyperlinks.add(new SelectJdkHyperlink((AndroidProjectSettingsService)service));
}
Message msg;
String text = "compileSdkVersion " + compileTarget + " requires compiling with JDK 7";
VirtualFile buildFile = getGradleBuildFile(module);
String groupName = "Project Configuration";
if (buildFile != null) {
int lineNumber = -1;
int column = -1;
Document document = FileDocumentManager.getInstance().getDocument(buildFile);
if (document != null) {
int offset = findCompileSdkVersionValueOffset(document.getText());
if (offset > -1) {
lineNumber = document.getLineNumber(offset);
if (lineNumber > -1) {
int lineStartOffset = document.getLineStartOffset(lineNumber);
column = offset - lineStartOffset;
}
}
}
hyperlinks.add(new OpenFileHyperlink(buildFile.getPath(), "Open build.gradle File", lineNumber, column));
msg = new Message(project, groupName, Message.Type.ERROR, buildFile, lineNumber, column, text);
}
else {
msg = new Message(groupName, Message.Type.ERROR, NonNavigatable.INSTANCE, text);
}
ProjectSyncMessages messages = ProjectSyncMessages.getInstance(project);
messages.add(msg, hyperlinks.toArray(new NotificationHyperlink[hyperlinks.size()]));
setHasWrongJdk(project, true);
return false;
}
}
return true;
}
示例7: createPopupActionGroup
import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
DefaultActionGroup group = new DefaultActionGroup(null, true);
Configuration configuration = myRenderContext.getConfiguration();
if (configuration == null) {
return group;
}
group.add(new TogglePickBestAction(configuration.getConfigurationManager()));
group.addSeparator();
IAndroidTarget current = configuration.getTarget();
IAndroidTarget[] targets = configuration.getConfigurationManager().getTargets();
boolean haveRecent = false;
Module module = myRenderContext.getModule();
int minSdk = -1;
if (module != null) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
minSdk = facet.getAndroidModuleInfo().getMinSdkVersion().getFeatureLevel();
}
}
for (int i = targets.length - 1; i >= 0; i--) {
IAndroidTarget target = targets[i];
if (!ConfigurationManager.isLayoutLibTarget(target)) {
continue;
}
if (!switchToTargetAllowed(configuration, target)) {
continue;
}
AndroidVersion version = target.getVersion();
if (version.getFeatureLevel() < minSdk) {
continue;
}
if (version.getApiLevel() >= 7) {
haveRecent = true;
}
else if (haveRecent) {
// Don't show ancient rendering targets; they're pretty broken
// (unless of course all you have are ancient targets)
break;
}
String title = getRenderingTargetLabel(target, false);
boolean select = current == target;
group.add(new SetTargetAction(myRenderContext, title, target, select));
}
group.addSeparator();
RenderPreviewMode currentMode = RenderPreviewMode.getCurrent();
if (currentMode != RenderPreviewMode.API_LEVELS) {
ConfigurationMenuAction.addApiLevelPreviewAction(myRenderContext, group);
} else {
ConfigurationMenuAction.addRemovePreviewsAction(myRenderContext, group);
}
return group;
}
示例8: validate
import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
@Override
public boolean validate() {
setErrorHtml(null);
AndroidVersion minApi = myState.get(AddAndroidActivityPath.KEY_MIN_SDK);
Integer buildApi = myState.get(AddAndroidActivityPath.KEY_BUILD_SDK);
TemplateEntry templateEntry = myState.get(AddAndroidActivityPath.KEY_SELECTED_TEMPLATE);
if (templateEntry == null) {
return false;
}
for (Parameter param : templateEntry.getParameters()) {
if (param != null) {
Object value = getStateParameterValue(param);
String error = param.validate(getProject(), getModule(), myState.get(AddAndroidActivityPath.KEY_SOURCE_PROVIDER),
myState.get(myPackageNameKey), value != null ? value : "");
if (error != null) {
// Highlight?
setErrorHtml(error);
return false;
}
// Check to see that the selection's constraints are met if this is a combo box
if (value instanceof ComboBoxItem) {
ComboBoxItem selectedItem = (ComboBoxItem)value;
if (minApi != null && selectedItem.minApi > minApi.getFeatureLevel()) {
setErrorHtml(String.format("The \"%s\" option for %s requires a minimum API level of %d",
selectedItem.label, param.name, selectedItem.minApi));
return false;
}
if (buildApi != null && selectedItem.minBuildApi > buildApi) {
setErrorHtml(String.format("The \"%s\" option for %s requires a minimum API level of %d",
selectedItem.label, param.name, selectedItem.minBuildApi));
return false;
}
}
}
}
return true;
}