mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	* #3448 CategoryImagesListFragment.handleError never succeeds - remove timeouts, rely on default timeout params * #3448 CategoryImagesListFragment.handleError never succeeds - fix compilation
This commit is contained in:
		
							parent
							
								
									6d687c3efb
								
							
						
					
					
						commit
						953f09d683
					
				
					 8 changed files with 21 additions and 69 deletions
				
			
		|  | @ -1,5 +1,8 @@ | |||
| package fr.free.nrw.commons.bookmarks.pictures; | ||||
| 
 | ||||
| import static android.view.View.GONE; | ||||
| import static android.view.View.VISIBLE; | ||||
| 
 | ||||
| import android.annotation.SuppressLint; | ||||
| import android.os.Bundle; | ||||
| import android.view.LayoutInflater; | ||||
|  | @ -11,15 +14,8 @@ import android.widget.ListAdapter; | |||
| import android.widget.ProgressBar; | ||||
| import android.widget.RelativeLayout; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import androidx.annotation.NonNull; | ||||
| import androidx.annotation.Nullable; | ||||
| 
 | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| 
 | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import butterknife.BindView; | ||||
| import butterknife.ButterKnife; | ||||
| import dagger.android.support.DaggerFragment; | ||||
|  | @ -32,15 +28,12 @@ import fr.free.nrw.commons.utils.ViewUtil; | |||
| import io.reactivex.android.schedulers.AndroidSchedulers; | ||||
| import io.reactivex.disposables.CompositeDisposable; | ||||
| import io.reactivex.schedulers.Schedulers; | ||||
| import java.util.List; | ||||
| import javax.inject.Inject; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
| import static android.view.View.GONE; | ||||
| import static android.view.View.VISIBLE; | ||||
| 
 | ||||
