Filtering your Pod

The final task is to filter the content of the Pod. In the movies example we will want to filter out all movies where the genre does not match the currently selected one.

Figure 1. Filter the movies by genre
067        if (selectedGenre.equals(movie.genre) 
068            || selectedGenre.equals("all")){
069          
070          myFavouriteMovies.addRow();
071          myFavouriteMovies.addEntry(1, row++, movieName);
072        }

So that completes our filter. When the Pod is loaded for the first time no value will be stored for the filter. Every subsequent save will store the filter value, even if that is an empty String. When the Pod reloads it will use the saved value to filter the list of Movies, and it will also pass the stored value back to the filter for display so that we can see what filter is being applied.

Using the PodBuilder, PodFilter and ChoiceBuilder has meant that there was no requirement to create Renderers. The builder classes allow us to reuse existing renderers. There will however be occasions where you want to create a custom filter type. In the next chapter we will demonstrate how to create a new filter renderer.