use of com.android.repository.api.RepoPackage in project android by JetBrains.
the class PlatformComponentsPanel method updatePlatformItems.
private void updatePlatformItems() {
myPlatformDetailsRootNode.removeAllChildren();
myPlatformSummaryRootNode.removeAllChildren();
myStates.clear();
List<AndroidVersion> versions = Lists.newArrayList(myCurrentPackages.keySet());
versions = Lists.reverse(versions);
for (AndroidVersion version : versions) {
Set<UpdaterTreeNode> versionNodes = Sets.newHashSet();
UpdaterTreeNode marker = new ParentTreeNode(version);
myPlatformDetailsRootNode.add(marker);
boolean obsolete = false;
for (UpdatablePackage info : myCurrentPackages.get(version)) {
RepoPackage pkg = info.getRepresentative();
PackageNodeModel model = new PackageNodeModel(info);
myStates.add(model);
UpdaterTreeNode node = new DetailsTreeNode(model, myModificationListener, myConfigurable);
marker.add(node);
versionNodes.add(node);
if (pkg.obsolete() && pkg.getTypeDetails() instanceof DetailsTypes.PlatformDetailsType) {
obsolete = true;
}
}
if (!obsolete) {
SummaryTreeNode node = SummaryTreeNode.createNode(version, versionNodes);
if (node != null) {
myPlatformSummaryRootNode.add(node);
}
}
}
refreshModified();
SdkUpdaterConfigPanel.resizeColumnsToFit(myPlatformDetailTable);
SdkUpdaterConfigPanel.resizeColumnsToFit(myPlatformSummaryTable);
myPlatformDetailTable.updateUI();
myPlatformSummaryTable.updateUI();
TreeUtil.expandAll(myPlatformDetailTable.getTree());
TreeUtil.expandAll(myPlatformSummaryTable.getTree());
}
use of com.android.repository.api.RepoPackage in project android by JetBrains.
the class UnresolvedDependenciesReporter method report.
private void report(@NotNull String dependency, @NotNull Module module, @Nullable VirtualFile buildFile) {
String group = "Unresolved Android dependencies";
GradleCoordinate coordinate = GradleCoordinate.parseCoordinateString(dependency);
RepoPackage constraintPackage = null;
if (coordinate != null) {
ProgressIndicator indicator = new StudioLoggerProgressIndicator(getClass());
reloadRemoteSdkWithModalProgress();
Collection<RemotePackage> remotePackages = getRemotePackages(indicator);
constraintPackage = findBestPackageMatching(coordinate, remotePackages);
}
List<NotificationHyperlink> quickFixes = new ArrayList<>();
if (dependency.startsWith("com.android.support.constraint:constraint-layout:") && !canGetConstraintLayoutFromSdkManager(module)) {
quickFixes.add(new FixAndroidGradlePluginVersionHyperlink());
} else if (constraintPackage != null) {
quickFixes.add(new InstallArtifactHyperlink(constraintPackage.getPath()));
} else if (dependency.startsWith("com.android.support")) {
quickFixes.add(new InstallRepositoryHyperlink(ANDROID));
} else if (dependency.startsWith("com.google.android")) {
quickFixes.add(new InstallRepositoryHyperlink(GOOGLE));
} else {
group = "Unresolved dependencies";
Project project = module.getProject();
if (isOfflineBuildModeEnabled(project)) {
quickFixes.add(new DisableOfflineModeHyperlink());
}
}
String text = "Failed to resolve: " + dependency;
SyncMessage message;
if (buildFile != null) {
PositionInFile position = findDependencyPosition(dependency, buildFile);
message = new SyncMessage(module.getProject(), group, ERROR, position, text);
String hyperlinkText = position.line > -1 ? "Show in File" : "Open File";
quickFixes.add(new OpenFileHyperlink(buildFile.getPath(), hyperlinkText, position.line, position.column));
} else {
message = new SyncMessage(group, ERROR, NonNavigatable.INSTANCE, text);
}
if (IdeInfo.getInstance().isAndroidStudio()) {
if (coordinate != null) {
quickFixes.add(new ShowDependencyInProjectStructureHyperlink(module, coordinate));
}
}
message.add(quickFixes);
getSyncMessages(module).report(message);
}
use of com.android.repository.api.RepoPackage in project android by JetBrains.
the class FormFactorApiComboBox method addPackages.
private void addPackages(@NotNull Collection<? extends RepoPackage> packages, int minSdkLevel) {
Iterable<? extends RepoPackage> filter = Iterables.filter(packages, FormFactorUtils.getMinSdkPackageFilter(myFormFactor, minSdkLevel));
List<RepoPackage> sorted = Lists.newArrayList(filter);
Collections.sort(sorted, (repoPackage, other) -> FormFactorUtils.getAndroidVersion(repoPackage).compareTo(FormFactorUtils.getAndroidVersion(other)));
int existingApiLevel = -1;
int prevInsertedApiLevel = -1;
int index = -1;
for (RepoPackage info : sorted) {
int apiLevel = FormFactorUtils.getFeatureLevel(info);
while (apiLevel > existingApiLevel) {
existingApiLevel = ++index < getItemCount() ? getItemAt(index).myApiLevel : Integer.MAX_VALUE;
}
if (apiLevel != existingApiLevel && apiLevel != prevInsertedApiLevel) {
insertItemAt(new AndroidTargetComboBoxItem(info), index++);
prevInsertedApiLevel = apiLevel;
}
}
}
use of com.android.repository.api.RepoPackage in project android by JetBrains.
the class UpdatablePackage method isUpdateFor.
@Override
public boolean isUpdateFor(UpdatableExternalComponent c) {
if (c == null) {
return false;
}
Object otherKey = c.getKey();
if (!(otherKey instanceof RepoPackage)) {
return false;
}
RepoPackage otherPackage = (RepoPackage) otherKey;
return myPackage.getPath().equals(otherPackage.getPath()) && myPackage.getVersion().compareTo(otherPackage.getVersion()) > 0;
}
use of com.android.repository.api.RepoPackage in project android by JetBrains.
the class AndroidVersionsInfo method addPackages.
private void addPackages(@NotNull FormFactor myFormFactor, @NotNull List<VersionItem> versionItemList, @NotNull Collection<? extends RepoPackage> packages, int minSdkLevel) {
List<RepoPackage> sorted = packages.stream().filter(repoPackage -> repoPackage != null && filterPkgDesc(repoPackage, myFormFactor, minSdkLevel)).collect(Collectors.toList());
Collections.sort(sorted, (repoPackage, other) -> getAndroidVersion(repoPackage).compareTo(getAndroidVersion(other)));
int existingApiLevel = -1;
int prevInsertedApiLevel = -1;
int index = -1;
for (RepoPackage info : sorted) {
int apiLevel = getFeatureLevel(info);
while (apiLevel > existingApiLevel) {
existingApiLevel = ++index < versionItemList.size() ? versionItemList.get(index).myApiLevel : Integer.MAX_VALUE;
}
if (apiLevel != existingApiLevel && apiLevel != prevInsertedApiLevel) {
versionItemList.add(index++, new VersionItem(info));
prevInsertedApiLevel = apiLevel;
}
}
}
Aggregations