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;
}
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;
}
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);
}
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()]);
}
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;
}
Aggregations