Friday, August 28, 2015

Enemies V

GitHub

Bugfixes


Last night, I showed a friend the app and he pointed out that, while he couldn't enter an empty text field he could enter a blank one that's just full of spaces. To fix it, I just used trim() on my input variables before validation. I also noticed a few other things while I was at it.


When users edit a text field, I have the previous text show up in the edittext. The cursor was always at the beginning of the text, and I would always have to place it at the end. After a little research, I figured out that I could amend this with the edittext's setselection() property. It was still a little tricky. I was using it in a dialog builder, and it wasn't having any effect. I realized that the setselection() statement has to be the last thing before I call builder.setview().


I also decided to institute a 30 character limit for Enemy names, which I put into the textWatcher that I had already set up. I disabled the submit button and displayed a toast. A problem then arose that every character the user entered after the limit would generate it's own subsequent toast. So I set up a Toast variable set to null, and a displayToast() method, which checks for the value of toast. If the toast is null, it is created and displayed, otherwise the toast is cancelled. Fuck. I just realized that this won't work if there are multiple Enemies, because there is only one toast value. I guess I'll have to set the toast to null after a certain point, like after submit is clicked, that way the Toast variable will start out fresh for every new entry. I guess when the Add or edit buttons are pressed.


I've still got to tackled Data persistence to finish this up. I've been looking into it, and I think my best option is to use a combination of shared preferences and Gson to convert my Enemy and Reason objects into json data.

No comments:

Post a Comment