/*
 * Copyright (c) 2004-2019, University of Oslo
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 * Neither the name of the HISP project nor the names of its contributors may
 * be used to endorse or promote products derived from this software without
 * specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package org.hisp.dhis.android.core.fileresource.internal;

import org.hisp.dhis.android.core.arch.api.executors.internal.RxAPICallExecutor;
import org.hisp.dhis.android.core.arch.call.D2Progress;
import org.hisp.dhis.android.core.arch.call.internal.D2ProgressManager;
import org.hisp.dhis.android.core.fileresource.FileResource;
import org.hisp.dhis.android.core.systeminfo.SystemInfo;
import org.hisp.dhis.android.core.systeminfo.internal.SystemInfoModuleDownloader;

import javax.inject.Inject;

import androidx.annotation.NonNull;
import dagger.Reusable;
import io.reactivex.Observable;

@Reusable
public class FileResourceCall {

    private final RxAPICallExecutor rxCallExecutor;

    private final SystemInfoModuleDownloader systemInfoDownloader;
    private final FileResourceModuleDownloader fileResourceModuleDownloader;

    @Inject
    FileResourceCall(@NonNull RxAPICallExecutor rxCallExecutor,
                     @NonNull SystemInfoModuleDownloader systemInfoDownloader,
                     @NonNull FileResourceModuleDownloader fileResourceModuleDownloader) {
        this.rxCallExecutor = rxCallExecutor;
        this.systemInfoDownloader = systemInfoDownloader;
        this.fileResourceModuleDownloader = fileResourceModuleDownloader;
    }

    public Observable<D2Progress> download() {
        D2ProgressManager progressManager = new D2ProgressManager(2);

        return rxCallExecutor.wrapObservableTransactionally(
                systemInfoDownloader.downloadMetadata().andThen(Observable.create(emitter -> {

                    emitter.onNext(progressManager.increaseProgress(SystemInfo.class, false));

                    fileResourceModuleDownloader.downloadMetadata().call();
                    emitter.onNext(progressManager.increaseProgress(FileResource.class, false));

                    emitter.onComplete();

                })), true);
    }

    public void blockingDownload() {
        download().blockingSubscribe();
    }
}
@@ -1609,16 +1609,53 @@
 ernal;%0A%0A
+import androidx.annotation.NonNull;%0A%0A
 import o
@@ -1920,212 +1920,37 @@
 ce;%0A
-import org.hisp.dhis.android.core.systeminfo.SystemInfo;%0Aimport org.hisp.dhis.android.core.systeminfo.internal.SystemInfoModuleDownloader;%0A%0Aimport javax.inject.Inject;%0A%0Aimport androidx.annotation.NonNull;
+%0Aimport javax.inject.Inject;%0A
 %0Aimp
@@ -2103,75 +2103,8 @@
 r;%0A%0A
-    private final SystemInfoModuleDownloader systemInfoDownloader;%0A
     
@@ -2257,87 +2257,8 @@
 or,%0A
-                     @NonNull SystemInfoModuleDownloader systemInfoDownloader,%0A
     
@@ -2394,66 +2394,8 @@
 or;%0A
-        this.systemInfoDownloader = systemInfoDownloader;%0A
     
@@ -2584,17 +2584,17 @@
 Manager(
-2
+1
 );%0A%0A    
@@ -2670,182 +2670,38 @@
     
-systemInfoDownloader.downloadMetadata().andThen(Observable.create(emitter -%3E %7B%0A%0A                    emitter.onNext(progressManager.increaseProgress(SystemInfo.class, false));
+Observable.create(emitter -%3E %7B
 %0A%0A  
@@ -2933,17 +2933,16 @@
       %7D)
-)
 , true);

Remove system info call from FileResourceCall