mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +00:00 
			
		
		
		
	Fixed issue fully breaking the refresh of current folder (fixed only for SimpleFactoryManager for the moment)
This commit is contained in:
		
							parent
							
								
									17d810fe2b
								
							
						
					
					
						commit
						e6c23205eb
					
				| @ -9,6 +9,8 @@ public class OwnCloudClientManagerFactory { | |||||||
| 	 | 	 | ||||||
| 	public final static Policy DEFAULT_POLICY = Policy.ALWAYS_NEW_CLIENT; | 	public final static Policy DEFAULT_POLICY = Policy.ALWAYS_NEW_CLIENT; | ||||||
| 	 | 	 | ||||||
|  | 	private static OwnCloudClientManager mDefaultSingleton; | ||||||
|  | 
 | ||||||
| 	public static OwnCloudClientManager newDefaultOwnCloudClientManager() { | 	public static OwnCloudClientManager newDefaultOwnCloudClientManager() { | ||||||
| 		return newOwnCloudClientManager(DEFAULT_POLICY); | 		return newOwnCloudClientManager(DEFAULT_POLICY); | ||||||
| 	} | 	} | ||||||
| @ -26,5 +28,11 @@ public class OwnCloudClientManagerFactory { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  |     public static OwnCloudClientManager getDefaultSingleton() { | ||||||
|  |     	if (mDefaultSingleton == null) { | ||||||
|  |     		mDefaultSingleton = newDefaultOwnCloudClientManager(); | ||||||
|  |     	} | ||||||
|  |     	return mDefaultSingleton; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,19 +7,23 @@ import android.accounts.AuthenticatorException; | |||||||
| import android.accounts.OperationCanceledException; | import android.accounts.OperationCanceledException; | ||||||
| import android.content.Context; | import android.content.Context; | ||||||
| import android.net.Uri; | import android.net.Uri; | ||||||
|  | import android.util.Log; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; | import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; | ||||||
| 
 | 
 | ||||||
| public class SimpleFactoryManager implements OwnCloudClientManager { | public class SimpleFactoryManager implements OwnCloudClientManager { | ||||||
|      |      | ||||||
|  | 	private static final String TAG = OwnCloudClientManager.class.getSimpleName(); | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) { | 	public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) { | ||||||
|  | 		Log.d(TAG, "getClientFor(OwnCloudAccount ... : "); | ||||||
| 		OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient( | 		OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient( | ||||||
| 				account.getBaseUri(),  | 				account.getBaseUri(),  | ||||||
| 				context.getApplicationContext(), | 				context.getApplicationContext(), | ||||||
| 				true); | 				true); | ||||||
| 
 | 
 | ||||||
|  | 		Log.d(TAG, "    new client " + client.hashCode()); | ||||||
| 		client.setCredentials(account.getCredentials()); | 		client.setCredentials(account.getCredentials()); | ||||||
| 		return client; | 		return client; | ||||||
| 	} | 	} | ||||||
| @ -29,15 +33,20 @@ public class SimpleFactoryManager implements OwnCloudClientManager { | |||||||
| 	public OwnCloudClient getClientFor(Account savedAccount, Context context) | 	public OwnCloudClient getClientFor(Account savedAccount, Context context) | ||||||
| 			throws OperationCanceledException, AuthenticatorException, AccountNotFoundException, | 			throws OperationCanceledException, AuthenticatorException, AccountNotFoundException, | ||||||
| 			IOException { | 			IOException { | ||||||
|  | 		Log.d(TAG, "getClientFor(Account ... : "); | ||||||
| 
 | 
 | ||||||
| 		return OwnCloudClientFactory.createOwnCloudClient( | 		OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient( | ||||||
| 				savedAccount,  | 				savedAccount,  | ||||||
| 				context.getApplicationContext()); | 				context.getApplicationContext()); | ||||||
|  | 		 | ||||||
|  | 		Log.d(TAG, "    new client " + client.hashCode()); | ||||||
|  | 		return client; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public OwnCloudClient getClientFor(Uri serverBaseUri, OwnCloudCredentials credentials, | 	public OwnCloudClient getClientFor(Uri serverBaseUri, OwnCloudCredentials credentials, | ||||||
| 			Context context) { | 			Context context) { | ||||||
|  | 		Log.d(TAG, "getClientFor(Uri ... : "); | ||||||
| 		 | 		 | ||||||
| 		OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient( | 		OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient( | ||||||
| 				serverBaseUri,  | 				serverBaseUri,  | ||||||
| @ -45,6 +54,7 @@ public class SimpleFactoryManager implements OwnCloudClientManager { | |||||||
| 				true); | 				true); | ||||||
| 
 | 
 | ||||||
| 		client.setCredentials(credentials); | 		client.setCredentials(credentials); | ||||||
|  | 		Log.d(TAG, "    new client " + client.hashCode()); | ||||||
| 		return client; | 		return client; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -71,16 +71,9 @@ public class SingleSessionManager implements OwnCloudClientManager { | |||||||
|     		new HashMap<String, OwnCloudClient>(); |     		new HashMap<String, OwnCloudClient>(); | ||||||
|      |      | ||||||
|      |      | ||||||
|     public static OwnCloudClientManager getInstance() { |  | ||||||
|     	if (mInstance == null) { |  | ||||||
|     		mInstance = new SingleSessionManager(); |  | ||||||
|     	} |  | ||||||
|     	return mInstance; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     @Override |     @Override | ||||||
|     public synchronized OwnCloudClient getClientFor(OwnCloudAccount account, Context context) { |     public synchronized OwnCloudClient getClientFor(OwnCloudAccount account, Context context) { | ||||||
|  | 		Log.d(TAG, "getClientFor(OwnCloudAccount ... : "); | ||||||
|     	if (account == null) { |     	if (account == null) { | ||||||
|     		throw new IllegalArgumentException("Cannot get an OwnCloudClient for a null account"); |     		throw new IllegalArgumentException("Cannot get an OwnCloudClient for a null account"); | ||||||
|     	} |     	} | ||||||
| @ -92,17 +85,21 @@ public class SingleSessionManager implements OwnCloudClientManager { | |||||||
|     			account.getCredentials().getAuthToken()); |     			account.getCredentials().getAuthToken()); | ||||||
|     	 |     	 | ||||||
|     	if (accountName != null) { |     	if (accountName != null) { | ||||||
|     		client = mClientsWithKnownUsername.get(account.getName()); |     		client = mClientsWithKnownUsername.get(accountName); | ||||||
|     	} |     	} | ||||||
|     	if (client == null) { |     	if (client == null) { | ||||||
|     		if (accountName != null) { |     		if (accountName != null) { | ||||||
|     			client = mClientsWithUnknownUsername.remove(sessionName); |     			client = mClientsWithUnknownUsername.remove(sessionName); | ||||||
|     			if (client != null) { |     			if (client != null) { | ||||||
|  |     	    		Log.d(TAG, "    reusing client {" + sessionName + ", " + client.hashCode() + "}"); | ||||||
|     				mClientsWithKnownUsername.put(accountName, client); |     				mClientsWithKnownUsername.put(accountName, client); | ||||||
|  |     	    		Log.d(TAG, "    moved client to {" + accountName + ", " + client.hashCode() + "}"); | ||||||
|     			} |     			} | ||||||
|     		} else { |     		} else { | ||||||
|         		client = mClientsWithUnknownUsername.get(sessionName); |         		client = mClientsWithUnknownUsername.get(sessionName); | ||||||
|     		} |     		} | ||||||
|  |     	} else { | ||||||
|  |     		Log.d(TAG, "    reusing client {" + accountName + ", " + client.hashCode() + "}"); | ||||||
|     	} |     	} | ||||||
|     	 |     	 | ||||||
|     	if (client == null) { |     	if (client == null) { | ||||||
| @ -114,9 +111,14 @@ public class SingleSessionManager implements OwnCloudClientManager { | |||||||
|     		client.setCredentials(account.getCredentials()); |     		client.setCredentials(account.getCredentials()); | ||||||
|     		if (accountName != null) { |     		if (accountName != null) { | ||||||
|     			mClientsWithKnownUsername.put(accountName, client); |     			mClientsWithKnownUsername.put(accountName, client); | ||||||
|  |     			Log.d(TAG, "    new client {" + accountName + ", " + client.hashCode() + "}"); | ||||||
|  | 
 | ||||||
|     		} else { |     		} else { | ||||||
|     			mClientsWithUnknownUsername.put(sessionName, client); |     			mClientsWithUnknownUsername.put(sessionName, client); | ||||||
|  |     			Log.d(TAG, "    new client {" + sessionName + ", " + client.hashCode() + "}"); | ||||||
|     		} |     		} | ||||||
|  |     	} else { | ||||||
|  |     		Log.d(TAG, "    reusing client {" + sessionName + ", " + client.hashCode() + "}"); | ||||||
|     	} |     	} | ||||||
|     	 |     	 | ||||||
|     	return client; |     	return client; | ||||||
|  | |||||||
| @ -28,6 +28,7 @@ import java.io.IOException; | |||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient; | import com.owncloud.android.lib.common.OwnCloudClient; | ||||||
| import com.owncloud.android.lib.common.OwnCloudClientFactory; | import com.owncloud.android.lib.common.OwnCloudClientFactory; | ||||||
|  | import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; | ||||||
| import com.owncloud.android.lib.common.OwnCloudCredentials; | import com.owncloud.android.lib.common.OwnCloudCredentials; | ||||||
| import com.owncloud.android.lib.common.SingleSessionManager; | import com.owncloud.android.lib.common.SingleSessionManager; | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; | import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; | ||||||
| @ -104,7 +105,8 @@ public abstract class RemoteOperation implements Runnable { | |||||||
|         mAccount = account; |         mAccount = account; | ||||||
|         mContext = context.getApplicationContext(); |         mContext = context.getApplicationContext(); | ||||||
|         try { |         try { | ||||||
|             mClient = SingleSessionManager.getInstance().getClientFor(mAccount, mContext); |             mClient = OwnCloudClientManagerFactory.getDefaultSingleton(). | ||||||
|  |             		getClientFor(mAccount, mContext); | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             Log.e(TAG, "Error while trying to access to " + mAccount.name, e); |             Log.e(TAG, "Error while trying to access to " + mAccount.name, e); | ||||||
|             return new RemoteOperationResult(e); |             return new RemoteOperationResult(e); | ||||||
| @ -251,7 +253,7 @@ public abstract class RemoteOperation implements Runnable { | |||||||
|                             		mAccount, mContext, mCallerActivity); |                             		mAccount, mContext, mCallerActivity); | ||||||
|                         } else { |                         } else { | ||||||
|                         /** EOF DEPRECATED */ |                         /** EOF DEPRECATED */ | ||||||
|                             mClient = SingleSessionManager.getInstance(). |                             mClient = OwnCloudClientManagerFactory.getDefaultSingleton(). | ||||||
|                             		getClientFor(mAccount, mContext); |                             		getClientFor(mAccount, mContext); | ||||||
|                         } |                         } | ||||||
|                     } else { |                     } else { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user