From 1d95320277846c082cda2bfcfbbfeb251d03fcc4 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Mon, 16 Jun 2014 09:33:30 +0200 Subject: [PATCH] Updated implementation of SingleSessionManager#saveAllClients for current HashMap --- .../lib/common/SingleSessionManager.java | 40 +++++-------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/com/owncloud/android/lib/common/SingleSessionManager.java b/src/com/owncloud/android/lib/common/SingleSessionManager.java index 1dec9441..f000983e 100644 --- a/src/com/owncloud/android/lib/common/SingleSessionManager.java +++ b/src/com/owncloud/android/lib/common/SingleSessionManager.java @@ -26,14 +26,13 @@ package com.owncloud.android.lib.common; import java.io.IOException; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import android.accounts.Account; -import android.accounts.AccountManager; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.content.Context; -import android.net.Uri; import android.util.Log; import com.owncloud.android.lib.common.OwnCloudClient; @@ -54,9 +53,6 @@ public class SingleSessionManager implements OwnCloudClientManager { private static final String TAG = SingleSessionManager.class.getSimpleName(); - private Map> mClientsPerServer = - new HashMap>(); - private Map mClientsWithKnownUsername = new HashMap(); @@ -167,31 +163,17 @@ public class SingleSessionManager implements OwnCloudClientManager { throws AccountNotFoundException, AuthenticatorException, IOException, OperationCanceledException { - // Get all accounts - Account [] accounts = AccountManager.get(context.getApplicationContext()) - .getAccountsByType(accountType); - - // Save cookies for all accounts - for(Account account: accounts){ - - Uri serverBaseUri = - Uri.parse(AccountUtils.getBaseUrlForAccount(context, account)); - - Map clientsPerAccount = - mClientsPerServer.get(serverBaseUri.toString()); - - if (clientsPerAccount != null) { - OwnCloudCredentials credentials = - AccountUtils.getCredentialsForAccount(context, account); - - /// TODO - CRITERIA FOR MATCH OF KEYS!!! - OwnCloudClient client = clientsPerAccount.get(credentials); - if (client != null) { - AccountUtils.saveClient(client, account, context.getApplicationContext()); - } - } + Iterator accountNames = mClientsWithKnownUsername.keySet().iterator(); + String accountName = null; + Account account = null; + while (accountNames.hasNext()) { + accountName = accountNames.next(); + account = new Account(accountName, accountType); + AccountUtils.saveClient( + mClientsWithKnownUsername.get(accountName), + account, + context); } - }