Search in sources :

Example 11 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project android by JetBrains.

the class TemplateWizard method getSdk.

@Nullable
protected static Sdk getSdk(int apiLevel) {
    for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
        AndroidPlatform androidPlatform = AndroidPlatform.parse(sdk);
        if (androidPlatform != null) {
            AndroidSdkData sdkData = androidPlatform.getSdkData();
            IAndroidTarget target = sdkData.findTargetByApiLevel(Integer.toString(apiLevel));
            if (target != null) {
                return sdk;
            }
        }
    }
    return null;
}
Also used : AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) Sdk(com.intellij.openapi.projectRoots.Sdk) IAndroidTarget(com.android.sdklib.IAndroidTarget) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project android by JetBrains.

the class ConstantFieldConverter method getFilteringSet.

@Nullable
private static Set<String> getFilteringSet(@NotNull ConvertContext context) {
    final Module module = context.getModule();
    if (module == null) {
        return null;
    }
    final AndroidPlatform platform = AndroidPlatform.getInstance(module);
    if (platform == null) {
        return null;
    }
    IAndroidTarget target = platform.getTarget();
    final AndroidTargetData targetData = platform.getSdkData().getTargetData(target);
    DomElement element = context.getInvocationElement().getParent();
    if (element instanceof Category) {
        return targetData.getStaticConstantsData().getCategories();
    } else if (element instanceof Action) {
        element = element.getParent();
        if (element instanceof IntentFilter) {
            element = element.getParent();
            if (element instanceof Activity) {
                return targetData.getStaticConstantsData().getActivityActions();
            } else if (element instanceof Service) {
                return targetData.getStaticConstantsData().getServiceActions();
            } else if (element instanceof Receiver) {
                return targetData.getStaticConstantsData().getReceiverActions();
            }
        }
    }
    return null;
}
Also used : AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) IAndroidTarget(com.android.sdklib.IAndroidTarget) Module(com.intellij.openapi.module.Module) AndroidTargetData(org.jetbrains.android.sdk.AndroidTargetData) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project android by JetBrains.

the class AndroidSdkConfigurableForm method updateBuildTargets.

private void updateBuildTargets(AndroidSdkData androidSdkData, IAndroidTarget buildTarget) {
    myBuildTargetsModel.removeAllElements();
    if (androidSdkData != null) {
        for (IAndroidTarget target : androidSdkData.getTargets()) {
            myBuildTargetsModel.addElement(target);
        }
    }
    if (buildTarget != null) {
        for (int i = 0; i < myBuildTargetsModel.getSize(); i++) {
            IAndroidTarget target = (IAndroidTarget) myBuildTargetsModel.getElementAt(i);
            if (buildTarget.hashString().equals(target.hashString())) {
                myBuildTargetComboBox.setSelectedIndex(i);
                return;
            }
        }
    }
    myBuildTargetComboBox.setSelectedItem(null);
}
Also used : IAndroidTarget(com.android.sdklib.IAndroidTarget)

Example 14 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project android by JetBrains.

the class AndroidSdkData method getTargets.

@NotNull
public IAndroidTarget[] getTargets(boolean includeAddOns) {
    Collection<IAndroidTarget> targets = getTargetCollection();
    Collection<IAndroidTarget> result = Lists.newArrayList();
    if (!includeAddOns) {
        for (IAndroidTarget target : targets) {
            if (target.isPlatform()) {
                result.add(target);
            }
        }
    } else {
        result.addAll(targets);
    }
    return result.toArray(new IAndroidTarget[result.size()]);
}
Also used : IAndroidTarget(com.android.sdklib.IAndroidTarget) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with IAndroidTarget

use of com.android.sdklib.IAndroidTarget in project android by JetBrains.

the class AndroidSdkUtils method findBestTarget.

@Nullable
private static IAndroidTarget findBestTarget(@NotNull IAndroidTarget[] targets) {
    IAndroidTarget bestTarget = null;
    int maxApiLevel = -1;
    for (IAndroidTarget target : targets) {
        AndroidVersion version = target.getVersion();
        if (target.isPlatform() && !version.isPreview() && version.getApiLevel() > maxApiLevel) {
            bestTarget = target;
            maxApiLevel = version.getApiLevel();
        }
    }
    return bestTarget;
}
Also used : IAndroidTarget(com.android.sdklib.IAndroidTarget) AndroidVersion(com.android.sdklib.AndroidVersion) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IAndroidTarget (com.android.sdklib.IAndroidTarget)105 Nullable (org.jetbrains.annotations.Nullable)24 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 Module (com.intellij.openapi.module.Module)17 NotNull (org.jetbrains.annotations.NotNull)16 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)15 Sdk (com.intellij.openapi.projectRoots.Sdk)14 File (java.io.File)13 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)13 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)13 AndroidVersion (com.android.sdklib.AndroidVersion)11 Device (com.android.sdklib.devices.Device)11 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)9 State (com.android.sdklib.devices.State)8 AndroidSdkAdditionalData (org.jetbrains.android.sdk.AndroidSdkAdditionalData)8 AndroidTargetData (org.jetbrains.android.sdk.AndroidTargetData)8 Configuration (com.android.tools.idea.configurations.Configuration)7 CompatibilityRenderTarget (com.android.tools.idea.rendering.multi.CompatibilityRenderTarget)7 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)7 ConfigurationManager (com.android.tools.idea.configurations.ConfigurationManager)6