| public class BookmarkPicturesFragment extends DaggerFragment { | ||||
| 
 | ||||
|     private static final int TIMEOUT_SECONDS = 15; | ||||
| 
 | ||||
|     private GridViewAdapter gridAdapter; | ||||
|     private CompositeDisposable compositeDisposable = new CompositeDisposable(); | ||||
| 
 | ||||
|  | @ -120,7 +113,6 @@ public class BookmarkPicturesFragment extends DaggerFragment { | |||
|         compositeDisposable.add(controller.loadBookmarkedPictures() | ||||
|                 .subscribeOn(Schedulers.io()) | ||||
|                 .observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .subscribe(this::handleSuccess, this::handleError)); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,7 +30,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers; | |||
| import io.reactivex.disposables.CompositeDisposable; | ||||
| import io.reactivex.schedulers.Schedulers; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import javax.inject.Inject; | ||||
| import javax.inject.Named; | ||||
| import timber.log.Timber; | ||||
|  | @ -40,7 +39,6 @@ import timber.log.Timber; | |||
|  */ | ||||
| public class CategoryImagesListFragment extends DaggerFragment { | ||||
| 
 | ||||
|     private static int TIMEOUT_SECONDS = 15; | ||||
|     /** | ||||
|      * counts the total number of items loaded from the API | ||||
|      */ | ||||
|  | @ -121,7 +119,6 @@ public class CategoryImagesListFragment extends DaggerFragment { | |||
|         compositeDisposable.add(mediaClient.getMediaListFromCategory(categoryName) | ||||
|                 .subscribeOn(Schedulers.io()) | ||||
|                 .observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .subscribe(this::handleSuccess, this::handleError)); | ||||
|     } | ||||
| 
 | ||||
|  | @ -227,7 +224,6 @@ public class CategoryImagesListFragment extends DaggerFragment { | |||
|         compositeDisposable.add(mediaClient.getMediaListFromCategory(categoryName) | ||||
|                 .subscribeOn(Schedulers.io()) | ||||
|                 .observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .subscribe(this::handleSuccess, this::handleError)); | ||||
|     } | ||||
| 
 | ||||
|  | @ -273,7 +269,6 @@ public class CategoryImagesListFragment extends DaggerFragment { | |||
|         compositeDisposable.add(mediaClient.getCaptionByWikibaseIdentifier(wikibaseIdentifier) | ||||
|                 .subscribeOn(Schedulers.io()) | ||||
|                 .observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .subscribe(subscriber -> { | ||||
|                     handleLabelforImage(subscriber, i); | ||||
|                 })); | ||||
|  |  | |||
|  | @ -1,6 +1,9 @@ | |||
| package fr.free.nrw.commons.category; | ||||
| 
 | ||||
| 
 | ||||
| import static android.view.View.GONE; | ||||
| import static android.view.View.VISIBLE; | ||||
| 
 | ||||
| import android.content.Intent; | ||||
| import android.content.res.Configuration; | ||||
| import android.os.Bundle; | ||||
|  | @ -9,21 +12,12 @@ import android.view.View; | |||
| import android.view.ViewGroup; | ||||
| import android.widget.ProgressBar; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import androidx.recyclerview.widget.GridLayoutManager; | ||||
| import androidx.recyclerview.widget.LinearLayoutManager; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
| 
 | ||||
| import com.pedrogomez.renderers.RVRendererAdapter; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| 
 | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import butterknife.BindView; | ||||
| import butterknife.ButterKnife; | ||||
| import com.pedrogomez.renderers.RVRendererAdapter; | ||||
| import fr.free.nrw.commons.R; | ||||
| import fr.free.nrw.commons.di.CommonsDaggerSupportFragment; | ||||
| import fr.free.nrw.commons.explore.categories.SearchCategoriesAdapterFactory; | ||||
|  | @ -31,19 +25,17 @@ import fr.free.nrw.commons.utils.NetworkUtils; | |||
| import fr.free.nrw.commons.utils.ViewUtil; | ||||
| import io.reactivex.android.schedulers.AndroidSchedulers; | ||||
| import io.reactivex.schedulers.Schedulers; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import javax.inject.Inject; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
| import static android.view.View.GONE; | ||||
| import static android.view.View.VISIBLE; | ||||
| 
 | ||||
| /** | ||||
|  * Displays the category search screen. | ||||
|  */ | ||||
| 
 | ||||
| public class SubCategoryListFragment extends CommonsDaggerSupportFragment { | ||||
| 
 | ||||
|     private static int TIMEOUT_SECONDS = 15; | ||||
| 
 | ||||
|     @BindView(R.id.imagesListBox) | ||||
|     RecyclerView categoriesRecyclerView; | ||||
|     @BindView(R.id.imageSearchInProgress) | ||||
|  | @ -99,14 +91,12 @@ public class SubCategoryListFragment extends CommonsDaggerSupportFragment { | |||
|             compositeDisposable.add(categoryClient.getParentCategoryList("Category:"+categoryName) | ||||
|                     .subscribeOn(Schedulers.io()) | ||||
|                     .observeOn(AndroidSchedulers.mainThread()) | ||||
|                     .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                     .collect(ArrayList<String>::new, ArrayList::add) | ||||
|                     .subscribe(this::handleSuccess, this::handleError)); | ||||
|         } else { | ||||
|             compositeDisposable.add(categoryClient.getSubCategoryList("Category:"+categoryName) | ||||
|                     .subscribeOn(Schedulers.io()) | ||||
|                     .observeOn(AndroidSchedulers.mainThread()) | ||||
|                     .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                     .collect(ArrayList<String>::new, ArrayList::add) | ||||
|                     .subscribe(this::handleSuccess, this::handleError)); | ||||
|         } | ||||
|  |  | |||
|  | @ -23,12 +23,10 @@ import io.reactivex.android.schedulers.AndroidSchedulers; | |||
| import io.reactivex.disposables.CompositeDisposable; | ||||
| import io.reactivex.schedulers.Schedulers; | ||||
| import java.util.Random; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
| public class ContributionViewHolder extends RecyclerView.ViewHolder { | ||||
| 
 | ||||
|     private static final long TIMEOUT_SECONDS = 15; | ||||
|     private final Callback callback; | ||||
|     @BindView(R.id.contributionImage) | ||||
|     SimpleDraweeView imageView; | ||||
|  | @ -121,7 +119,6 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder { | |||
|                 compositeDisposable.add(mediaClient.getCaptionByWikibaseIdentifier(wikibaseMediaId) | ||||
|                     .subscribeOn(Schedulers.io()) | ||||
|                     .observeOn(AndroidSchedulers.mainThread()) | ||||
|                     .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                     .subscribe(subscriber -> { | ||||
|                         if (!subscriber.trim().equals(MediaClient.NO_CAPTION)) { | ||||
|                             titleView.setText(subscriber); | ||||
|  |  | |||
|  | @ -15,7 +15,6 @@ import java.lang.reflect.Proxy; | |||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import javax.inject.Inject; | ||||
| import javax.inject.Named; | ||||
| import timber.log.Timber; | ||||
|  | @ -47,7 +46,6 @@ public class SubDepictionListPresenter implements SubDepictionListContract.UserA | |||
|     public String query; | ||||
|     protected CompositeDisposable compositeDisposable = new CompositeDisposable(); | ||||
|     DepictsClient depictsClient; | ||||
|     private static int TIMEOUT_SECONDS = 15; | ||||
|     private List<DepictedItem> queryList = new ArrayList<>(); | ||||
|     OkHttpJsonApiClient okHttpJsonApiClient; | ||||
|     /** | ||||
|  | @ -98,7 +96,6 @@ public class SubDepictionListPresenter implements SubDepictionListContract.UserA | |||
|         compositeDisposable.add(depictsClient.getP18ForItem(entityId) | ||||
|                 .subscribeOn(ioScheduler) | ||||
|                 .observeOn(mainThreadScheduler) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .subscribe(response -> { | ||||
|                     view.onImageUrlFetched(response,position); | ||||
|                 })); | ||||
|  |  | |||
|  | @ -1,6 +1,9 @@ | |||
| package fr.free.nrw.commons.explore.categories; | ||||
| 
 | ||||
| 
 | ||||
| import static android.view.View.GONE; | ||||
| import static android.view.View.VISIBLE; | ||||
| 
 | ||||
| import android.content.res.Configuration; | ||||
| import android.os.Bundle; | ||||
| import android.view.LayoutInflater; | ||||
|  | @ -8,23 +11,12 @@ import android.view.View; | |||
| import android.view.ViewGroup; | ||||
| import android.widget.ProgressBar; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import androidx.recyclerview.widget.GridLayoutManager; | ||||
| import androidx.recyclerview.widget.LinearLayoutManager; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
| 
 | ||||
| import com.pedrogomez.renderers.RVRendererAdapter; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| 
 | ||||
| import javax.inject.Inject; | ||||
| import javax.inject.Named; | ||||
| 
 | ||||
| import butterknife.BindView; | ||||
| import butterknife.ButterKnife; | ||||
| import com.pedrogomez.renderers.RVRendererAdapter; | ||||
| import fr.free.nrw.commons.R; | ||||
| import fr.free.nrw.commons.category.CategoryClient; | ||||
| import fr.free.nrw.commons.category.CategoryDetailsActivity; | ||||
|  | @ -36,19 +28,19 @@ import fr.free.nrw.commons.utils.NetworkUtils; | |||
| import fr.free.nrw.commons.utils.ViewUtil; | ||||
| import io.reactivex.android.schedulers.AndroidSchedulers; | ||||
| import io.reactivex.schedulers.Schedulers; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import javax.inject.Inject; | ||||
| import javax.inject.Named; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
| import static android.view.View.GONE; | ||||
| import static android.view.View.VISIBLE; | ||||
| 
 | ||||
| /** | ||||
|  * Displays the category search screen. | ||||
|  */ | ||||
| 
 | ||||
| public class SearchCategoryFragment extends CommonsDaggerSupportFragment { | ||||
| 
 | ||||
|     private static int TIMEOUT_SECONDS = 15; | ||||
| 
 | ||||
|     @BindView(R.id.imagesListBox) | ||||
|     RecyclerView categoriesRecyclerView; | ||||
|     @BindView(R.id.imageSearchInProgress) | ||||
|  | @ -140,7 +132,6 @@ public class SearchCategoryFragment extends CommonsDaggerSupportFragment { | |||
|         compositeDisposable.add(categoryClient.searchCategories(query,25) | ||||
|                 .subscribeOn(Schedulers.io()) | ||||
|                 .observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .doOnSubscribe(disposable -> saveQuery(query)) | ||||
|                 .collect(ArrayList<String>::new, ArrayList::add) | ||||
|                 .subscribe(this::handleSuccess, this::handleError)); | ||||
|  | @ -159,7 +150,6 @@ public class SearchCategoryFragment extends CommonsDaggerSupportFragment { | |||
|         compositeDisposable.add(categoryClient.searchCategories(query,25, queryList.size()) | ||||
|                 .subscribeOn(Schedulers.io()) | ||||
|                 .observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .collect(ArrayList<String>::new, ArrayList::add) | ||||
|                 .subscribe(this::handlePaginationSuccess, this::handleError)); | ||||
|     } | ||||
|  |  | |||
|  | @ -14,7 +14,6 @@ import java.lang.reflect.Proxy; | |||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import javax.inject.Inject; | ||||
| import javax.inject.Named; | ||||
| import timber.log.Timber; | ||||
|  | @ -35,7 +34,6 @@ public class SearchDepictionsFragmentPresenter extends CommonsDaggerSupportFragm | |||
|                     SearchDepictionsFragmentContract.View.class.getClassLoader(), | ||||
|                     new Class[]{SearchDepictionsFragmentContract.View.class}, | ||||
|                     (proxy, method, methodArgs) -> null); | ||||
|     private static int TIMEOUT_SECONDS = 15; | ||||
|     protected CompositeDisposable compositeDisposable = new CompositeDisposable(); | ||||
|     private final Scheduler ioScheduler; | ||||
|     private final Scheduler mainThreadScheduler; | ||||
|  | @ -91,7 +89,6 @@ public class SearchDepictionsFragmentPresenter extends CommonsDaggerSupportFragm | |||
|       compositeDisposable.add(depictsClient.searchForDepictions(query, 25, offset) | ||||
|             .subscribeOn(ioScheduler) | ||||
|             .observeOn(mainThreadScheduler) | ||||
|             .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|             .doOnSubscribe(disposable -> saveQuery()) | ||||
|             .collect(ArrayList<DepictedItem>::new, ArrayList::add) | ||||
|             .subscribe(this::handleSuccess, this::handleError)); | ||||
|  | @ -171,7 +168,6 @@ public class SearchDepictionsFragmentPresenter extends CommonsDaggerSupportFragm | |||
|          compositeDisposable.add(depictsClient.getP18ForItem(entityId) | ||||
|                 .subscribeOn(ioScheduler) | ||||
|                 .observeOn(mainThreadScheduler) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .subscribe(response -> { | ||||
|                     view.onImageUrlFetched(response,position); | ||||
|                 })); | ||||
|  |  | |||
|  | @ -44,8 +44,6 @@ import timber.log.Timber; | |||
| 
 | ||||
| public class SearchImageFragment extends CommonsDaggerSupportFragment { | ||||
| 
 | ||||
|     private static int TIMEOUT_SECONDS = 15; | ||||
| 
 | ||||
|     @BindView(R.id.imagesListBox) | ||||
|     RecyclerView imagesRecyclerView; | ||||
|     @BindView(R.id.imageSearchInProgress) | ||||
|  | @ -145,7 +143,6 @@ public class SearchImageFragment extends CommonsDaggerSupportFragment { | |||
|         compositeDisposable.add(mediaClient.getMediaListFromSearch(query) | ||||
|                 .subscribeOn(Schedulers.io()) | ||||
|                 .observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .doOnSubscribe(disposable -> saveQuery(query)) | ||||
|                 .subscribe(this::handleSuccess, this::handleError)); | ||||
|     } | ||||
|  | @ -162,7 +159,6 @@ public class SearchImageFragment extends CommonsDaggerSupportFragment { | |||
|         compositeDisposable.add(mediaClient.getMediaListFromSearch(query) | ||||
|                 .subscribeOn(Schedulers.io()) | ||||
|                 .observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                 .subscribe(this::handlePaginationSuccess, this::handleError)); | ||||
|     } | ||||
| 
 | ||||
|  | @ -218,7 +214,6 @@ public class SearchImageFragment extends CommonsDaggerSupportFragment { | |||
|             compositeDisposable.add(mediaClient.getCaptionByWikibaseIdentifier(wikibaseIdentifier) | ||||
|                     .subscribeOn(Schedulers.io()) | ||||
|                     .observeOn(AndroidSchedulers.mainThread()) | ||||
|                     .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||||
|                     .subscribe(subscriber -> { | ||||
|                         handleLabelforImage(subscriber, position); | ||||
|                     })); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Seán Mac Gillicuddy
						Seán Mac Gillicuddy