Search in sources :

Example 1 with LogoutUseCase

use of org.eyeseetea.malariacare.domain.usecase.LogoutUseCase 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 LogoutUseCase

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

the class PushServiceStrategy method logout.

public void logout() {
    IAuthenticationManager authenticationManager;
    LogoutUseCase logoutUseCase;
    authenticationManager = new AuthenticationManager(mPushService);
    logoutUseCase = new LogoutUseCase(authenticationManager);
    AlarmPushReceiver.cancelPushAlarm(mPushService);
    logoutUseCase.execute(new LogoutUseCase.Callback() {

        @Override
        public void onLogoutSuccess() {
            if (!EyeSeeTeaApplication.getInstance().isAppWentToBg()) {
                Intent loginIntent = new Intent(mPushService, LoginActivity.class);
                loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                mPushService.startActivity(loginIntent);
            }
        }

        @Override
        public void onLogoutError(String message) {
            Log.d(TAG, message);
        }
    });
}
Also used : IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) LoginActivity(org.eyeseetea.malariacare.LoginActivity) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase) Intent(android.content.Intent)

Example 3 with LogoutUseCase

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

the class SettingsActivityStrategy method onCreate.

@Override
public void onCreate() {
    mAuthenticationManager = new AuthenticationManager(settingsActivity);
    mLogoutUseCase = new LogoutUseCase(mAuthenticationManager);
    IntentFilter screenStateFilter = new IntentFilter();
    screenStateFilter.addAction(Intent.ACTION_SCREEN_ON);
    screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
    settingsActivity.registerReceiver(mScreenOffReceiver, screenStateFilter);
}
Also used : IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) IntentFilter(android.content.IntentFilter) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)

Example 4 with LogoutUseCase

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

the class LogoutAndLoginRequiredOnPreferenceClickListener method logout.

private void logout() {
    Log.d(TAG, "Logging out...");
    AuthenticationManager authenticationManager = new AuthenticationManager(settingsActivity);
    LogoutUseCase logoutUseCase = new LogoutUseCase(authenticationManager);
    logoutUseCase.execute(new LogoutUseCase.Callback() {

        @Override
        public void onLogoutSuccess() {
            Intent loginIntent = new Intent(settingsActivity, LoginActivity.class);
            settingsActivity.finish();
            settingsActivity.startActivity(loginIntent);
        }

        @Override
        public void onLogoutError(String message) {
            Log.e(TAG, message);
        }
    });
}
Also used : AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) LoginActivity(org.eyeseetea.malariacare.LoginActivity) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase) Intent(android.content.Intent)

Example 5 with LogoutUseCase

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

the class DashboardActivity method executeLogout.

public void executeLogout() {
    IAuthenticationManager iAuthenticationManager = new AuthenticationManager(this);
    LogoutUseCase logoutUseCase = new LogoutUseCase(iAuthenticationManager);
    AlarmPushReceiver.cancelPushAlarm(this);
    logoutUseCase.execute(new LogoutUseCase.Callback() {

        @Override
        public void onLogoutSuccess() {
            DashboardActivityStrategy.onLogoutSuccess();
        }

        @Override
        public void onLogoutError(String message) {
            Log.e("." + this.getClass().getSimpleName(), message);
        }
    });
}
Also used : IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)

Aggregations

AuthenticationManager (org.eyeseetea.malariacare.data.authentication.AuthenticationManager)7 LogoutUseCase (org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)7 IAuthenticationManager (org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager)5 Intent (android.content.Intent)2 LoginActivity (org.eyeseetea.malariacare.LoginActivity)2 IntentFilter (android.content.IntentFilter)1 CredentialsLocalDataSource (org.eyeseetea.malariacare.data.database.CredentialsLocalDataSource)1 PullController (org.eyeseetea.malariacare.data.sync.importer.PullController)1 IPullController (org.eyeseetea.malariacare.domain.boundary.IPullController)1 IAsyncExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)1 IMainExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)1 ICredentialsRepository (org.eyeseetea.malariacare.domain.boundary.repositories.ICredentialsRepository)1 Credentials (org.eyeseetea.malariacare.domain.entity.Credentials)1 PullUseCase (org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase)1 AsyncExecutor (org.eyeseetea.malariacare.presentation.executors.AsyncExecutor)1 UIThreadExecutor (org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor)1