Search in sources :

Example 1 with PullUseCase

use of org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase in project pictureapp by EyeSeeTea.

the class ProgressActivity method initializeDependencies.

private void initializeDependencies() {
    AuthenticationManager authenticationManager = new AuthenticationManager(this);
    IPullController pullController = new PullController(this);
    IAsyncExecutor asyncExecutor = new AsyncExecutor();
    IMainExecutor mainExecutor = new UIThreadExecutor();
    mLogoutUseCase = new LogoutUseCase(authenticationManager);
    mPullUseCase = new PullUseCase(pullController, asyncExecutor, mainExecutor);
}
Also used : AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) IPullController(org.eyeseetea.malariacare.domain.boundary.IPullController) PullUseCase(org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase) PullController(org.eyeseetea.malariacare.data.sync.importer.PullController) IPullController(org.eyeseetea.malariacare.domain.boundary.IPullController) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)

Example 2 with PullUseCase

use of org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase in project pictureapp by EyeSeeTea.

the class SplashScreenActivity method init.

private void init() {
    LocationMemory.getInstance().init(getApplicationContext());
    D2.init(this);
    SdkQueries.createDBIndexes();
    // Added to execute a query in DB, because DBFLow doesn't do any migration until a query
    // is executed
    PopulateDB.initDBQuery();
    try {
        PostMigration.launchPostMigration();
    } catch (PostMigrationException e) {
        new AlertDialog.Builder(this).setTitle(getApplicationContext().getString(R.string.error_message)).setCancelable(false).setMessage(getApplicationContext().getString(R.string.db_migration_error)).setNeutralButton(android.R.string.ok, null).create().show();
    }
    if (!BuildConfig.multiuser) {
        Log.i(TAG, "Pull on SplashScreen ...");
        PullController pullController = new PullController(getApplication().getApplicationContext());
        IAsyncExecutor asyncExecutor = new AsyncExecutor();
        IMainExecutor mainExecutor = new UIThreadExecutor();
        PullUseCase pullUseCase = new PullUseCase(pullController, asyncExecutor, mainExecutor);
        PullFilters pullFilters = new PullFilters();
        pullFilters.setDemo(true);
        pullUseCase.execute(pullFilters, new PullUseCase.Callback() {

            @Override
            public void onComplete() {
                Log.d(this.getClass().getSimpleName(), "pull complete");
                try {
                    NavigationBuilder.getInstance().buildController(Tab.getFirstTab());
                } catch (LoadingNavigationControllerException ex) {
                    onError(ex.getMessage());
                }
            }

            @Override
            public void onStep(PullStep step) {
                Log.d(this.getClass().getSimpleName(), step.toString());
            }

            @Override
            public void onError(String message) {
                Log.e(this.getClass().getSimpleName(), message);
            }

            @Override
            public void onNetworkError() {
                Log.e(this.getClass().getSimpleName(), "Network Error");
            }

            @Override
            public void onPullConversionError() {
                Log.e(this.getClass().getSimpleName(), "Pull Conversion Error");
            }

            @Override
            public void onCancel() {
                Log.e(this.getClass().getSimpleName(), "Pull oncancel");
            }
        });
    }
}
Also used : AlertDialog(android.app.AlertDialog) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) PullStep(org.eyeseetea.malariacare.domain.usecase.pull.PullStep) PullController(org.eyeseetea.malariacare.data.sync.importer.PullController) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor) LoadingNavigationControllerException(org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException) PullUseCase(org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase) PostMigrationException(org.eyeseetea.malariacare.domain.exception.PostMigrationException) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) PullFilters(org.eyeseetea.malariacare.domain.usecase.pull.PullFilters) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)

Example 3 with PullUseCase

use of org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase in project pictureapp by EyeSeeTea.

the class LoginActivityStrategy method executePullDemo.

private void executePullDemo() {
    PullController pullController = new PullController(loginActivity);
    IAsyncExecutor asyncExecutor = new AsyncExecutor();
    IMainExecutor mainExecutor = new UIThreadExecutor();
    PullUseCase pullUseCase = new PullUseCase(pullController, asyncExecutor, mainExecutor);
    PullFilters pullFilters = new PullFilters();
    pullFilters.setDemo(true);
    pullUseCase.execute(pullFilters, new PullUseCase.Callback() {

        @Override
        public void onComplete() {
            loginActivity.hideProgressBar();
            finishAndGo(DashboardActivity.class);
        }

        @Override
        public void onStep(PullStep step) {
            Log.d(this.getClass().getSimpleName(), step.toString());
        }

        @Override
        public void onError(String message) {
            loginActivity.hideProgressBar();
            Log.e(this.getClass().getSimpleName(), message);
        }

        @Override
        public void onPullConversionError() {
            loginActivity.hideProgressBar();
            Log.e(this.getClass().getSimpleName(), "Pull conversion error");
        }

        @Override
        public void onCancel() {
            loginActivity.hideProgressBar();
            Log.e(this.getClass().getSimpleName(), "Pull cancel");
        }

        @Override
        public void onNetworkError() {
            loginActivity.hideProgressBar();
            Log.e(this.getClass().getSimpleName(), "Network Error");
        }
    });
}
Also used : PullUseCase(org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) DashboardActivity(org.eyeseetea.malariacare.DashboardActivity) PullFilters(org.eyeseetea.malariacare.domain.usecase.pull.PullFilters) PullStep(org.eyeseetea.malariacare.domain.usecase.pull.PullStep) PullController(org.eyeseetea.malariacare.data.sync.importer.PullController) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)

Aggregations

PullController (org.eyeseetea.malariacare.data.sync.importer.PullController)3 IAsyncExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)3 IMainExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)3 PullUseCase (org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase)3 AsyncExecutor (org.eyeseetea.malariacare.presentation.executors.AsyncExecutor)3 UIThreadExecutor (org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor)3 PullFilters (org.eyeseetea.malariacare.domain.usecase.pull.PullFilters)2 PullStep (org.eyeseetea.malariacare.domain.usecase.pull.PullStep)2 AlertDialog (android.app.AlertDialog)1 DashboardActivity (org.eyeseetea.malariacare.DashboardActivity)1 AuthenticationManager (org.eyeseetea.malariacare.data.authentication.AuthenticationManager)1 IPullController (org.eyeseetea.malariacare.domain.boundary.IPullController)1 LoadingNavigationControllerException (org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException)1 PostMigrationException (org.eyeseetea.malariacare.domain.exception.PostMigrationException)1 LogoutUseCase (org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)1