use of com.android.tools.idea.sdk.StudioDownloader in project android by JetBrains.
the class SdkUpdaterConfigurable method createComponent.
@Nullable
@Override
public JComponent createComponent() {
myChannelChangedCallback = new Runnable() {
@Override
public void run() {
Channel channel = StudioSettingsController.getInstance().getChannel();
if (myCurrentChannel == null) {
myCurrentChannel = channel;
}
if (!Objects.equal(channel, myCurrentChannel)) {
myCurrentChannel = channel;
myPanel.refresh();
}
}
};
myPanel = new SdkUpdaterConfigPanel(myChannelChangedCallback, new StudioDownloader(), StudioSettingsController.getInstance(), this);
JComponent component = myPanel.getComponent();
component.addAncestorListener(new AncestorListenerAdapter() {
@Override
public void ancestorAdded(AncestorEvent event) {
myChannelChangedCallback.run();
}
});
return myPanel.getComponent();
}
use of com.android.tools.idea.sdk.StudioDownloader in project android by JetBrains.
the class InstallComponentsPath method deriveValues.
@Override
public void deriveValues(Set<ScopedStateStore.Key> modified) {
super.deriveValues(modified);
if (modified.contains(WizardConstants.KEY_SDK_INSTALL_LOCATION)) {
String sdkPath = myState.get(WizardConstants.KEY_SDK_INSTALL_LOCATION);
if (sdkPath != null) {
File sdkLocation = new File(sdkPath);
if (!FileUtil.filesEqual(myLocalHandler.getLocation(), sdkLocation)) {
myLocalHandler = AndroidSdkHandler.getInstance(sdkLocation);
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
myLocalHandler.getSdkManager(progress).loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, progress, new StudioDownloader(), StudioSettingsController.getInstance());
myComponentInstaller = new ComponentInstaller(myLocalHandler);
myComponentTree.updateState(myLocalHandler);
}
}
}
}
use of com.android.tools.idea.sdk.StudioDownloader in project android by JetBrains.
the class InstallComponentsPath method createComponentTree.
private ComponentTreeNode createComponentTree(@NotNull FirstRunWizardMode reason, @NotNull ScopedStateStore stateStore, boolean createAvd) {
List<ComponentTreeNode> components = Lists.newArrayList();
components.add(new AndroidSdk(stateStore, myInstallUpdates));
DynamicWizard wizard = getWizard();
ProgressWindow progressWindow = new ProgressWindow(false, false, null);
if (wizard != null) {
Disposer.register(wizard.getDisposable(), progressWindow);
}
com.android.repository.api.ProgressIndicator progress = new RepoProgressIndicatorAdapter(progressWindow);
RepoManager sdkManager = myLocalHandler.getSdkManager(new StudioLoggerProgressIndicator(getClass()));
sdkManager.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, progress, new StudioDownloader(progressWindow), StudioSettingsController.getInstance());
Map<String, RemotePackage> remotePackages = sdkManager.getPackages().getRemotePackages();
ComponentTreeNode platforms = Platform.createSubtree(stateStore, remotePackages, myInstallUpdates);
if (platforms != null) {
components.add(platforms);
}
if (Haxm.canRun() && reason == FirstRunWizardMode.NEW_INSTALL) {
Haxm.HaxmInstallationIntention haxmInstallationIntention = myInstallUpdates ? Haxm.HaxmInstallationIntention.INSTALL_WITH_UPDATES : Haxm.HaxmInstallationIntention.INSTALL_WITHOUT_UPDATES;
components.add(new Haxm(haxmInstallationIntention, stateStore, FirstRunWizard.KEY_CUSTOM_INSTALL));
}
if (createAvd) {
components.add(new AndroidVirtualDevice(stateStore, remotePackages, myInstallUpdates, myFileOp));
}
return new ComponentCategory("Root", "Root node that is not supposed to appear in the UI", components);
}
use of com.android.tools.idea.sdk.StudioDownloader in project android by JetBrains.
the class AndroidVersionsInfo method loadRemoteTargets.
private void loadRemoteTargets(@NotNull FormFactor myFormFactor, int minSdkLevel, @NotNull List<VersionItem> versionItemList, ItemsLoaded completedCallback) {
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
final Runnable runCallbacks = () -> {
if (completedCallback != null) {
completedCallback.onDataLoadedFinished(versionItemList);
}
};
RepoManager.RepoLoadedCallback onComplete = packages -> {
addPackages(myFormFactor, versionItemList, packages.getNewPkgs(), minSdkLevel);
addOfflineLevels(myFormFactor, versionItemList);
runCallbacks.run();
};
// We need to pick up addons that don't have a target created due to the base platform not being installed.
RepoManager.RepoLoadedCallback onLocalComplete = packages -> addPackages(myFormFactor, versionItemList, packages.getLocalPackages().values(), minSdkLevel);
Runnable onError = () -> ApplicationManager.getApplication().invokeLater(() -> {
addOfflineLevels(myFormFactor, versionItemList);
runCallbacks.run();
}, ModalityState.any());
StudioProgressRunner runner = new StudioProgressRunner(false, false, "Refreshing Targets", true, null);
sdkHandler.getSdkManager(REPO_LOG).load(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, ImmutableList.of(onLocalComplete), ImmutableList.of(onComplete), ImmutableList.of(onError), runner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
use of com.android.tools.idea.sdk.StudioDownloader in project android by JetBrains.
the class AndroidStudioWelcomeScreenProvider method fetchPackages.
@NotNull
private static Map<String, RemotePackage> fetchPackages() {
ConnectionState connectionState = checkInternetConnection();
switch(connectionState) {
case OK:
break;
case NO_CONNECTION:
return ImmutableMap.of();
default:
throw new IllegalArgumentException(connectionState.name());
}
StudioLoggerProgressIndicator logger = new StudioLoggerProgressIndicator(AndroidStudioWelcomeScreenProvider.class);
RepoManager mgr = AndroidSdks.getInstance().tryToChooseSdkHandler().getSdkManager(logger);
mgr.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, logger, new StudioDownloader(), StudioSettingsController.getInstance());
return mgr.getPackages().getRemotePackages();
}
Aggregations