mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	Move new Http query together with other ApacheHttpRequests
This commit is contained in:
		
							parent
							
								
									3b17d96bae
								
							
						
					
					
						commit
						6412e15f20
					
				
					 4 changed files with 29 additions and 31 deletions
				
			
		|  | @ -273,7 +273,8 @@ public  class       ContributionsActivity | |||
|         CommonsApplication application = CommonsApplication.getInstance(); | ||||
| 
 | ||||
|         compositeDisposable.add( | ||||
|                 RxJava2Tasks.getUploadCount(application.getCurrentAccount().name) | ||||
|                 CommonsApplication.getInstance().getMWApi() | ||||
|                         .getUploadCount(application.getCurrentAccount().name) | ||||
|                         .subscribeOn(Schedulers.io()) | ||||
|                         .observeOn(AndroidSchedulers.mainThread()) | ||||
|                         .subscribe( | ||||
|  |  | |||
|  | @ -1,30 +0,0 @@ | |||
| package fr.free.nrw.commons.contributions; | ||||
| 
 | ||||
| import java.io.BufferedReader; | ||||
| import java.io.InputStreamReader; | ||||
| import java.net.HttpURLConnection; | ||||
| import java.net.URL; | ||||
| import java.util.Locale; | ||||
| 
 | ||||
| import fr.free.nrw.commons.PageTitle; | ||||
| import io.reactivex.Single; | ||||
| 
 | ||||
| class RxJava2Tasks { | ||||
| 
 | ||||
|     private static final String UPLOAD_COUNT_URL_TEMPLATE = | ||||
|             "https://tools.wmflabs.org/urbanecmbot/uploadsbyuser/uploadsbyuser.py?user=%s"; | ||||
| 
 | ||||
|     static Single<Integer> getUploadCount(String userName) { | ||||
|         return Single.fromCallable(() -> { | ||||
|             URL url = new URL(String.format(Locale.ENGLISH, UPLOAD_COUNT_URL_TEMPLATE, | ||||
|                     new PageTitle(userName).getText())); | ||||
|             HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); | ||||
|             BufferedReader bufferedReader = new BufferedReader(new | ||||
|                     InputStreamReader(urlConnection.getInputStream())); | ||||
|             String uploadCount = bufferedReader.readLine(); | ||||
|             bufferedReader.close(); | ||||
|             urlConnection.disconnect(); | ||||
|             return Integer.parseInt(uploadCount); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Mikel
						Mikel