question: private ArrayList < String > filterYears ( ArrayList < String > items ) { Iterator < String > iterator ; Calendar now = Calendar . getInstance ( ) ; int year = now . get ( Calendar . YEAR ) ; String yearInString = String . valueOf ( year ) ; Log . d ( TAG , "Year: " + yearInString ) ; int prevYear = year - 1 ; String prevYearInString = String . valueOf ( prevYear ) ; Log . d ( TAG , "Previous year: " + prevYearInString ) ; for ( iterator = items . iterator ( ) ; iterator . hasNext ( ) ; ) { String s = iterator . next ( ) ; if ( s . matches ( ".*(19|20)\\d{2}.*" ) && ! s . contains ( yearInString ) && ! s . contains ( prevYearInString ) ) { Log . d ( TAG , "Filtering out year " + s ) ; iterator . remove ( ) ; } } Log . d ( TAG , "Items: " + items . toString ( ) ) ; return items ; }
target:  Remove categories that contain a year in them (starting with 19__ or 20__), except for this year and previous year Rationale: https://github.com/commons-app/apps-android-commons/issues/47