keenlabs/KeenClient-Java — pull request #27 by smurthas (2014-11-13 06:31:22+00:00)
Title: Network Reachability

This checks for an available network connection before attempting an upload. It does not do any sort of quality or speed check.

The unit test only exercises the the logic of calling the `isNetworkConnected` method (I hand verified in an Android app and a small Java program as well).

Some things to consider:
* Does the strategy of holding on to the `Builder` object in the client and using the abstract `isNetworkConnected` method to deal with the differences between the two platforms make sense and fit well with the other "platform differences" patterns in the codebase?
* The Java SDK "defaults" to not checking the network status since this is much less of a concern on the server-side. For completeness and consistency, I included a simple (but not very efficient) loop that will only run if a specific network interface name is set via the `JavaKeenClientBuilder.setNetworkInterfaceName` method. Does it even make sense to include this functionality? The only scenario I can envision is a client-side, old-school Java application, but do those still exist? Even if they do, I'm not really certain this is the right pattern (the client app is unlikely to know which interface to check for -- maybe better to just have a boolean flag and skip the loopback interface since that is always "connected"?).
* The loop in the `JavaKeenClientBuilder.isNetworkConnected` method might be inefficient. If we decide to keep that functionality, we should consider caching a pointer to the interface.
* The loop in the `JavaKeenClientBuilder.isNetworkConnected` method fails silently. Should this check for `debug mode == false` and throw the error? (I didn't really look into this as I think we might just ditch that section of code.)
* I could honestly use a sanity check on my private/protected/package/public usage as my head has been buried in JS for too long!