mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Rename item to iterator
This commit is contained in:
parent
464d6e0bac
commit
ae0ab0cf2d
1 changed files with 11 additions and 4 deletions
|
|
@ -11,11 +11,14 @@ import org.mediawiki.api.MWApi;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
|
||||
import static android.R.id.list;
|
||||
|
||||
/**
|
||||
* Sends asynchronous queries to the Commons MediaWiki API to retrieve categories that share the
|
||||
* same prefix as the keyword typed in by the user. The 'acprefix' action-specific parameter is used
|
||||
|
|
@ -44,18 +47,22 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
|
|||
|
||||
protected ArrayList<String> filterYears(ArrayList<String> items) {
|
||||
|
||||
Iterator<String> iterator;
|
||||
|
||||
//Copy to Iterator to prevent ConcurrentModificationException when removing item
|
||||
for(Iterator<String> item = items.iterator(); item.hasNext();) {
|
||||
String s = item.next();
|
||||
for(iterator = items.iterator(); iterator.hasNext();) {
|
||||
String s = iterator.next();
|
||||
|
||||
//Check if s contains a 4-digit word anywhere within the string (.* is wildcard)
|
||||
if(s.matches(".*(19|20)\\d{2}.*")) {
|
||||
Log.d(TAG, "Filtering out year " + s);
|
||||
item.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> filteredItems = new ArrayList<String>(items);
|
||||
ArrayList<String> filteredItems = new ArrayList<>();
|
||||
|
||||
|
||||
return filteredItems;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue