mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +00:00 
			
		
		
		
	Merge pull request #22 from owncloud/operations_service
Moved result data from GetRemoteStatusOperation and GetRemoteUserNameOperation into the RemoteOperationResult instance they their methods execute() return.
This commit is contained in:
		
						commit
						614163529b
					
				| @ -24,6 +24,8 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.resources.status; | package com.owncloud.android.lib.resources.status; | ||||||
| 
 | 
 | ||||||
|  | import java.util.ArrayList; | ||||||
|  | 
 | ||||||
| import org.apache.commons.httpclient.HttpStatus; | import org.apache.commons.httpclient.HttpStatus; | ||||||
| import org.apache.commons.httpclient.methods.GetMethod; | import org.apache.commons.httpclient.methods.GetMethod; | ||||||
| import org.json.JSONException; | import org.json.JSONException; | ||||||
| @ -60,16 +62,10 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|     private String mUrl; |     private String mUrl; | ||||||
|     private RemoteOperationResult mLatestResult; |     private RemoteOperationResult mLatestResult; | ||||||
|     private Context mContext; |     private Context mContext; | ||||||
|     private OwnCloudVersion mOCVersion; |  | ||||||
| 
 | 
 | ||||||
|     public GetRemoteStatusOperation(String url, Context context) { |     public GetRemoteStatusOperation(String url, Context context) { | ||||||
|         mUrl = url; |         mUrl = url; | ||||||
|         mContext = context; |         mContext = context; | ||||||
|         mOCVersion = null; |  | ||||||
|     } |  | ||||||
|      |  | ||||||
|     public OwnCloudVersion getDiscoveredVersion() { |  | ||||||
|         return mOCVersion; |  | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     private boolean tryConnection(OwnCloudClient wc, String urlSt) { |     private boolean tryConnection(OwnCloudClient wc, String urlSt) { | ||||||
| @ -85,8 +81,8 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|                     mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); |                     mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); | ||||||
|                 } else { |                 } else { | ||||||
|                     String version = json.getString(NODE_VERSION); |                     String version = json.getString(NODE_VERSION); | ||||||
|                     mOCVersion = new OwnCloudVersion(version); | 					OwnCloudVersion ocVersion = new OwnCloudVersion(version); | ||||||
|                     if (!mOCVersion.isVersionValid()) { |                     if (!ocVersion.isVersionValid()) { | ||||||
|                         mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.BAD_OC_VERSION); |                         mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.BAD_OC_VERSION); | ||||||
|                          |                          | ||||||
|                     } else { |                     } else { | ||||||
| @ -95,6 +91,9 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|                                                                     RemoteOperationResult.ResultCode.OK_NO_SSL |                                                                     RemoteOperationResult.ResultCode.OK_NO_SSL | ||||||
|                             ); |                             ); | ||||||
| 
 | 
 | ||||||
|  |                         ArrayList<Object> data = new ArrayList<Object>(); | ||||||
|  |                         data.add(ocVersion); | ||||||
|  |                         mLatestResult.setData(data); | ||||||
|                         retval = true; |                         retval = true; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  | |||||||
| @ -24,6 +24,8 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.resources.users; | package com.owncloud.android.lib.resources.users; | ||||||
| 
 | 
 | ||||||
|  | import java.util.ArrayList; | ||||||
|  | 
 | ||||||
| import org.apache.commons.httpclient.methods.GetMethod; | import org.apache.commons.httpclient.methods.GetMethod; | ||||||
| import org.apache.http.HttpStatus; | import org.apache.http.HttpStatus; | ||||||
| import org.json.JSONObject; | import org.json.JSONObject; | ||||||
| @ -93,6 +95,10 @@ public class GetRemoteUserNameOperation extends RemoteOperation { | |||||||
| 				  | 				  | ||||||
| 				 // Result | 				 // Result | ||||||
| 				 result = new RemoteOperationResult(true, status, get.getResponseHeaders()); | 				 result = new RemoteOperationResult(true, status, get.getResponseHeaders()); | ||||||
|  | 				 // Username in result.data | ||||||
|  |                  ArrayList<Object> data = new ArrayList<Object>(); | ||||||
|  |                  data.add(displayName); | ||||||
|  |                  result.setData(data); | ||||||
| 				 mUserName =  displayName; | 				 mUserName =  displayName; | ||||||
| 				  | 				  | ||||||
| 				 Log.d(TAG, "*** Parsed user information: " + id + " - " + displayName + " - " + email); | 				 Log.d(TAG, "*** Parsed user information: " + id + " - " + displayName + " - " + email); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user