mozilla/MozStumbler — pull request #1075 by crankycoder (2014-10-23 02:26:09+00:00)
Title: Features/957 megapatch

This is a large patch, but I've rebased it into something that is hopefully digestable.

In order the patches are:

* d7c1924 is a straight copy of the osmdroid codebase that we've been using until now. There are no code modifications.

* 9ae2bf0 which moves org.osmdroid into org.mozilla.osmdroid. Code has been reformatted to force brace brackets as well as organizing imports. No other code change is involved.

* 8721509 is where I squashed all changes to osmdroid.

The key bits that you will care about are:
1) I've removed MapTileProvider and MapTileFilesystemProvider as we no longer use them
2) Those have been replaced with SmartFSProvider which is a facade around tile loading from disk or network. The SmartFSProvider caches tiles on disk for 300 seconds, does a conditional GET of the tile and save the tile to disk with an etag and a cache control file (which is used to enforce the 300 second cache rule)
3) MapTileDownloader has been replaced with a TileDownloaderDelegate. This uses HttpUrlConnection instead of the Apache DefaultHttpClient. I've added socket timeouts and connection timeouts as well as using connection recycling if the Android API level is appropriate.
4) ZoomInLooper and ZoomOutLooper have had the handleTile method changed to a no-op. This prevents tiles from rescaling when a zoom operation occurs. osmdroid's zoom bug (https://github.com/osmdroid/osmdroid/issues/52) is caused (basically) because of a poor design which marks tiles as 'dirty'. There's no easy way to fix this so I simply don't scale tiles anymore.

There an LRUCache in play which marks tiles as 'dirty' and in need of a download, the cache somtimes evicts tiles before they can be pulled from cache and redownloaded, so I've also forced the OVERSHOOT_TILE_CACHE_SIZE to be 100 tiles (from 0) to increase the chances that the LRU doesn't evict tiles too quickly. The LRUCache should really be removed entirely and this part of the code needs a redesign.

There are low hanging fruit CPU optimizations we can make to remove the calls to handleTile() so that we aren't looping over all tiles in a zoom just to do nothing.

* 25141a8
1) adds GET support to HttpUtil as well as providing a means to access the raw bytes of the downloaded content.
2) All Log.e() calls now require a Throwable type as the last argument. You cannot just pass strings to a Log.e() call. If you do, you should probably be using Log.w() for warnings.

The last two commits ccc2c65 and db98db7 are small adjustments to the build system and to reduce the logging level of some verbose and info messages down to debug as they are not important to normal runtime execution.

If you checkout this code into a separate branch, you can diff the mozstumbler changes using:
```
git diff -w dev android/src/main/java/org/mozilla/mozstumbler
```