mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Add filterYears method
This commit is contained in:
parent
aaf91ac264
commit
bff5ce96b0
2 changed files with 17 additions and 10 deletions
|
|
@ -222,16 +222,7 @@ public class CategorizationFragment extends Fragment {
|
||||||
//Needs to be an ArrayList and not a List unless we want to modify a big portion of preexisting code
|
//Needs to be an ArrayList and not a List unless we want to modify a big portion of preexisting code
|
||||||
ArrayList<String> mergedItemsList = new ArrayList<String>(mergedItems);
|
ArrayList<String> mergedItemsList = new ArrayList<String>(mergedItems);
|
||||||
|
|
||||||
//Copy to Iterator to prevent ConcurrentModificationException when removing item
|
|
||||||
for(Iterator<String> item = mergedItemsList.iterator(); item.hasNext();) {
|
|
||||||
String s = item.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.d(TAG, "Merged item list: " + mergedItemsList);
|
Log.d(TAG, "Merged item list: " + mergedItemsList);
|
||||||
return mergedItemsList;
|
return mergedItemsList;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import org.mediawiki.api.MWApi;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||||
|
|
||||||
|
|
@ -41,6 +42,21 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
|
||||||
catFragment.categoriesSkip.setVisibility(View.GONE);
|
catFragment.categoriesSkip.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ArrayList<String> filterYears(ArrayList<String> items) {
|
||||||
|
//Copy to Iterator to prevent ConcurrentModificationException when removing item
|
||||||
|
for(Iterator<String> item = items.iterator(); item.hasNext();) {
|
||||||
|
String s = item.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ArrayList<String> doInBackground(Void... voids) {
|
protected ArrayList<String> doInBackground(Void... voids) {
|
||||||
//If user hasn't typed anything in yet, get GPS and recent items
|
//If user hasn't typed anything in yet, get GPS and recent items
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue