private ProgramFilter[] createFilterList() {
final HashMap<String, ProgramFilter> filterList = new HashMap<String, ProgramFilter>();
/* Add default filters. The user may not remove them. */
ProgramFilter showAll = new ShowAllFilter();
filterList.put(showAll.getName(), showAll);
ProgramFilter pluginFilter = new PluginFilter();
filterList.put(pluginFilter.getName(), pluginFilter);
ProgramFilter subtitleFilter = new SubtitleFilter();
filterList.put(subtitleFilter.getName(), subtitleFilter);
ProgramFilter audioDescriptionFilter = new AudioDescriptionFilter();
filterList.put(audioDescriptionFilter.getName(), audioDescriptionFilter);
/* Read the available filters from the file system and add them to the array */
if (mFilterDirectory == null) {
throw new NullPointerException("directory is null");
}
File[] fileList = getFilterFiles();
if (fileList != null) {
for (File file : fileList) {
UserFilter filter = null;
try {
filter = new UserFilter(file);
} catch (ParserException e) {
mLog.warning("error parsing filter from file " + file + "; exception: " + e);
}
if (filter != null) {
filterList.put(filter.getName(), filter);
}
}
}
PluginAccess[] plugins = PluginManagerImpl.getInstance().getActivatedPlugins();
for (PluginAccess plugin : plugins) {
PluginsProgramFilter[] filters = plugin.getAvailableFilter();
if (filters != null) {
for (PluginsProgramFilter filter : filters) {
filterList.put(filter.getName(), filter);
}
}
}
final ArrayList<ProgramFilter> filterArr = new ArrayList<ProgramFilter>();
/* Sort the list*/
try {
File filterFile = new File(mFilterDirectory, FILTER_INDEX);
if (filterFile.canRead()) {
StreamUtilities.bufferedReader(filterFile,
new BufferedReaderProcessor() {
public void process(BufferedReader inxIn) throws IOException {
String curFilterName = inxIn.readLine();
while (curFilterName != null) {
if (curFilterName.equals("[SEPARATOR]")) {
filterArr.add(new SeparatorFilter());
} else {
ProgramFilter filter = filterList.get(curFilterName);
if (filter != null) {
filterArr.add(filter);
filterList.remove(curFilterName);
}