mirror of
				https://github.com/nerzhul/ownCloud-SMS-App.git
				synced 2025-10-31 02:17:53 +00:00 
			
		
		
		
	SmsFetcher: do the cursor checks directly in SmsDataProviderAPI
This commit is contained in:
		
							parent
							
								
									8212ef63aa
								
							
						
					
					
						commit
						8395ac5bb4
					
				| @ -63,16 +63,6 @@ public class SmsFetcher { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (c.getCount() == 0) { |  | ||||||
| 			c.close(); |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if (!c.moveToFirst()) { |  | ||||||
| 			c.close(); |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		// Reading mailbox | 		// Reading mailbox | ||||||
| 		do { | 		do { | ||||||
| 			JSONObject entry = new JSONObject(); | 			JSONObject entry = new JSONObject(); | ||||||
| @ -108,18 +98,6 @@ public class SmsFetcher { | |||||||
| 			return null; | 			return null; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// or for a reason count returns zero value |  | ||||||
| 		if (c.getCount() == 0) { |  | ||||||
| 			c.close(); |  | ||||||
| 			return null; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		// If no first message into cursor |  | ||||||
| 		if (!c.moveToFirst()) { |  | ||||||
| 			c.close(); |  | ||||||
| 			return null; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		// We create a list of strings to store results | 		// We create a list of strings to store results | ||||||
| 		JSONArray results = new JSONArray(); | 		JSONArray results = new JSONArray(); | ||||||
| 		JSONObject entry = new JSONObject(); | 		JSONObject entry = new JSONObject(); | ||||||
| @ -169,20 +147,6 @@ public class SmsFetcher { | |||||||
| 			Log.i(SmsFetcher.TAG, "Retrieved " + c.getCount() + " messages."); | 			Log.i(SmsFetcher.TAG, "Retrieved " + c.getCount() + " messages."); | ||||||
| 		} else { | 		} else { | ||||||
| 			Log.i(SmsFetcher.TAG, "No message retrieved."); | 			Log.i(SmsFetcher.TAG, "No message retrieved."); | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if (c == null) { |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if (c.getCount() == 0) { |  | ||||||
| 			c.close(); |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		// Reading mailbox |  | ||||||
| 		if (!c.moveToFirst()) { |  | ||||||
| 			c.close(); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -117,7 +117,22 @@ public class SmsDataProvider extends ContentProvider { | |||||||
| 
 | 
 | ||||||
|         Log.i(SmsDataProvider.TAG, "query: selection set to " + selection); |         Log.i(SmsDataProvider.TAG, "query: selection set to " + selection); | ||||||
| 
 | 
 | ||||||
|         return _context.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder); |         Cursor cursor = _context.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder); | ||||||
|  | 		if (cursor == null) { | ||||||
|  | 			return null; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if (cursor.getCount() == 0) { | ||||||
|  | 			cursor.close(); | ||||||
|  | 			return null; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if (!cursor.moveToFirst()) { | ||||||
|  | 			cursor.close(); | ||||||
|  | 			return null; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		return cursor; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user