Homework Two – Pokedex
For my assignment using lists and databases,I decided to create a very basic Pokedex. It includes the first 4 generations (493) Pokemon, with some rather basic information on each one stored in a database. That is, by any stretch of the imagination, too long of a list to have in a single android list activity. But at the same time, there are many ways to want to look through them all. So the first Activity is about what way you would like to sort through the pokemon. By generation (number), name, or type.
There’s also a “Favorite” functionality that allows you to tag your favorite pokemon (information stored in the database), for easy access. After saying how you want to look through the pokemon, you then have a list displayed for the parameter based on your search method (ie: Which generation, what range of names (“A through C”) or what type). Each version of this is contained in a single activity, and its display is based on the extra passed in from the first activity. (public static final variables combined with switches proved to be very effective). Then a second extra is passed along for a database search. The database class gets handed two variables representing the search type and search parameter to determine what it needs to retrieve. After the query, it lists the results and tells you how many there are.
Hidden functionality, if you long click on a pokemon in this list activity, it will automatically be added to favorites (it’ll toast you about its success). Beyond that, choose your pokemon!
I didn’t emphasize layout as much as I should have, but I put it together all by myself, which is a first! It has the name, sprite, and type(s). There’s a favorites checkbox which automatically persists whether or not you mark it as a favorite. And there’s a “Female” checkbox. Some pokemon have an alternative sprite based on their gender, if that’s the case for the displayed pokemon, you have the option to see both sprites. In the example of Rhydon, the male’s Rhydon horn (on his face) is larger.
Problems that occured. Walking into this plan, I knew where problems were most likely to arise. In the database, and in the file resources.
Database: The horrible thing about databases here is that you can screw up somewhere, but it doesn’t cause problems til significantly later. As is what happened in my database creation. I left out a few commas, and later when I was adding entries from a file, it wouldn’t add. I spent forever trying to get it to work (every change in the database creation had to be met with a version number change, I had to do this at least 30 times until I found the problem).
Resources (and assets). This is where the true nightmare lied. First and foremost was loading the pokedex entries from a text file. It took a while to figure out how to access a text file. Had to open a filestream from it and give that to a scanner. This problem was negligible compared to the later issues. Second were the type icons. There were only 17, so I was able to use them easily as resources, though to access them appropriately, I had to use a 17 step switch, it was pretty, but it wasn’t hard.
Then I was confronted with the pokemon image sprites, all ~600 (including female sprites) of them. Sorting them by “R.id.” and a giant switch using the resource folder would be insane. After some digging about, I found that the assets folder would serve my purpose, as I open by a filename stringĀ (and each image file is named by the pokedex number of the pokemon it represents)
Functionality I thought about adding: Shiny sprites. Each pokemon has a shiny variation of their sprite. I had the image files for it, but ultimately,there was no exercise to it, and it drastically increased the build time to include the files. Pokemon cries. Each pokemon makes a unique sound. As much as I’d love to have to work with system sound permissions, that was 90MB of resources I wasn’t willing/able to include (especially building with 2MB of resources took a minute anyway). The most feasible idea I could have included was to make my own array adapter for the list of pokemon, and highlight any pokemon that are favorited.