Search in sources :

Example 6 with StudioProgressRunner

use of com.android.tools.idea.sdk.progress.StudioProgressRunner in project android by JetBrains.

the class StudioSdkUtil method reloadRemoteSdkWithModalProgress.

/**
   * Convenience method to reload the local and remote SDK, showing a modal, non-cancellable progress window.
   */
public static void reloadRemoteSdkWithModalProgress() {
    final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    StudioProgressRunner runner = new StudioProgressRunner(true, false, "Refreshing SDK", false, null);
    StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(StudioSdkUtil.class);
    RepoManager sdkManager = sdkHandler.getSdkManager(progress);
    sdkManager.load(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, null, null, null, runner, new StudioDownloader(null), StudioSettingsController.getInstance(), true);
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) RepoManager(com.android.repository.api.RepoManager) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler)

Example 7 with StudioProgressRunner

use of com.android.tools.idea.sdk.progress.StudioProgressRunner in project android by JetBrains.

the class FormFactorApiComboBox method loadRemoteTargets.

private void loadRemoteTargets(final int minSdkLevel, final Runnable completedCallback, final Runnable foundItemsCallback, final Runnable noItemsCallback) {
    AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    final Runnable runCallbacks = () -> {
        if (completedCallback != null) {
            completedCallback.run();
        }
        if (getItemCount() > 0) {
            if (foundItemsCallback != null) {
                foundItemsCallback.run();
            }
        } else {
            if (noItemsCallback != null) {
                noItemsCallback.run();
            }
        }
    };
    RepoManager.RepoLoadedCallback onComplete = packages -> {
        addPackages(packages.getNewPkgs(), minSdkLevel);
        addOfflineLevels();
        loadSavedApi();
        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(packages.getLocalPackages().values(), minSdkLevel);
    Runnable onError = () -> ApplicationManager.getApplication().invokeLater(() -> {
        addOfflineLevels();
        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 : Iterables(com.google.common.collect.Iterables) ScopedStateStore(com.android.tools.idea.wizard.dynamic.ScopedStateStore) ActionListener(java.awt.event.ActionListener) ModalityState(com.intellij.openapi.application.ModalityState) WizardConstants(com.android.tools.idea.wizard.WizardConstants) JavaSdkVersion(com.intellij.openapi.projectRoots.JavaSdkVersion) INSTALL_REQUESTS_KEY(com.android.tools.idea.wizard.WizardConstants.INSTALL_REQUESTS_KEY) RemotePackage(com.android.repository.api.RemotePackage) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) ConfigureAndroidProjectPath(com.android.tools.idea.npw.deprecated.ConfigureAndroidProjectPath) 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) AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) AndroidTargetManager(com.android.sdklib.repository.targets.AndroidTargetManager) DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) RepoPackage(com.android.repository.api.RepoPackage) Collection(java.util.Collection) TemplateMetadata(com.android.tools.idea.templates.TemplateMetadata) Set(java.util.Set) AndroidSdkUtils(org.jetbrains.android.sdk.AndroidSdkUtils) TemplateUtils(com.android.tools.idea.templates.TemplateUtils) com.android.sdklib(com.android.sdklib) IdDisplay(com.android.sdklib.repository.IdDisplay) ScopedDataBinder(com.android.tools.idea.wizard.dynamic.ScopedDataBinder) Sets(com.google.common.collect.Sets) Sdk(com.intellij.openapi.projectRoots.Sdk) ProgressIndicator(com.android.repository.api.ProgressIndicator) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) Nullable(org.jetbrains.annotations.Nullable) ApiComboBoxItem(com.android.tools.idea.ui.ApiComboBoxItem) List(java.util.List) StudioSettingsController(com.android.tools.idea.sdk.StudioSettingsController) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) ATTR_MIN_API(com.android.tools.idea.templates.TemplateMetadata.ATTR_MIN_API) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Key(com.android.tools.idea.wizard.dynamic.ScopedStateStore.Key) RepoManager(com.android.repository.api.RepoManager) SystemImage(com.android.sdklib.repository.targets.SystemImage) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) javax.swing(javax.swing) 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 8 with StudioProgressRunner

use of com.android.tools.idea.sdk.progress.StudioProgressRunner in project android by JetBrains.

the class SdkUpdaterConfigPanel method refresh.

/**
   * Revalidates and refreshes our packages. Notifies platform and tools components of the start and end, so they can update their UIs.
   */
public void refresh() {
    validate();
    myPlatformComponentsPanel.startLoading();
    myToolComponentsPanel.startLoading();
    // TODO: make progress runner handle invokes?
    Project[] projects = ProjectManager.getInstance().getOpenProjects();
    StudioProgressRunner progressRunner = new StudioProgressRunner(false, false, "Loading SDK", false, projects.length == 0 ? null : projects[0]);
    myConfigurable.getRepoManager().load(0, ImmutableList.of(myLocalUpdater), ImmutableList.of(myRemoteUpdater), null, progressRunner, myDownloader, mySettings, false);
}
Also used : Project(com.intellij.openapi.project.Project) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner)

Aggregations

StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)8 RepoManager (com.android.repository.api.RepoManager)7 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)6 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)6 NotNull (org.jetbrains.annotations.NotNull)6 RemotePackage (com.android.repository.api.RemotePackage)5 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)5 ImmutableList (com.google.common.collect.ImmutableList)5 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)4 StudioSettingsController (com.android.tools.idea.sdk.StudioSettingsController)4 Lists (com.google.common.collect.Lists)3 Project (com.intellij.openapi.project.Project)3 Nullable (org.jetbrains.annotations.Nullable)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 AndroidVersion (com.android.sdklib.AndroidVersion)2 IdDisplay (com.android.sdklib.repository.IdDisplay)2 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)2 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)2