Search in sources :

Example 26 with Build

use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.

the class Mocks method successBuild.

/**
 * MOCK
 *
 * @param properties - properties to set
 * @return success build with {@link Properties}
 */
public static Build successBuild(Properties properties) {
    Build build = createNotFailedBuildMock("/guestAuth/app/rest/builds/id:783912", "2459", "Checkstyle_IdeaInspectionsPullRequest", "SUCCESS", "finished", "Success", null, "refs/heads/master", "20160621T230008+0700", null, null, "20160621T233008+0700");
    build.setProperties(properties);
    return build;
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build)

Example 27 with Build

use of com.github.vase4kin.teamcityapp.buildlist.api.Build in project TeamCityApp by vase4kin.

the class BuildListDataManagerImpl method loadBuilds.

/**
 * {@inheritDoc}
 */
public void loadBuilds(@NonNull Observable<Builds> call, @NonNull final OnLoadingListener<List<BuildDetails>> loadingListener) {
    mSubscriptions.clear();
    Subscription subscription = call.flatMap(new Func1<Builds, Observable<Build>>() {

        @Override
        public Observable<Build> call(Builds builds) {
            if (builds.getCount() == 0) {
                return Observable.from(Collections.<Build>emptyList());
            } else {
                mLoadMoreUrl = builds.getNextHref();
                return Observable.from(builds.getObjects());
            }
        }
    }).flatMap(new Func1<Build, Observable<Build>>() {

        @Override
        public Observable<Build> call(Build build) {
            // Make sure cache is updated
            final BuildDetails serverBuildDetails = new BuildDetailsImpl(build);
            // If server build's running update cache immediately
            if (serverBuildDetails.isRunning()) {
                return mRepository.build(build.getHref(), true);
            } else {
                // Call cache
                return mRepository.build(build.getHref(), false).flatMap(new Func1<Build, Observable<Build>>() {

                    @Override
                    public Observable<Build> call(Build build) {
                        BuildDetails cacheBuildDetails = new BuildDetailsImpl(build);
                        // If cache's not updated -> update it
                        return mRepository.build(build.getHref(), // Don't update cache if server and cache builds are finished
                        !(serverBuildDetails.isFinished() == cacheBuildDetails.isFinished()));
                    }
                });
            }
        }
    }).flatMap(new Func1<Build, Observable<BuildDetails>>() {

        @Override
        public Observable<BuildDetails> call(Build build) {
            return Observable.<BuildDetails>just(new BuildDetailsImpl(build));
        }
    }).toSortedList(new Func2<BuildDetails, BuildDetails, Integer>() {

        @Override
        public Integer call(BuildDetails build, BuildDetails build2) {
            return (build.isQueued() == build2.isQueued()) ? 0 : (build.isQueued() ? -1 : 1);
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<List<BuildDetails>>() {

        @Override
        public void onCompleted() {
        }

        @Override
        public void onError(Throwable e) {
            loadingListener.onFail(e.getMessage());
        }

        @Override
        public void onNext(List<BuildDetails> builds) {
            loadingListener.onSuccess(builds);
        }
    });
    mSubscriptions.add(subscription);
}
Also used : BuildDetails(com.github.vase4kin.teamcityapp.overview.data.BuildDetails) Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) Observable(rx.Observable) BuildDetailsImpl(com.github.vase4kin.teamcityapp.overview.data.BuildDetailsImpl) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) List(java.util.List) Subscription(rx.Subscription) Func1(rx.functions.Func1) Func2(rx.functions.Func2)

Aggregations

Build (com.github.vase4kin.teamcityapp.buildlist.api.Build)27 Intent (android.content.Intent)14 Test (org.junit.Test)14 Builds (com.github.vase4kin.teamcityapp.buildlist.api.Builds)6 HttpException (retrofit2.adapter.rxjava.HttpException)6 Bundle (android.os.Bundle)5 ArrayList (java.util.ArrayList)5 Subscription (rx.Subscription)5 Properties (com.github.vase4kin.teamcityapp.properties.api.Properties)4 CompositeSubscription (rx.subscriptions.CompositeSubscription)3 Instrumentation (android.app.Instrumentation)2 Agent (com.github.vase4kin.teamcityapp.agents.api.Agent)2 BuildDetailsActivity (com.github.vase4kin.teamcityapp.build_details.view.BuildDetailsActivity)2 Triggered (com.github.vase4kin.teamcityapp.buildlist.api.Triggered)2 User (com.github.vase4kin.teamcityapp.buildlist.api.User)2 RunBuildActivity (com.github.vase4kin.teamcityapp.runbuild.view.RunBuildActivity)2 Agents (com.github.vase4kin.teamcityapp.agents.api.Agents)1 Artifacts (com.github.vase4kin.teamcityapp.artifact.api.Artifacts)1 BuildCancelRequest (com.github.vase4kin.teamcityapp.build_details.api.BuildCancelRequest)1 Changes (com.github.vase4kin.teamcityapp.changes.api.Changes)1