Search in sources :

Example 1 with StudioDownloader

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();
}
Also used : AncestorListenerAdapter(com.intellij.ui.AncestorListenerAdapter) AncestorEvent(javax.swing.event.AncestorEvent) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with StudioDownloader

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);
            }
        }
    }
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) File(java.io.File) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader)

Example 3 with StudioDownloader

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);
}
Also used : StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) RepoProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.RepoProgressIndicatorAdapter) ProgressWindow(com.intellij.openapi.progress.util.ProgressWindow) RemotePackage(com.android.repository.api.RemotePackage)

Example 4 with StudioDownloader

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);
}
Also used : java.util(java.util) SdkConstants(com.android.SdkConstants) ModalityState(com.intellij.openapi.application.ModalityState) RemotePackage(com.android.repository.api.RemotePackage) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) AndroidTargetHash(com.android.sdklib.AndroidTargetHash) AndroidTargetManager(com.android.sdklib.repository.targets.AndroidTargetManager) DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) FormFactor(com.android.tools.idea.npw.FormFactor) RepoPackage(com.android.repository.api.RepoPackage) AndroidVersion(com.android.sdklib.AndroidVersion) TemplateMetadata(com.android.tools.idea.templates.TemplateMetadata) AndroidSdkUtils(org.jetbrains.android.sdk.AndroidSdkUtils) TemplateUtils(com.android.tools.idea.templates.TemplateUtils) Collectors(java.util.stream.Collectors) IdDisplay(com.android.sdklib.repository.IdDisplay) Sets(com.google.common.collect.Sets) ProgressIndicator(com.android.repository.api.ProgressIndicator) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) IAndroidTarget(com.android.sdklib.IAndroidTarget) Nullable(org.jetbrains.annotations.Nullable) SdkVersionInfo(com.android.sdklib.SdkVersionInfo) StudioSettingsController(com.android.tools.idea.sdk.StudioSettingsController) TypeDetails(com.android.repository.impl.meta.TypeDetails) ApplicationManager(com.intellij.openapi.application.ApplicationManager) RepoManager(com.android.repository.api.RepoManager) SystemImage(com.android.sdklib.repository.targets.SystemImage) NotNull(org.jetbrains.annotations.NotNull) RepoManager(com.android.repository.api.RepoManager) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader)

Example 5 with StudioDownloader

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();
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)14 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)9 RepoManager (com.android.repository.api.RepoManager)7 NotNull (org.jetbrains.annotations.NotNull)6 RemotePackage (com.android.repository.api.RemotePackage)5 StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)5 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)4 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)4 StudioSettingsController (com.android.tools.idea.sdk.StudioSettingsController)4 ImmutableList (com.google.common.collect.ImmutableList)4 Nullable (org.jetbrains.annotations.Nullable)4 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)3 ProgressIndicator (com.android.repository.api.ProgressIndicator)2 DEFAULT_EXPIRATION_PERIOD_MS (com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS)2 RepoPackage (com.android.repository.api.RepoPackage)2 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)2 IdDisplay (com.android.sdklib.repository.IdDisplay)2 AndroidTargetManager (com.android.sdklib.repository.targets.AndroidTargetManager)2 SystemImage (com.android.sdklib.repository.targets.SystemImage)2 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)2