Credit Where Credit Is Due

While I continue to work on my free online dating service (as well as the accompanying Android dating app), I delve into new territories of Ruby, Rails, and Android programming that I previously have not had to deal with. As such, I’m constantly searching for info to teach myself where to start, where to turn, why I’m encountering errors, and more. I just want to take an opportunity to spread some love to various articles, posts, and comments that have helped me with my work.

Upload Multipart Image Using Android’s HttpPost

Most of my searches about how to upload images to a web server via Java led to information on classes not directly pertaining to Android’s built-in HttpClient and HttpRequestBase classes. However, since the entirety of my JSON HTTP requests in my Android app is based upon these classes, I wanted to utilize them if possible. Finally, I came across Vikas’ post that led me along the correct path. The key is to download and include Apache’s HttpMime library, which is a part of HttpClient 4.1. Because Android is using HttpClient 3.0, this class isn’t available by default on Android. Read Vikas’ post for more info.

Mimicking HTML Drop-downs with Android Spinners

Part of my registration process when for my Android app is to utilize numeric IDs that represent the visible text for various drop-down options (known as Spinners in Android). Simply utilizing the zero-based index of a standard ArrayAdapter wasn’t suitable, however, since the IDs should match up with database values on my server, and will not necessarily be numerically ordered. The solution, as outlined by user385674 on StackOverflow was to utilize a custom Object that includes a custom key and text value, with the toString method returning what the spinner should display.

Loading List Item Images Asynchronously on Android

This is definitely one of the more complex issues I’ve come across in my early development for Android, and it makes me wish there was a built-in method for ImageViews to download remote images. Tim Bray’s post on the official Android blog helps to find a way to handle this situation. However, between his blog post and the sample project on Google Code, I’m sure you’ll see the great level of complexity involved here. The main issue revolves around the race condition between Android’s reuse of views while scrolling through lists and the HTTP response containing the image data for one of these reusable views. The result is that an ImageView could load with the correct image, being replaced moments later by a slower-loading image that shouldn’t even be on the screen anymore.

Integer Out of Range with ThinkingSphinx in Rails

One of the most fun (read: teeth-grindingly frustrating) things about coding is that sometimes things don’t work right out of the box. And not in a “oh, I just need to add a configuration line” kind of way. No, I’m talking about the “I’m using a specific version of [this], and it doesn’t work with a specific version of [that], and there’s no way of knowing it until digging deep into the code…and my soul.” The integer out of range issue I was running into with ThinkingSphinx is exactly the type of thing I’m talking about here. Specifically, it was only happening because I’m using ThinkingSphinx with PostgreSQL, and I needed to set the use_64_bit flag on Sphinx v2.0.1. Since I was using a 1.X version of Sphinx, this meant I had to upgrade.

After attempting to upgrade, I quickly learned that Sphinx 2.0.1 doesn’t work with OS X. User pat on StackOverflow posted a solution: upgrade Sphinx to 2.0.2-dev. This, of course, did not fix the problem for me, resulting in a new “missing pthread_mutex_timedlock” error. After much more digging, I found that at the time pat posted his solution, Sphinx was at revision 2887. However, when I tried to update, the code was at revision 2888, which is where the new error was introduced. The solution was to install revision 2887 from the SVN repository.

According to the official bug report, this issue is now fixed as of revision 2913, although I have not tested personally.

Leave a Reply

Your email address will not be published. Required fields are marked *