This week, I mainly finished server things: Server configure dialog, Implementation of switching room, separate message list for different recipient, font awesome icons for MediaGrid.
For the server configure, I save the server IP and port into SharedPreferences, so next time it shows user’s last configuration.
For the switching room, first an Alert dialog is shown for user to input a room id. Then it clears the message queue, message showing list, and interrupts three long polling thread including longPollingChat, longPollingUser, longPollingIM. Then saveUserDoc is recalled to restart a new room, and reset long polling thread.
For the separate message list, I created a HashMap to map the user name to its corresponding message list. Every time when message is reached, it is written into its message list. And if the message recipient is the same as the recipient that user choose, then message is shown to the list view.
For the font awesome part, the non-system font could be only add with java code dynamically. So I created a getFontAwesome() function in GlobalUtil to load the font data. And the most annoying part is the icon of an item in a list view. Because I’m unable to specify the font in the xml file of an item, I have to extend the SimpleAdapter’s getView() method to specify the font.