mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	Refactoring to not expose the ApiResult and Apache HTTP implementation
This commit is contained in:
		
							parent
							
								
									599e7bb453
								
							
						
					
					
						commit
						d64c1b51cc
					
				
					 14 changed files with 386 additions and 200 deletions
				
			
		|  | @ -12,14 +12,14 @@ import android.os.Bundle; | |||
| import android.os.RemoteException; | ||||
| import android.text.TextUtils; | ||||
| 
 | ||||
| import org.mediawiki.api.ApiResult; | ||||
| 
 | ||||
| import java.io.IOException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import fr.free.nrw.commons.CommonsApplication; | ||||
| import fr.free.nrw.commons.Utils; | ||||
| import fr.free.nrw.commons.mwapi.LogEventResult; | ||||
| import fr.free.nrw.commons.mwapi.MediaWikiApi; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
|  | @ -65,7 +65,7 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter { | |||
|         SharedPreferences prefs = this.getContext().getSharedPreferences("prefs", Context.MODE_PRIVATE); | ||||
|         String lastModified = prefs.getString("lastSyncTimestamp", ""); | ||||
|         Date curTime = new Date(); | ||||
|         ApiResult result; | ||||
|         LogEventResult result; | ||||
|         Boolean done = false; | ||||
|         String queryContinue = null; | ||||
|         while(!done) { | ||||
|  | @ -81,22 +81,21 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter { | |||
|             } | ||||
|             Timber.d("Last modified at %s", lastModified); | ||||
| 
 | ||||
|             ArrayList<ApiResult> uploads = result.getNodes("/api/query/logevents/item"); | ||||
|             Timber.d("%d results!", uploads.size()); | ||||
|             List<LogEventResult.LogEvent> logEvents = result.getLogEvents(); | ||||
|             Timber.d("%d results!", logEvents.size()); | ||||
|             ArrayList<ContentValues> imageValues = new ArrayList<>(); | ||||
|             for(ApiResult image: uploads) { | ||||
|                 String pageId = image.getString("@pageid"); | ||||
|                 if (pageId.equals("0")) { | ||||
|             for (LogEventResult.LogEvent image : logEvents) { | ||||
|                 if (image.isDeleted()) { | ||||
|                     // means that this upload was deleted. | ||||
|                     continue; | ||||
|                 } | ||||
|                 String filename = image.getString("@title"); | ||||
|                 String filename = image.getFilename(); | ||||
|                 if(fileExists(contentProviderClient, filename)) { | ||||
|                     Timber.d("Skipping %s", filename); | ||||
|                     continue; | ||||
|                 } | ||||
|                 String thumbUrl = Utils.makeThumbBaseUrl(filename); | ||||
|                 Date dateUpdated = Utils.parseMWDate(image.getString("@timestamp")); | ||||
|                 Date dateUpdated = image.getDateUpdated(); | ||||
|                 Contribution contrib = new Contribution(null, thumbUrl, filename, "", -1, dateUpdated, dateUpdated, user, "", ""); | ||||
|                 contrib.setState(Contribution.STATE_COMPLETED); | ||||
|                 imageValues.add(contrib.toContentValues()); | ||||
|  | @ -118,7 +117,8 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter { | |||
|                     throw new RuntimeException(e); | ||||
|                 } | ||||
|             } | ||||
|             queryContinue = result.getString("/api/query-continue/logevents/@lestart"); | ||||
| 
 | ||||
|             queryContinue = result.getQueryContinue(); | ||||
|             if(TextUtils.isEmpty(queryContinue)) { | ||||
|                 done = true; | ||||
|             } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Paul Hawke
						Paul Hawke