Tuesday, December 8, 2015

Enemies VI: My Own Worst Enemy

Pictures are mostly the same as the old one, the only difference is that now the data is saved.




GitHub


Wow, this has been on the shelf for a while. I was about 94% done, but I got stuck on data persistence. Saving an arraylist of objects that contains other objects? How is that even possible? I spent most of my time, the last couple months going through books Android and CS books and I left this for so long that it became harder and harder to come back. With my last app though, I dipped my toe in the water of sharePrefs, and that gave me the confidence to at least look at this app again.

I thought I'd just tinker around with Gson a bit today. I tried out some sample methods and set log tags to see what data I go back. It took me a couple hours, but I had a pretty good handle on it. Then all that was left was applying my new found knowledge to Enemies. The work I did before hand really helped, and I made my way through some difficult problems. I guess it's a requirement for programming, but everything is necessarily broken down into smaller parts. I'm always taken aback when I'm finished with something, I'm so focused on working through each piece of the puzzle and it's a pleasant surprise when they all fit together.


App Breakdown



This is a note-taking app. The twist is that it's only for noting who your enemies are and why. It may seem on it's face like a kind of shitty or even evil app to make. I'm not a guy with not a lot of enemies, so I likely won't use it. I just though of it and it seemed like a cool idea. I'm a novice, so I have to make simple apps that many people have made before. I didn't want to just make an app that takes notes and then saves them. I feel by adding specificity, I gave my simple app some substance. I'll make a super benevolent app to make up for it karmically.

The look of the app is the result of my making one Google image search and not being able to let go of the prospect of a cool picture. I like it overall. I love that image, as I said, and like the way the title looks like it's cut out of the picture. While this was my original vision and I do like it, it has a bit of an early 2000s website feel too it.

Users can add Enemies to their list. Long presses of each list item brings up the option to edit or delete. A short press leads to another page, where users can add reasons why the enemy is on their list. Reasons can also be edited or deleted via long press. Enemies and Reasons are saved when the app is closed or just stopped.






Small Features 


  • Every user entry has a character limit, and if they are exceeded, confirmation buttons are disabled.

  • Reasons are dated

  • The reason entry has a character count that turns red when exceeded.

  • When a user edits something, the original text appears in the edittext and with a cursor at the end. It sounds like not that big a deal, but it took some work to figure out.

  • A beautiful floating action button that disappears while scrolling the list.




Part I'm most Proud Of



It's been so long that I don't really remember what was most annoying about this app. It probably had something to do with getting that custom font to look right.

When the ReasonActivity closed, I needed to get its data to the MainActivity. This tripped me up at first. I saved a json string to SharedPrefs in a key-value pair. The key was the enemy name.(enemy.getName(), jsonString). I was sending that to a method in the main activity that retrieves reasons, The problem was that this method isn't tied to any particular enemy, So I was sending a Reason data to the main activity, and didn't know how to add it to the appropriate Enemy. After a few minutes it dawned on me that I could store as many key-value pairs as I want in sharedPref, so I sent the Enemy name with a generic key("key", enemy.getName()). This was probably an obvious solution, but when I figured it out I felt like a goddamn genius.







No comments:

Post a Comment